Update server.js
Browse files
server.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
2 |
const openaiKey = process.env.OPENAI_KEY;
|
3 |
const proxyKey = process.env.PROXY_KEY; // Your secret proxy key
|
4 |
-
|
5 |
|
6 |
const proxy = require("express-http-proxy");
|
7 |
const fs = require("fs");
|
@@ -9,7 +9,7 @@ const FormData = require("form-data");
|
|
9 |
const port = 7860;
|
10 |
const app = express();
|
11 |
|
12 |
-
|
13 |
const bodyParser = require('body-parser');
|
14 |
const axios = require('axios');
|
15 |
const multer = require('multer'); // for handling multipart/form-data
|
@@ -43,7 +43,7 @@ app.post('/upload', upload.single('file'), async (req, res) => {
|
|
43 |
}
|
44 |
|
45 |
// Make a request to the Whisper API with the obtained API key and multipart/form-data
|
46 |
-
const whisperResponse = await axios.post('
|
47 |
headers: {
|
48 |
'Authorization': `Bearer ${apiKey}`,
|
49 |
...whisperFormData.getHeaders(),
|
|
|
1 |
const baseUrl = getExternalUrl(process.env.SPACE_ID);
|
2 |
const openaiKey = process.env.OPENAI_KEY;
|
3 |
const proxyKey = process.env.PROXY_KEY; // Your secret proxy key
|
4 |
+
const express = require('express');
|
5 |
|
6 |
const proxy = require("express-http-proxy");
|
7 |
const fs = require("fs");
|
|
|
9 |
const port = 7860;
|
10 |
const app = express();
|
11 |
|
12 |
+
|
13 |
const bodyParser = require('body-parser');
|
14 |
const axios = require('axios');
|
15 |
const multer = require('multer'); // for handling multipart/form-data
|
|
|
43 |
}
|
44 |
|
45 |
// Make a request to the Whisper API with the obtained API key and multipart/form-data
|
46 |
+
const whisperResponse = await axios.post('https://api.openai.com/v1/audio/transcriptions', whisperFormData, {
|
47 |
headers: {
|
48 |
'Authorization': `Bearer ${apiKey}`,
|
49 |
...whisperFormData.getHeaders(),
|