AVSpeechSynthesizer funciona en el simulador pero no en el dispositivo
He estado tratando de aprender AVSpeechSynthesis. El código funciona bien en el simulador de iOS (tanto en iPad como en iOS), pero la función de texto a voz no funciona en absoluto en mi iPad. Aquí está mi código.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Load Model
self.string = @"Hello World";
self.utterance = [[AVSpeechUtterance alloc] initWithString:self.string];
self.utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
self.utterance.rate = (float) 0.25;
//Load UI
self.textLabel.text = self.string;
}
- (IBAction)startSpeaking:(id)sender {
self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
if ([self.speechSynthesizer isSpeaking]) {
[self.speechSynthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryWord];
} else {
[self.speechSynthesizer speakUtterance:self.utterance];
}
}
ACTUALIZACIÓN: AVSpeechSyntheSizer funciona pero no hay sonido Entonces tengo un UILabel con el mismo texto que AVSpeechUtterance en la interfaz de usuario. Implementé AVSpeechSynthesizerDelegate de modo que cuando presiono startSpeaking: la etiqueta de texto convierte la palabra actual en roja. Así que sé que AVSpeechSynthesizer debe estar funcionando porque está haciendo llamadas de delegado, pero no puedo entender por qué no puedo escucharlo. El volumen está alto y ninguna otra aplicación está reproduciendo audio.