added translation option to UI and serve
This commit is contained in:
parent
71f075dd63
commit
a5f1040cef
@ -129,6 +129,15 @@ disabled
|
|||||||
credentials: 'same-origin'
|
credentials: 'same-origin'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
document.getElementById('task-select').addEventListener('change', (event) => {
|
||||||
|
const task = event.target.value;
|
||||||
|
fetch('/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ task, sessionId }),
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'same-origin'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Draw sliding bar graph
|
// Draw sliding bar graph
|
||||||
function drawSlidingBarGraph(lastVolumes) {
|
function drawSlidingBarGraph(lastVolumes) {
|
||||||
@ -265,6 +274,11 @@ disabled
|
|||||||
if (json.hasOwnProperty("language")) {
|
if (json.hasOwnProperty("language")) {
|
||||||
languageSelect.value = json.language;
|
languageSelect.value = json.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (json.hasOwnProperty("taskSelect")) {
|
||||||
|
taskSelect.value = json.taskSelect;
|
||||||
|
}
|
||||||
|
|
||||||
//storerecordings checkbox
|
//storerecordings checkbox
|
||||||
if (json.hasOwnProperty("storeRecordings")) {
|
if (json.hasOwnProperty("storeRecordings")) {
|
||||||
storeRecordings.checked = json.storeRecordings;
|
storeRecordings.checked = json.storeRecordings;
|
||||||
@ -488,6 +502,7 @@ disabled
|
|||||||
languageSelect = document.getElementById("language-select");
|
languageSelect = document.getElementById("language-select");
|
||||||
inputDevices = document.getElementById("input-devices");
|
inputDevices = document.getElementById("input-devices");
|
||||||
storeRecordings = document.getElementById("store-recordings");
|
storeRecordings = document.getElementById("store-recordings");
|
||||||
|
taskSelect = document.getElementById("task-select");
|
||||||
|
|
||||||
enumerateDevices();
|
enumerateDevices();
|
||||||
connect(socket);
|
connect(socket);
|
||||||
|
@ -49,11 +49,12 @@ wss.on('connection', (ws, req) => {
|
|||||||
console.log('No session data found for session id ' + webSocket.sessionId);
|
console.log('No session data found for session id ' + webSocket.sessionId);
|
||||||
}
|
}
|
||||||
let language = sessionData?.language || 'en';
|
let language = sessionData?.language || 'en';
|
||||||
|
let task = sessionData?.task || 'transcribe';
|
||||||
//show the size of the audio data as 0.000 MB
|
//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);
|
console.log('(queue ' + queueCounter + ') Received ' + (data.length / 1024 / 1024).toFixed(3) + ' MB audio from client. Crrent language: ' + language);
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
var formData = {
|
var formData = {
|
||||||
task: 'transcribe',
|
task: task,
|
||||||
language: sessionData.language,
|
language: sessionData.language,
|
||||||
output: 'json',
|
output: 'json',
|
||||||
audio_file: {
|
audio_file: {
|
||||||
@ -157,6 +158,10 @@ app.post('/settings', (req, res) => {
|
|||||||
sessionData.storeRecordings = body.storeRecordings;
|
sessionData.storeRecordings = body.storeRecordings;
|
||||||
console.log(`Session ${sid}: storeRecordings set to ${sessionData.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' });
|
res.send('OK', 200, { 'Content-Type': 'text/plain' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user