Spaces:
Sleeping
Sleeping
Updated Dockerfile for Hugging Face Spaces deployment
Browse files- app/server.js +9 -3
app/server.js
CHANGED
@@ -76,10 +76,16 @@ app.post('/save-audio', upload.single('audio'), async (req, res) => {
|
|
76 |
console.log(result);
|
77 |
audioPaths.push(result.audio_path);
|
78 |
sentenceIndex++;
|
79 |
-
|
|
|
80 |
const publicAudioPath = path.join(publicDir, path.basename(result.audio_path));
|
81 |
-
fs.
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
83 |
} else {
|
84 |
console.error('Failed to process the file via FastAPI');
|
85 |
res.status(500).send('Failed to process the file via FastAPI');
|
|
|
76 |
console.log(result);
|
77 |
audioPaths.push(result.audio_path);
|
78 |
sentenceIndex++;
|
79 |
+
|
80 |
+
// Copy the audio file to the public directory
|
81 |
const publicAudioPath = path.join(publicDir, path.basename(result.audio_path));
|
82 |
+
fs.copyFile(result.audio_path, publicAudioPath, (err) => {
|
83 |
+
if (err) {
|
84 |
+
console.error('Error copying audio file to public directory:', err);
|
85 |
+
return res.status(500).send('Error copying audio file to public directory');
|
86 |
+
}
|
87 |
+
res.status(200).json({ audio_path: `/generated_audio_audio_${sentenceIndex}.wav`, translation: result.translation });
|
88 |
+
});
|
89 |
} else {
|
90 |
console.error('Failed to process the file via FastAPI');
|
91 |
res.status(500).send('Failed to process the file via FastAPI');
|