// ARRAY DI PAROLE NORMALE, POI PYTHON -> split, for loop, POS e <span con classe POS in html
// The Myth of the Natural Language %%
// Speech2Design!!
// Welcome to the core-code of the Speech-to-text
// The tool we are gonna use is the "Web Speech API".
// The tool we are gonna use is the "Web Speech API".
// What is an API?
// An API is a set of defined rules that explain how computers or applications communicate with one another.
// An API is a set of defined rules that explain how computers or applications communicate with one another.
// APIs sit between an application and the web server, acting as an intermediary layer that processes data transfer between systems.
// GLOBAL VARIABLES
letinterimTranscripts="";// Variable for interim results, the Speech-to-text try different worlds before to give us the most correct one.
letallTheInterim="";// Variable to store *all* the interim results
letfinalTranscripts="";// Variable for the... final transcripts
letinterimTranscripts="";// Variable for interim results, the Speech-to-text try different worlds before to give us the most correct one.
letallTheInterim="";// Variable to store *all* the interim results
letfinalTranscripts="";// Variable for the final transcripts
// To define bridges to the html file:
letspeech=document.getElementById("result");// where to print the final result of the recognition
letprocess=document.getElementById("process");// and here the process, print the current sentence with interim results
// To define bridges to the html file:
letspeech=document.getElementById("result");// where to print the final result of the recognition
letprocess=document.getElementById("process");// and here the process, print the current sentence with interim results
// TEXT STORAGE
lettextStorage=localStorage.getItem("speech");// This define where to save the results.
speech.innerHTML=textStorage;// LocalStorage is a type of web storage that allows you to access a local Storage object and store the data in the browser with no expiration date.
lettextStorage=localStorage.getItem("speech");// This define where to save the results.
speech.innerHTML=textStorage;// LocalStorage is a type of web storage that allows you to access a local Storage object and store the data in the browser with no expiration date.
finalTranscripts=textStorage;
// RESET STORAGE
letresetStorage=document.getElementById("reset");// This will just reset, through a button, all the results got by that moment.
letresetStorage=document.getElementById("reset");// This will just reset, through a button, all the results got by that moment.
}else{// There are also shown the interim results and according to their "confidence" (the percentage of how much the word is correct) the color of each word could change
finalTranscripts+=transcript+"\n";
}else{
// There are also shown the interim results and according to their "confidence" (the percentage of how much the word is correct) the color of each word could change
interimTranscripts+=transcript;
allTheInterim+=`<span style="opacity: ${
event.results[i][0].confidence+0.3
}">${interimTranscripts}</span>`;
allTheInterim+=`<span style="opacity:
${event.results[i][0].confidence+0.3}
">${interimTranscripts}</span>`;
}
}
process.innerHTML=allTheInterim;
@ -118,14 +122,16 @@ function startConverting() {
speech.innerHTML=final;
textStorage=final;
console.log(textStorage);
localStorage.setItem("speech",final);// Here is where is stored the recognized text in the Local Storage