iOS 10.3 文本转语音适用于模拟器但不适用于设备
iOS 10.3 text to speech works on simulator but not on device
我正在为法语调用文字转语音。
这在以下设备上按预期工作:iOS 9.3
模拟器、iOS 9.3
设备 (iPad 3rd gen
)、iOS 10.3
模拟器。
无法在 iOS 10.3
设备 (iPhone 6s
) 上(静默地)工作。
默认法语语音已安装并根据设备设置工作。
static AVSpeechSynthesizer* synthesizer = NULL;
//...
+(void)readText:(NSString*)text
{
if(synthesizer == NULL)
synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
[synthesizer speakUtterance:utterance];
}
在你的 .h 文件上
添加 AVSpeechSynthesizer* synthesizer = NULL;
你可以开始了——我已经测试过了..它工作得非常好:)
转到您的 .h 文件并添加
AVSpeechSynthesizer* synthesizer = NULL;
和.m one
-(void)readText:(NSString*)text
{
if(synthesizer == NULL)
synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
[synthesizer speakUtterance:utterance];
}
原来语音合成器是由铃声音量控制的,而不是媒体音量。测试者设备上的铃声已静音。
我正在为法语调用文字转语音。
这在以下设备上按预期工作:iOS 9.3
模拟器、iOS 9.3
设备 (iPad 3rd gen
)、iOS 10.3
模拟器。
无法在 iOS 10.3
设备 (iPhone 6s
) 上(静默地)工作。
默认法语语音已安装并根据设备设置工作。
static AVSpeechSynthesizer* synthesizer = NULL;
//...
+(void)readText:(NSString*)text
{
if(synthesizer == NULL)
synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
[synthesizer speakUtterance:utterance];
}
在你的 .h 文件上
添加 AVSpeechSynthesizer* synthesizer = NULL;
你可以开始了——我已经测试过了..它工作得非常好:)
转到您的 .h 文件并添加
AVSpeechSynthesizer* synthesizer = NULL;
和.m one
-(void)readText:(NSString*)text
{
if(synthesizer == NULL)
synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];
[synthesizer speakUtterance:utterance];
}
原来语音合成器是由铃声音量控制的,而不是媒体音量。测试者设备上的铃声已静音。