Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AVSpeechSynthesizer代表没有调用iOS 11_Ios_Iphone_Ios11_Avspeechsynthesizer - Fatal编程技术网

AVSpeechSynthesizer代表没有调用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

这是我的文本到语音转换代码。在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,您的
合成器
对象必须是一个属性才能工作:)

或者将您的
avspeechsynthesis
实例设置为
synthesis
,如下所示:

@property (strong, nonatomic) AVSpeechSynthesizer *synthesizer;
或者像readwrite这样

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

让我知道这是否有效。

@MZubairShamshad在上述两种类型中,哪种类型的属性使用解决了您的问题?@AanchalChaurasia
@property(强、非原子)avspeechsynthesis*synthesis为您工作过吗me@MZubairShamshad谢谢你的回复。我会投票确定,一旦我得到确认,它的工作良好。为我工作。谢谢