Susper has been given a voice search feature through which it provides the user a better experience of search. We introduced to enhance the speech recognition by adding Speech Synthesis or Text-To-Speech feature. The speech synthesis feature should only work when a voice search is attempted.
The idea was to create speech synthesis similar to market leader. Here is the link to YouTube video showing the demo of the feature: Video link
In the video, it will show demo :
- If a manual search is used then the feature should not work.
- If voice search is used then the feature should work.
For implementing this feature, we used Speech Synthesis API which is provided with Google Chrome browser 33 and above versions.
window.speechSynthesis.speak(‘Hello world!’); can be used to check whether the browser supports this feature or not.
First, we created an interface:
Then under @Injectable we created a class for the SpeechSynthesisService.
The above code will implement the feature Text-To-Speech.
The source code for the implementation can be found here: https://github.com/fossasia/susper.com/blob/master/src/app/speech-synthesis.service.ts
We call speech synthesis only when voice search mode is activated. Here we used redux to check whether the mode is ‘speech’ or not. When the mode is ‘speech’ then it should utter the description inside the infobox.
We did the following changes in infobox.component.ts:
And we added a conditional statement to check whether mode is ‘speech’ or not.
The source code for the implementation can be found here: https://github.com/fossasia/susper.com/commit/3624d504c4687c227016b4fea229c680ad80a613