-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2918: Add tts on web #2985
base: main
Are you sure you want to change the base?
2918: Add tts on web #2985
Conversation
…d unnecessary mock
…le from ttsContext
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🚀
Tested this on chrome and firefox.
Firefox voice is really crappy, but chrome is really nice 🚀 Maybe we add hint, that some browsers better support this feature? Maybe @hauf-toni can share some input, how to handle this best from a UI perspective.
Found a few bug:
issue 1:
- Open this page: http://localhost:9000/augsburg/de/willkommen/willkommen-in-augsburg-2
- Click "read aloud"
- Click "play"
- Click on "Weiter"
Result: The reader starts reading out the beginning of the current sentance, when clicking "weiter" for the first time. When clicking "weiter" a second time, it correctly jumps to the next sentance
Expected result: When clicking "weiter" for the first time, it should directly jump to the next sentance.
issue 2:
When opening this page: http://localhost:9000/augsburg/de/willkommen
the "read aloud" button is displayed, but does nothing when clicked.
Expected: Should either not be displayed or does something when clicked
issue 3:
Open this page: http://localhost:9000/augsburg/de/behoerden-beratung/behoerden/auslaenderbehoerde
Click "next" to jump to the last sentance
in this line "Weitere Informationen finden Sie unter [hier]" the reader switches to the "start"-mode, but there is still this whole contact blog that is read
issue 4:
When clicking pause I see the initial view of the tts-player, with the first word of the page in the heading. I think this is confusing, as clicking play does not continue reading from the beginning. I would expect that the player just changes the pause button to showing a play button.
what i get when i click pause
what i expected
issue 5:
on firefox when the tts reaches the end of the text, the player does not reset to start as it is for other browsers.
build-configs/integreat/index.ts
Outdated
@@ -39,6 +39,7 @@ const commonIntegreatBuildConfig: CommonBuildConfigType = { | |||
fixedCity: null, | |||
cityNotCooperatingTemplate, | |||
chat: true, | |||
tts: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this "false". Do we only want this feature on beta for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@steffenkleinle what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so. Until iOS is ready as well I think we only want this on beta :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will turn this to true 👍️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, badly phrased from my side. This should stay false until ios is ready.
"accessibility": "Barrierefreiheit", | ||
"readAloud": "Vorlesefunktion", | ||
"previous": "Zurück", | ||
"next": "Weiter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 We already have translations for previous and next in the translations file, but in other sections/categories. I think it is fine to keep it, but we may think about this in the future, if it is worth the effort to restructure things to lower translation costs.
Can you please mention which browser you used for each issue? |
I mostly used Chrome, sometimes I double checked with Firefox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good already, thank you! Tested in Firefox on OS X
A couple of small things:
I would prefer that the overlay doesn't change size based on whether or not the text is being read. I hear that will be a separate issue :)
There were a lot of very random CSS numbers, please already apply the multiples-of-four rule of thumb that Toni mentioned when introducing the new style guide.
Also, I'm getting an unfortunate word separation in German, maybe increase the width of the side bar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 I don't love this test because it really tests the implementation of the component as opposed to testing roughly how a user would use the component. On the other hand, it's really hard to test third-party components, and then ones playing sounds. Not sure what to do here
} | ||
|
||
return [] | ||
}, [model, languageCode]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Hmmm, I don't like this hack to break up the content, and I see that you didn't do it in the native one. Maybe there is a better solution here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm at native it stops as normal at the end of sentences but at web I noticed lists and paragraphs without full stop will continue reading the next sentence as it one.
Other option is maybe changes from CMS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool, thank you so much! This is such a complicated feature, and you made it through that!
Tested in Firefox
Short description
Adding text-to-speech functionality for web.
Proposed changes
TtsPlayer.tsx
will receive content and title fromuseTtsPlayer.ts
hook then it will process content as following:<p>
or<li>
tag if there is non at the end.sentencex
to support most languages.TtsPlayer.tsx
using EasySpeech library for web speech api .. why I used it instead of directly using the native api read here: https://github.com/leaonline/easy-speech/blob/master/FAQ.md#why-does-this-library-exists-if-i-can-use-tts-natively-in-the-browserWeb Speech API has some limitation on devices like Android I can't pause so I implemented a way to increment
currentSentencesIndex
at each sentence so pausing will be depend on sentence index . Another issue with Firefox about triggering onEnd function at any.cancel()
method unlike chromium based browsers.This is different from tts-native: voices needs to be installed from OS so a modal will show up
TtsHelpModal
to guide users for each platform. Note: by default for windows for example you have what the keyboard layout have of languages also it may need a restart to see the newly installed language.Modified Modal.tsx to accept new props: icon and styling just for (backgroundColor, borderRadius)
Side effects
Testing
Observations
I tested this PR on linux and I got different result at each browser:
Chrome: works as expected + nice voices.
Firefox: I can't pause (linux) +
using opensource voice library frombetter sounded voices can be downloaded from pied (Note: you need to restart the browser after selecting a voice).mbrola mb-en1
sounds roboticBrave: (linux) not working at all because there is no build in speech to text like google chrome does.
Windows on the other hand.. most browsers can run good as long you download the voices from the OS it self.
I didn't test it on mac OS...
Resolved issues
Fixes: #2918