AVSpeechSynthesizer *tts1;
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"i love you"];
//设置语言类别(不能被识别,返回值为nil)
AVSpeechSynthesisVoice *voiceType = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.voice = voiceType;
//设置语速快慢
utterance.rate *= 0.5;
//语音合成器会生成音频
[tts1 speakUtterance:utterance];
这个OC代码已经没有报错了,但是模拟器里不能发音 。难道 模拟器不支持,需要真机测试吗 ?
能翻译成swift语言吗?