added translation option to UI and serve

This commit is contained in:
Dobromir Popov
2024-06-10 00:35:45 +03:00
parent 71f075dd63
commit a5f1040cef
2 changed files with 21 additions and 1 deletions

View File

@ -49,11 +49,12 @@ wss.on('connection', (ws, req) => {
console.log('No session data found for session id ' + webSocket.sessionId);
}
let language = sessionData?.language || 'en';
let task = sessionData?.task || 'transcribe';
//show the size of the audio data as 0.000 MB
console.log('(queue ' + queueCounter + ') Received ' + (data.length / 1024 / 1024).toFixed(3) + ' MB audio from client. Crrent language: ' + language);
var request = require('request');
var formData = {
task: 'transcribe',
task: task,
language: sessionData.language,
output: 'json',
audio_file: {
@ -157,6 +158,10 @@ app.post('/settings', (req, res) => {
sessionData.storeRecordings = body.storeRecordings;
console.log(`Session ${sid}: storeRecordings set to ${sessionData.storeRecordings}`);
}
if(body.task != undefined){
sessionData.task = body.task;
}
res.send('OK', 200, { 'Content-Type': 'text/plain' });
});