AVSpeechSynthesizer funciona no simulador, mas não no dispositivo
Eu tenho tentado aprender AVSpeechSynthesis. O código funciona bem no iOS Simulator (no iPad e no iOS), mas o recurso de conversão de texto em fala não funciona no meu iPad. Aqui está o meu 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];
}
}
ATUALIZAÇÃO: AVSpeechSyntheSizer está funcionando, mas não há som Então, eu tenho um UILabel com o mesmo texto que o AVSpeechUtterance na interface do usuário. Eu implementei o AVSpeechSynthesizerDelegate para que, quando eu pressione startSpeaking: o rótulo do texto fique vermelho. Então, eu sei que o AVSpeechSynthesizer deve estar funcionando porque está fazendo chamadas de delegado, mas não consigo entender por que não consigo ouvi-lo. O volume está alto e nenhum outro aplicativo está reproduzindo áudio.