AVSpeechSynthesizer代表没有调用iOS 11
这是我的文本到语音转换代码。在iOS 11下,一切正常。但在iOS中,11个委托方法没有被调用AVSpeechSynthesizer代表没有调用iOS 11,ios,iphone,ios11,avspeechsynthesizer,Ios,Iphone,Ios11,Avspeechsynthesizer,这是我的文本到语音转换代码。在iOS 11下,一切正常。但在iOS中,11个委托方法没有被调用 AVSpeechSynthesizerDelegate设置准确。(因为它在iOS 11下工作) 点击按钮 AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init]; synthesizer.delegate = self; AVSpeechUtterance *utterance = [AVSpeechUtterance
AVSpeechSynthesizerDelegate
设置准确。(因为它在iOS 11下工作)
点击按钮
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
synthesizer.delegate = self;
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:stringToSpeech];
[utterance setRate:AVSpeechUtteranceDefaultSpeechRate];
[utterance setPitchMultiplier:1];
[utterance setVolume:1];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
[synthesizer speakUtterance:utterance];
这些是我已经实现的委托方法
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance {
NSLog(@"finished");
}
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance{
NSLog(@"Started");
}
有人面对过这个问题吗?
任何帮助都将不胜感激
我正在iOS 11.0.3上进行测试,使用Xcode 9.0,您的
合成器对象必须是一个属性才能工作:)
或者将您的avspeechsynthesis
实例设置为synthesis
,如下所示:
@property (strong, nonatomic) AVSpeechSynthesizer *synthesizer;
或者像readwrite这样
@property (readwrite, strong, nonatomic) AVSpeechSynthesizer *synthesizer;
让我知道这是否有效。@MZubairShamshad在上述两种类型中,哪种类型的属性使用解决了您的问题?@AanchalChaurasia@property(强、非原子)avspeechsynthesis*synthesis代码>为您工作过吗me@MZubairShamshad谢谢你的回复。我会投票确定,一旦我得到确认,它的工作良好。为我工作。谢谢