Update server.js
Browse files
server.js
CHANGED
|
@@ -43,20 +43,13 @@ 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 |
-
|
| 47 |
headers: {
|
| 48 |
'Authorization': `Bearer ${apiKey}`,
|
| 49 |
...whisperFormData.getHeaders(),
|
| 50 |
},
|
| 51 |
});
|
| 52 |
|
| 53 |
-
try {
|
| 54 |
-
const jsonResponse = JSON.parse(whisperResponse.data);
|
| 55 |
-
res.status(whisperResponse.status).json(jsonResponse);
|
| 56 |
-
} catch (error) {
|
| 57 |
-
console.error('Error parsing JSON response:', error);
|
| 58 |
-
res.status(500).json({ error: 'Error parsing JSON response' });
|
| 59 |
-
}
|
| 60 |
|
| 61 |
|
| 62 |
// Forward the response from the Whisper API back to the iOS app
|
|
|
|
| 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(),
|
| 50 |
},
|
| 51 |
});
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
// Forward the response from the Whisper API back to the iOS app
|