Each audio segment (from the browser) sent to the server should trigger a notification mechanism, a receipt, notifiying users the length of the audio clip saved onto the server, and how many segments have been saved on the server. This helps ensure the WebSocket stream transferred audio to the server properly. We may also compute the total length of the audio clip, and send this data to the browser as well.
This may provide a coding outline for the task sending converted audio from the server, back to the browser.
The following code from initializer.js will need to be adjusted:
...
// Getting messages from server through WebSocket, either a result or an error
websocket.onmessage = function(e) {
result = JSON.parse(e.data);
if (typeof(result.score) !== 'undefined')
document.getElementById("result").innerHTML = "Score: " + result.score + " Speed: " + result.speed + " Words: " + result.words;
if (typeof(result.error) !== 'undefined')
document.getElementById("error").innerHTML = result.error;
else
document.getElementById("error").innerHTML = "";
}
}
...
Each audio segment (from the browser) sent to the server should trigger a notification mechanism, a receipt, notifiying users the length of the audio clip saved onto the server, and how many segments have been saved on the server. This helps ensure the WebSocket stream transferred audio to the server properly. We may also compute the total length of the audio clip, and send this data to the browser as well.
This may provide a coding outline for the task sending converted audio from the server, back to the browser.
The following code from initializer.js will need to be adjusted: