我可以使用AVSpeechSynthesizer API进行文本到语音,在模拟器上讲日语,但它并不能在真正的设备上工作,产生日志,如下所示。有什么建议吗?
AXSpeechAssetDownloader\ error \ ASAssetQuery错误获取结果(用于com.apple.MobileAsset.MacinTalkVoiceAssets)错误Domain=ASError Code=21“无法复制资产信息”UserInfo={NSDescription=Unable到复制资产信息}
这是来源
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:speechStr];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ja-JP"];
[self.synthesizer speakUtterance:utterance]发布于 2016-06-30 11:46:09
首先,您必须检查是否启用了setting>accessibilty>speech>speech选择,只需在ios 9或greater.then中启用它,这是我的工作代码,如果它对您有帮助的话。
NSMutableString *mutableString = [self.utteranceString mutableCopy];
// CFStringTransform((__bridge CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, NO);
//CFStringTransform((__bridge CFMutableStringRef)mutableString, NULL, kCFStringTransformStripCombiningMarks, NO);
AVAudioSessionCategoryPlayback error:&setCategoryErr];
AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:self.utteranceString];
[synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:@"ja-JP"];
self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
self.speechSynthesizer.delegate = self;
// set your class to conform to the AVSpeechSynthesizerDelegate protocol
float speechSpeed = 0.5f;
[synUtt setRate:speechSpeed];
UInt32 doChangeDefaultRoute = 1;
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
[synUtt setVolume:1.0];
[self.speechSynthesizer speakUtterance:synUtt];https://stackoverflow.com/questions/33184132
复制相似问题