IOS-AVSpeechSynthesizer -- iOS7 speech synthesizer

Source: Internet
Author: User

The speech synthesizer technology is launched by iOS7, which can realize the non-network speech function and support multiple languages. define a member variable to record the voice synthesizer AVSpeechSynthesizer # import <AVFoundation/AVFoundation. h> 1 @ interfaceViewController () 2 3 {4 5 // synthesizer 6 7 AVSpeechSynthesizer * _ synthesizer; 8 9 10 11 // instantiate the speaking language, speaking Chinese and English 12 13 AVSpeechSynthesisVoice * _ voice; 14 15} 2. define the voice object AVSpeechSynthesisVoice. Specify the language of the speech zh_CN Chinese en-US English 1-(void) viewDidLoad 2 {3 [super viewDidLoad]; 4 5 // instantiate the language of the speech to speak Chinese. 6 _ voice = [AVSpeechSynthesisVoice voiceWithLanguage: @ "en-US"]; 7 8 // to recite, a speech synthesizer 9 _ synthesizer = [[AVSpeechSynthesizer alloc] init]; 10} 3. instantiate the voice object AVSpeechUtterance, specify the content to read 1 // read the content in the text box 2 // instantiate the voice object, and read the content 3 AVSpeechUtterance * utterance = [AVSpeechUtterance speechUtteranceWithString: _ textView. text]; 4. specify the speech and recitation speed. The Chinese recitation speed is 0.1. The English recitation speed is 0.3. The English recitation speed is also 1 utterance. voice = _ voice; 2 3 utterance. rate = 0.3; 5. start 1 [_ synthesizer speakUtterance: utterance]; Note: when creating an application, if the recitation content is limited, professional dubbing audio is required. If the recitation content is unlimited, this method is the best choice!

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.