📜 ⬆️ ⬇️

Speech synthesizer in iOS7

IOS7 has a speech synthesizer built in, now get your application to speak the question of a couple lines of code.

AVSpeechSynthesizer class is responsible for speech synthesis . It is enough to pass text wrapped to AVSpeechUtterance class to it and the text will be read by the smartphone.

Voice depends on locale, including Russian supported. Speech sounds clear and pleasant.
')
var speechSynthesizer = new AVSpeechSynthesizer (); var speechUtterance = new AVSpeechUtterance ("Shall we play a game?"); speechSynthesizer.SpeakUtterance (speechUtterance); 


default voice with english locale
This is a link! Click with Ctrl or Cmd, you can not embed sound on Habré. In our blog posted a post with Sound Cloud widgets.

Speech is configured using the parameters of the class AVSpeechUtterance:


In my opinion, the default text sounds too fast. Set the maximum speed reduced by 3.6 times
 var speechSynthesizer = new AVSpeechSynthesizer (); var speechUtterance = new AVSpeechUtterance ("Shall we play a game?") { Rate = AVSpeechUtterance.MaximumSpeechRate / (float)3.6 }; speechSynthesizer.SpeakUtterance (speechUtterance); 

default voice max speed / 3.6

The speech synthesizer in iOS7 only supports female voice in 35 locales, among them Russian.
 ['ar-SA', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-IE', 'en-US', 'en-ZA', 'es-ES', 'es-MX', 'fi-FI', 'fr-CA', 'fr-FR', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', 'nl-BE', 'nl-NL', 'no-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sv-SE', 'th-TH', 'tr-TR', 'zh-CN', 'zh-HK', 'zh-TW'] 


 var speechSynthesizer = new AVSpeechSynthesizer (); var speechUtterance = new AVSpeechUtterance ("  ?") { Rate = AVSpeechUtterance.MaximumSpeechRate / (float)4, Voice = AVSpeechSynthesisVoice.FromLanguage ("ru-RU") }; speechSynthesizer.SpeakUtterance (speechUtterance); 

Russian, quarter max speed

Russian voice sounds great, try to play a long text.
Lermontov "Sail", Russian, quarter max speed

There are flaws, but in my opinion it is wonderful. Suitable for combat use.

Variants of applications with speech synthesis:


In Android , speech synthesis appeared in 2009 (1.6+), it sounds disgusting .


Subscribe to our blog . Every Thursday, useful articles about mobile development, marketing and business of mobile studio.

Source: https://habr.com/ru/post/198808/


All Articles