Speech Synthesizer in iOS7

    A speech synthesizer was built in iOS7, now make your application speak a couple of lines of code.

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

    Voice depends on the locale, including Russian supported. The 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 the link! Click with Ctrl or Cmd, you can not embed sound on the hub I posted a post with Sound Cloud widgets on our blog .

    Speech is configured using the parameters of the AVSpeechUtterance class:
    • Rate - playing speed, the more the faster from MinimumSpeechRate to MaximumSpeechRate.
    • Voice - an object of class AVSpeechSynthesisVoice depends only on the locale, the voice is one female.
    • Volume - voice volume, from 0 to 1.0, default 1.0 (the 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.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, a quarter of the maximum speed

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

    There are flaws, but in my opinion it’s fine. Suitable for combat use.

    Speech synthesis application options:
    • Applications for the blind, such as indoor navigation in conjunction with iBeacon .
    • Museum / city audio guides, synthesized speech is not as pleasant as people read, but the text will be understandable.
    • Applications for cars, scooters and bicycles. For example, you can read the latest tweets. It is convenient when you ride a bicycle to work.
    • Travel apps. For example, “thank you”, “please”, “hello” in popular languages.

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

    Subscribe to our habr-blog . Every Thursday, useful articles on mobile development, marketing and the mobile studio business.

    Also popular now: