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 localeThis 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:
- Rate - the playback speed, the more the faster from MinimumSpeechRate to MaximumSpeechRate.
- Voice - an object of class AVSpeechSynthesisVoice depends only on locale, the voice is one female.
- Volume - voice volume, from 0 to 1.0, default 1.0 (loudest)
- PitchMultiplier - voice pitch from 0.5 to 2.0, default 1.0.
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.6The 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 speedRussian voice sounds great, try to play a long text.
Lermontov "Sail", Russian, quarter max speedThere are flaws, but in my opinion it is wonderful. Suitable for combat use.
Variants of applications with speech synthesis:
- Applications for the blind, such as indoor navigation with iBeacon .
- Audio guides to the museum / city, synthesized speech is not as pleasant as people read, but the text will be clear.
- Applications for auto, scooter and bike. For example, you can read the latest tweets. Convenient when riding a bike to work.
- Tourist applications. For example, “thank you”, “please”, “hello” in popular languages.
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.