The implementation of TTS technology in iOS is voice broadcast and iostts.

Source: Internet
Author: User

The implementation of TTS technology in iOS is voice broadcast and iostts.

Text-To-Speech technology, also known as TTS, is short for Text To Speech. This technology is used when iOS wants To implement functions such as voicebooks.

I. Notes for using TTS in iOS:

Ii. code example: Play voice

// Voice broadcast AVSpeechUtterance * utterance = [AVSpeechUtterance speechUtteranceWithString: @ "Moonlight in front of the bed, suspected to be frost on the ground. "]; Utterance. pitchMultiplier = 0.8; // Chinese pronunciation: audio * voice = [AVSpeechSynthesisVoice voiceWithLanguage: @ "zh-CN"]; // english pronunciation // AVSpeechSynthesisVoice * voice = [audio voiceWithLanguage: @ "en-GB"]; utterance. voice = voice; NSLog (@ "% @", [descrispeechvoices]); AVSpeechSynthesizer * synth = [[AVSpeechSynthesizer alloc] init]; [synth speakUtterance: utterance];

3. AVSpeechSynthesizer Introduction

 

This class is like a talking person. He can "speak", "pause", and "continue". He can judge whether he is talking. there are the following methods or attributes:

 

  • Speaker: speakUtterance
  • Control: continueSpeaking, pauseSpeakingAtBoundary, paused, speaking, stopSpeakingAtBoundary)
  • Delegate: delegate
 

4. AVSpeechBoundary Introduction

 

This is an enumeration. When you pause or stop talking, you can use this enumeration to mark the stop. There are two types:

  • AVSpeechBoundaryImmediate: stop now
  • AVSpeechBoundaryWord

V. AVSpeechSynthesizerDelegate

Synthesizer delegation provides Response interfaces for some events.

  • DidCancelSpeechUtterance: the message has been canceled.
  • DidContinueSpeechUtterance: continue talking
  • DidFinishSpeechUtterance: Completed
  • DidPauseSpeechUtterance: paused
  • DidStartSpeechUtterance: started
  • WillSpeakRangeOfSpeechString: to say something

Vi. AVSpeechSynthesisVoice Introduction

 

AVSpeechSynthesisVoice defines a series of sounds, mainly in different languages and regions.

 

  • VoiceWithLanguage: gets a sound based on the language.
  • SpeechVoices: Voice supported by the current device
  • CurrentLanguageCode: gets the language string of the current sound, such as "ZH-cn"
  • Language: Obtain the current language.

VII. AVSpeechUtterance

 

The main attributes and methods are as follows:

 

  • PitchMultiplier: Pitch
  • PostUtteranceDelay: The pause time after reading a paragraph
  • PreUtteranceDelay: The pause before reading a paragraph
  • Rate: read speed. The system provides three speeds: AVSpeechUtteranceMinimumSpeechRate, AVSpeechUtteranceMaximumSpeechRate, avspeechutterancedefaspeechrate
  • SpeechString: the string to be read
  • Voice: the voice used. It is an AVSpeechSynthesisVoice object.
  • Volume: volume

8. UML Relationship Diagram

The relationships between these classes are as follows:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.