framework for translation
This commit is contained in:
parent
771e265b66
commit
ad05f4dcd4
|
@ -619,6 +619,7 @@ function startSpeech() {
|
||||||
var SpeechRecognition =
|
var SpeechRecognition =
|
||||||
window.SpeechRecognition || window.webkitSpeechRecognition;
|
window.SpeechRecognition || window.webkitSpeechRecognition;
|
||||||
VideoChat.recognition = new SpeechRecognition();
|
VideoChat.recognition = new SpeechRecognition();
|
||||||
|
// VideoChat.recognition.lang = "en";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendingCaptions = false;
|
sendingCaptions = false;
|
||||||
logIt(e);
|
logIt(e);
|
||||||
|
@ -684,6 +685,39 @@ function recieveCaptions(captions) {
|
||||||
}
|
}
|
||||||
// End Live caption
|
// End Live caption
|
||||||
|
|
||||||
|
// Translation
|
||||||
|
// function translate(text) {
|
||||||
|
// let fromLang = "en";
|
||||||
|
// let toLang = "zh";
|
||||||
|
// // let text = "hello how are you?";
|
||||||
|
// const API_KEY = "APIKEYHERE";
|
||||||
|
// let gurl = `https://translation.googleapis.com/language/translate/v2?key=${API_KEY}`;
|
||||||
|
// gurl += "&q=" + encodeURI(text);
|
||||||
|
// gurl += `&source=${fromLang}`;
|
||||||
|
// gurl += `&target=${toLang}`;
|
||||||
|
// fetch(gurl, {
|
||||||
|
// method: "GET",
|
||||||
|
// headers: {
|
||||||
|
// "Content-Type": "application/json",
|
||||||
|
// Accept: "application/json",
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => res.json())
|
||||||
|
// .then((response) => {
|
||||||
|
// // console.log("response from google: ", response);
|
||||||
|
// // return response["data"]["translations"][0]["translatedText"];
|
||||||
|
// logIt(response);
|
||||||
|
// var translatedText =
|
||||||
|
// response["data"]["translations"][0]["translatedText"];
|
||||||
|
// console.log(translatedText);
|
||||||
|
// dataChanel.send("cap:" + translatedText);
|
||||||
|
// })
|
||||||
|
// .catch((error) => {
|
||||||
|
// console.log("There was an error with the translation request: ", error);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// End Translation
|
||||||
|
|
||||||
// Text Chat
|
// Text Chat
|
||||||
// Add text message to chat screen on page
|
// Add text message to chat screen on page
|
||||||
function addMessageToScreen(msg) {
|
function addMessageToScreen(msg) {
|
||||||
|
|
Loading…
Reference in New Issue