2017-05-30 63 views
1

我打電話給法語的文本到語音。iOS 10.3文本到語音在模擬器上工作,但不在設備上

這可按預期在: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]; 
} 
+0

請檢查您的設備是否爲靜音模式。還要按音量調高設備音量。 –

回答

1

原來的聲音S ynthesizer由鈴聲音量控制,而不是媒體音量。振鈴器在測試儀的設備上靜音。

0

您的.h文件 添加AVSpeechSynthesizer* synthesizer = NULL; ,你是好go--我測試..它的工作原理超細:)

去你的.h文件並添加

AVSpeechSynthesizer* synthesizer = NULL; 

,並在.M一個

-(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]; 
} 
相關問題