Skip to content
This repository was archived by the owner on Jul 14, 2021. It is now read-only.

[FIX] TTS API#125

Open
diogomqbm wants to merge 2 commits intoscalableminds:masterfrom
diogomqbm:tts-fix
Open

[FIX] TTS API#125
diogomqbm wants to merge 2 commits intoscalableminds:masterfrom
diogomqbm:tts-fix

Conversation

@diogomqbm
Copy link
Copy Markdown

Related Issue: #122

This changes the expected behavior of TTS. Now it will only trigger TTS when the passed voiceLang matches the supported languages by SpeechSynthesis API.

Comment thread src/Message.js
toSpeak.voice = voices.find(voice => voice.lang === voiceLang);
synth.speak(toSpeak);
const desiredVoice = voices.find(voice => voice.lang === voiceLang);
if (desiredVoice) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the desired voice can not be found? Nothing will be spoken at all, right? Can we fall back to English? Or at least throw an error message in the console?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can fall back to English. However, I have observed a warning I'm getting regarding the usage of speechSynthesis.speak(). It seems that it isn't allowed to use this method without user activation since M71, around December 2018.
Check: https://www.chromestatus.com/feature/5687444770914304

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I suggest we should add a little button per message that when clicked triggers the speechSynthesis.speak() function, this will be less annoying for users who don't want to be listening to every message and will be equally accessible for those who need this feature to work.
What is your opinion on this approach? @hotzenklotz

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly about that. I guess having to trigger speech output by pressing a button next every message is a bit tedious/besides the point. What I mean is, that it might feel less like an "audio" chat and rather "just a like yet another feature".

I would leave it as is. The browser warning should only be shown when TTS was enabled by the devs, right? I think this is a design decision that chatbot designers should deal with themselves. Do they want speech or not? If yes, perhaps the first bot message should explain to enable it in Chrome...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. So, I'm going to change to English as the default language as we talked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants