Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Ios 我试图获取AVSpeechSynthesizer音频文件,但它给了我一个错误,;线程1:异常:“;avspeechouter不得排队两次”;_Ios_Objective C - Fatal编程技术网

Ios 我试图获取AVSpeechSynthesizer音频文件,但它给了我一个错误,;线程1:异常:“;avspeechouter不得排队两次”;

Ios 我试图获取AVSpeechSynthesizer音频文件,但它给了我一个错误,;线程1:异常:“;avspeechouter不得排队两次”;,ios,objective-c,Ios,Objective C,这是我的密码: _avSpeaker = [[AVSpeechSynthesizer alloc] init]; speeechutterance = [[AVSpeechUtterance alloc] initWithString:textViewStr]; AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"]; speeechutterance.voice

这是我的密码:

_avSpeaker = [[AVSpeechSynthesizer alloc] init];
speeechutterance = [[AVSpeechUtterance alloc] initWithString:textViewStr];
AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
speeechutterance.voice = voice;
 [_avSpeaker speakUtterance:speeechutterance];
__block AVAudioFile *output = nil;
if (@available(iOS 13.0, *)) {
         [_avSpeaker writeUtterance:speeechutterance
                   toBufferCallback:^(AVAudioBuffer * _Nonnull buffer) {
             AVAudioPCMBuffer *pcmBuffer = (AVAudioPCMBuffer*)buffer;
             if (!pcmBuffer) {
                 NSLog(@"Error");
                 return;
             }
             if (pcmBuffer.frameLength != 0) {
                 //append buffer to file
                 if (output == nil) {
                     output = [[AVAudioFile alloc] initForWriting:[NSURL                                fileURLWithPath:alawFilePathName]
                                                         settings:pcmBuffer.format.settings
                                                     commonFormat:AVAudioPCMFormatInt16
                                                      interleaved:NO error:nil];
                 }
                 [output writeFromBuffer:pcmBuffer error:nil];
             }
        }];
} else {

}
。。。。。。。。。。
如何解决这个问题以及如何使用函数“WriteTerance”请有人能帮我吗?

我也遇到过同样的问题。