Update plugins/gptold.js
Browse files- plugins/gptold.js +23 -1
plugins/gptold.js
CHANGED
@@ -27,6 +27,18 @@ import got from "got";
|
|
27 |
* description: url mp3
|
28 |
* schema:
|
29 |
* type: string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
* - in: header
|
31 |
* name: x-api-key
|
32 |
* required: true
|
@@ -44,6 +56,12 @@ GptRoutes.get("/api/v1/ai/openai/whisper-large-v3-turbo", authenticateApiKey, ap
|
|
44 |
"Content-Type": "application/json"
|
45 |
};
|
46 |
const url = req.query.url;
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
const path = await audioContent(url);
|
49 |
if (!path) {
|
@@ -54,7 +72,11 @@ GptRoutes.get("/api/v1/ai/openai/whisper-large-v3-turbo", authenticateApiKey, ap
|
|
54 |
const audioBytes = fs.readFileSync(path);
|
55 |
const audioBase64 = Buffer.from(audioBytes).toString("base64");
|
56 |
|
57 |
-
const inputData = {
|
|
|
|
|
|
|
|
|
58 |
|
59 |
const response = await got.post(API_BASE_URL, {
|
60 |
headers,
|
|
|
27 |
* description: url mp3
|
28 |
* schema:
|
29 |
* type: string
|
30 |
+
* - in: query
|
31 |
+
* name: language
|
32 |
+
* required: true
|
33 |
+
* description: The language of the audio being transcribed or translated.
|
34 |
+
* schema:
|
35 |
+
* type: string
|
36 |
+
* - in: query
|
37 |
+
* name: task
|
38 |
+
* required: true
|
39 |
+
* description: Supported tasks are 'translate' or 'transcribe'.
|
40 |
+
* schema:
|
41 |
+
* type: string
|
42 |
* - in: header
|
43 |
* name: x-api-key
|
44 |
* required: true
|
|
|
56 |
"Content-Type": "application/json"
|
57 |
};
|
58 |
const url = req.query.url;
|
59 |
+
const language = req.query.language || "en";
|
60 |
+
const task = req.query.task || "transcribe";
|
61 |
+
|
62 |
+
if (!url) {
|
63 |
+
return res.status(500).json({ error: "url required" });
|
64 |
+
}
|
65 |
|
66 |
const path = await audioContent(url);
|
67 |
if (!path) {
|
|
|
72 |
const audioBytes = fs.readFileSync(path);
|
73 |
const audioBase64 = Buffer.from(audioBytes).toString("base64");
|
74 |
|
75 |
+
const inputData = {
|
76 |
+
audio: audioBase64,
|
77 |
+
language: language,
|
78 |
+
task: task
|
79 |
+
};
|
80 |
|
81 |
const response = await got.post(API_BASE_URL, {
|
82 |
headers,
|