dirty fix to disable speech for firefox users

This commit is contained in:
andzejsp 2023-04-14 21:56:56 +03:00
parent 8b6bfacc5d
commit 121ae6c9b6
4 changed files with 464 additions and 452 deletions

View File

@ -1,3 +1,5 @@
// Dirty fix for disabling speech synth for firefox browsers :()
if (!userAgent.match(/firefox|fxios/i)) {
isStarted = false;
isSpeaking = false;
const SpeechRecognition = window.SpeechRecognition || webkitSpeechRecognition;
@ -199,3 +201,4 @@ function add_audio_in_ui() {
}
});
}
}

View File

@ -1,3 +1,6 @@
// Dirty fix for disabling speech synth for firefox browsers :()
const userAgent = navigator.userAgent;
function addMessage(sender, message, id, rank = 0, can_edit = false) {
const chatWindow = document.getElementById('chat-window');
const chatForm = document.getElementById('chat-form');
@ -24,8 +27,7 @@ function addMessage(sender, message, id, rank=0, can_edit=false) {
messageElement.appendChild(senderElement);
messageElement.appendChild(messageTextElement);
if(can_edit)
{
if (can_edit) {
// Create buttons container
const buttonsContainer = document.createElement('div');
// Add the 'flex' class to the div
@ -99,8 +101,7 @@ function addMessage(sender, message, id, rank=0, can_edit=false) {
text = textDecoder.decode(result.value);
// The server will first send a json containing information about the message just sent
if(entry_counter==0)
{
if (entry_counter == 0) {
// We parse it and
infos = JSON.parse(text)
console.log(infos)
@ -320,7 +321,10 @@ function addMessage(sender, message, id, rank=0, can_edit=false) {
chatWindow.appendChild(messageElement);
chatWindow.appendChild(hiddenElement);
// Dirty fix for disabling speech synth for firefox browsers :()
if (!userAgent.match(/firefox|fxios/i)) {
attachAudio_modules(messageTextElement);
}
// scroll to bottom of chat window
chatWindow.scrollTop = chatWindow.scrollHeight;

View File

@ -32,9 +32,14 @@ fetch('/main')
load_discussion();
update_main();
db_export();
// Dirty fix for disabling speech synth for firefox browsers :()
if (!userAgent.match(/firefox|fxios/i)) {
prepre_audio();
add_audio_in_ui();
populateVoicesList();
}
populate_models()
})