Text to Speech [TTS] for Chat


#22

You can use this updated script, which will read the sender’s name:

speakSystem.js (1.1 KB)


#23

Thank you a lot!


#24

sorry for more tiny request but u could provide the template for Brazilian language?


#25

@mausmani Thank you so much for the thorough documentation. I tested this speaksystem in Chrome and it works well. When I try it using Microsoft Edge, it doesn’t speak. Now, the script that I initially posted in this thread does work with Microsoft Edge. Do you know what is the difference that makes the script by @peckingbird work in Edge and the one you wrote not work? To be clear, I love your script as it addresses many issues I had with the old script. I am trying to understand why it will not speak using Microsoft Edge. I feel that browser uses less memory and therefore is better when I stream. Thank you!


#26

You will need to get the compatible voices for Edge browser. I just modified these 2 lines in alertHandler.js to the compatible voice in Edge browser:

speech.voice = voices.filter(function(voice) { return voice.name == 'Microsoft David Mobile - English (United States)'; })[0];
speech.lang = 'en-US';

This should work.


#27

Hi,

As per the website I had linked:

speech.voice = voices.filter(function(voice) { return voice.name == 'Google português do Brasil'; })[0];
speech.lang = 'pt-BR';

#28

Awesome! Thank you. It works great. I actually like Zira’s voice better so I changed it to:

speech.voice = voices.filter(function(voice) { return voice.name == 'Microsoft Zira Mobile - English (United States)'; })[0];
speech.lang = 'en-US';

I love it!


#29

Glad it worked for you!


#30

Updated the script with the cost for the command and a command to set the cost :slight_smile: i also renamed the command to tts instead of say

speakSystem.js (1.9 KB)


#31

Will one of you legends be working to get this functioning with 2.3.9 as currently, I can’t seem to get it to work :frowning: I’d offer to help, but I’m not sufficiently knowledgable sadly.


#32

working fine for me as it is :slight_smile:


#33

I upgraded tonight and my tts still works fine. I made sure to follow the instructions above and cross-referenced my previous alertHandler.js file where I had modified it as instructed here. You do also open the alert window in your browser, right?


#34

Just an update to allow the rate of the speed the voice!

if (imageFile.substring(0,7) == "<voice>"){//Check if voice alert.
    var textToSpeak = imageFile.substring(7);//Remove "<voice>"
    //Pass text to window object.
    var speech = new SpeechSynthesisUtterance(textToSpeak);
    var voices = window.speechSynthesis.getVoices();
    speech.default = false;
    speech.voice = voices.filter(function(voice) { return voice.name == 'Google UK English Male'; })[0];
    speech.lang = 'en-GB'; //Also added as for some reason android devices used for testing loaded spanish language 
    speech.volume = 0.70;
    speech.rate = 0.70;
    window.speechSynthesis.speak(speech);
    return;
}

#35

I think the latest Windows 10 update broke tts when using Microsoft Edge. Is there an update to the code that would enable tts again? I like using Edge because it seems to not take up many resources while streaming and gaming.


#36

i just looked into it and im kind of lost cus the function below works with javascript just fine which is almost the same as what we already have

function speak(textToSpeech) {
    var synUtterance = new SpeechSynthesisUtterance(textToSpeech);
    synUtterance.voice = voices.filter(function(voice) { return voice.name == 'Google UK English Male'; })[0];
    synUtterance.lang = langSelect.value;
    synUtterance.volume = parseFloat(volumeRange.value);
    synUtterance.rate = parseFloat(rateRange.value);
    synUtterance.pitch = parseFloat(pitchRange.value);

    window.speechSynthesis.speak(synUtterance);
}

this link is where i did a test on edge and there way worked fine


#37

Yeah, that is weird. I went to the link using Edge and it says it is supported and does speak text within that page. When I launch the PB control panel and open alerts and use my !say command, nothing happens. So the code is the same as what speech synthesis api is and it doesn’t work?


Audio Hooks Question
#38

did you ever get this to work yet?


#39

Thanks for asking. No, unfortunately not with the Edge browser. It works as expected using Chrome, so I’m sticking with that until a solution comes around. I’m not sure what Microsoft changed to cause the script to not work in Edge.


#40

ill have a look when i redo the code for the tts over then next few weeks


#41

That’d be great! Thanks