Spaces:
Sleeping
Sleeping
Updated Dockerfile for Hugging Face Spaces deployment
Browse files- app/public/app.js +1 -1
- app/server.js +5 -0
app/public/app.js
CHANGED
@@ -84,7 +84,7 @@ async function saveAudioAndTranscription(sentence, index) {
|
|
84 |
|
85 |
// Show translation and play audio
|
86 |
translationElement.textContent = result.translation;
|
87 |
-
audioElement.src = `
|
88 |
audioElement.load(); // Ensure the audio element loads the new source
|
89 |
audioElement.play().catch(error => {
|
90 |
console.error('Error playing audio:', error);
|
|
|
84 |
|
85 |
// Show translation and play audio
|
86 |
translationElement.textContent = result.translation;
|
87 |
+
audioElement.src = `download-audio?file_path=${result.audio_path}`;
|
88 |
audioElement.load(); // Ensure the audio element loads the new source
|
89 |
audioElement.play().catch(error => {
|
90 |
console.error('Error playing audio:', error);
|
app/server.js
CHANGED
@@ -97,6 +97,11 @@ app.post('/save-audio', upload.single('audio'), async (req, res) => {
|
|
97 |
});
|
98 |
});
|
99 |
|
|
|
|
|
|
|
|
|
|
|
100 |
app.get('/concatenate-audio', (req, res) => {
|
101 |
const folderPath = path.join(uploadsDir, getNextFolderNumber().toString());
|
102 |
const finalAudioPath = path.join(folderPath, 'final_audio.wav');
|
|
|
97 |
});
|
98 |
});
|
99 |
|
100 |
+
app.get('/download-audio', (req, res) => {
|
101 |
+
const filePath = path.join(publicDir, req.query.file_path);
|
102 |
+
res.download(filePath);
|
103 |
+
});
|
104 |
+
|
105 |
app.get('/concatenate-audio', (req, res) => {
|
106 |
const folderPath = path.join(uploadsDir, getNextFolderNumber().toString());
|
107 |
const finalAudioPath = path.join(folderPath, 'final_audio.wav');
|