简体   繁体   中英

iOS text-to-speech using AVSpeechSynthesizer

I am using AVSpeechSynthesizer for text-to-speech in my iOS app.

The speech synthesizer is working fine on all devices except from iPad 2 (model A1395) running iOS 9.0.2. I am using Xcode 7.0.1.

The problem is, on playing a text say “hope” the letter “p” is either really quiet or not playing that the user can hear only “ho”. If the text is “hopes” then it plays correct.

Any idea on how to solve this?

There is some parameters (voice, rate...) that needs to be set and I've already encountered some bug with iOS 9 with some code that was working directly with previous iOS. Here is my code for initializing AVSpeechSynthesizer :

NSString*str = @"hope";
AVSpeechSynthesizer*    synth = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance
                                        speechUtteranceWithString: str];
utterance.rate = AVSpeechUtteranceDefaultSpeechRate;
NSString*lang = @"en-US"
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:lang];
[synth speakUtterance:utterance];

Can you try this code on your iPad 2 for example ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM