1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| const url = "https://multi-format-ai-translator-the-most-complete.p.rapidapi.com/translator/translate/srt";
const params = new URLSearchParams({
source: "auto",
target: "es",
});
const srt = `1
00:00:01,000 --> 00:00:04,000
Welcome to our tutorial on machine learning.
2
00:00:04,500 --> 00:00:08,000
Today we will cover the basics of neural networks.
3
00:00:08,500 --> 00:00:12,000
Let's start with understanding what a perceptron is.`;
const response = await fetch(`${url}?${params}`, {
method: "POST",
headers: {
"Content-Type": "text/plain",
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "multi-format-ai-translator-the-most-complete.p.rapidapi.com",
},
body: srt,
});
const data = await response.json();
console.log(data.data.translated_srt);
|