[mirotalksfu] - add missing recognition lang
هذا الالتزام موجود في:
@@ -1,8 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let isWebkitSpeechRecognitionSupported = false;
|
let isWebkitSpeechRecognitionSupported = false;
|
||||||
let isVoiceCommandsEnabled = true;
|
|
||||||
let recognition;
|
let recognition;
|
||||||
|
let isVoiceCommandsEnabled = true;
|
||||||
|
let browserLanguage = navigator.language || navigator.userLanguage;
|
||||||
|
let isVoiceCommandSupported = browserLanguage.includes('en-');
|
||||||
|
|
||||||
const commands = {
|
const commands = {
|
||||||
shareRoom: 'room',
|
shareRoom: 'room',
|
||||||
@@ -48,6 +50,7 @@ if ('webkitSpeechRecognition' in window) {
|
|||||||
|
|
||||||
recognition.maxAlternatives = 1;
|
recognition.maxAlternatives = 1;
|
||||||
recognition.continuous = true;
|
recognition.continuous = true;
|
||||||
|
recognition.lang = browserLanguage;
|
||||||
|
|
||||||
console.log('Speech recognition', recognition);
|
console.log('Speech recognition', recognition);
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ if ('webkitSpeechRecognition' in window) {
|
|||||||
chatMessage.value = transcript;
|
chatMessage.value = transcript;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVoiceCommandsEnabled) {
|
if (isVoiceCommandsEnabled && isVoiceCommandSupported) {
|
||||||
execVoiceCommands(transcript);
|
execVoiceCommands(transcript);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -84,10 +87,12 @@ if ('webkitSpeechRecognition' in window) {
|
|||||||
console.info('Browser supports webkitSpeechRecognition');
|
console.info('Browser supports webkitSpeechRecognition');
|
||||||
} else {
|
} else {
|
||||||
console.warn('This browser not supports webkitSpeechRecognition');
|
console.warn('This browser not supports webkitSpeechRecognition');
|
||||||
|
hide(chatSpeechStartButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
function startSpeech(action) {
|
function startSpeech(action) {
|
||||||
if (action) {
|
if (action) {
|
||||||
|
recognition.lang = browserLanguage;
|
||||||
recognition.start();
|
recognition.start();
|
||||||
} else {
|
} else {
|
||||||
recognition.stop();
|
recognition.stop();
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم