yalsaffar commited on
Commit
38ba82a
·
1 Parent(s): b941e8b

Updated Dockerfile for Hugging Face Spaces deployment

Browse files
Files changed (1) hide show
  1. 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
- // Serve the audio file from the public directory
 
80
  const publicAudioPath = path.join(publicDir, path.basename(result.audio_path));
81
- fs.copyFileSync(result.audio_path, publicAudioPath);
82
- res.status(200).json({ audio_path: `/public/${path.basename(result.audio_path)}`, translation: result.translation });
 
 
 
 
 
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');