简体   繁体   中英

iOS 10.3 text to speech works on simulator but not on device

I'm calling text to speech for the French language.

This works as expected on: iOS 9.3 simulator, iOS 9.3 device ( iPad 3rd gen ), iOS 10.3 simulator. Does not work (silently) on iOS 10.3 device ( iPhone 6s ).

Default French voice is installed and works according to device settings.

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];
}

Turns out the speech synthesizer is controlled by the ringer volume, not the media volume. The ringer was muted on the tester's device.

on your .h file add AVSpeechSynthesizer* synthesizer = NULL; and you're good to go-- i have tested it.. it works super fine :)

go to your .h file and add

AVSpeechSynthesizer* synthesizer = NULL;

and on the .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];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM