AVSpeechSynthesizer代表不在iOS 11中调用

AVSpeechSynthesizer代表不在iOS 11中调用,第1张

概述这是我的文字转语音代码. iOS 11以下的一切工作正常.但是在iOS 11中没有调用委托方法. AVSpeechSynthesizerDelegate准确设置. (因为它在iOS 11下工作) 按下按钮 AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];synthesizer.delegate = self 这是我的文字转语音代码. iOS 11以下的一切工作正常.但是在iOS 11中没有调用委托方法.

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进行测试

解决方法 你的合成器对象必须是一个属性,以便工作:).

要么你的AVSpeechSynthesizer实例,这是合成器,如下所示:

@property (strong,nonatomic) AVSpeechSynthesizer *synthesizer;

或者像reaDWrite一样.

@property (reaDWrite,strong,nonatomic) AVSpeechSynthesizer *synthesizer;

让我知道这个是否奏效.

总结

以上是内存溢出为你收集整理的AVSpeechSynthesizer代表不在iOS 11中调用全部内容,希望文章能够帮你解决AVSpeechSynthesizer代表不在iOS 11中调用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1008469.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存