ios objective-c avfoundation avaudiosession

AVSpeechSynthesizer error AudioSession



objective-c avfoundation (4)

Estoy jugando con AVSpeechSynthesizer y siempre obtengo estos errores:

ERROR: >aqsrv> 65: Exception caught in (null) - error -66634 ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty (''disa'') failed with error: ''?ytp''

Mi código es:

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; [synthesizer setDelegate:self]; speechSpeed = AVSpeechUtteranceMinimumSpeechRate; AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:[[self text] text]]; [synUtt setRate:speechSpeed]; [synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:languageCode]]; [synthesizer speakUtterance:synUtt];

¿Alguien sabe como arreglar estos errores?


Conseguí el código de arriba para trabajar en el simulador con ajustes mínimos.

  1. El bit [[self text] text] de su código puede ser incorrecto (que es de donde vendría el error Exception caught in (null) ). El siguiente código funcionó para mí.

    AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; [synthesizer setDelegate:self]; // set your class to conform to the AVSpeechSynthesizerDelegate protocol float speechSpeed = AVSpeechUtteranceMinimumSpeechRate; AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:@"hello I am testing"]; [synUtt setRate:speechSpeed]; [synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]]]; [synthesizer speakUtterance:synUtt];

    Y cuando digo "funcionó", quiero decir que escuché la voz pronunciando mi oración de prueba en mi simulador.

    Todavía vi esta advertencia:

    2013-09-21 11: 37: 56.454 Speech [5550: 3a03] 11: 37: 56.454 ERROR: AVAudioSessionUtilities.h: 88: GetProperty_DefaultToZero: AudioSessionGetProperty (''disa'') falló con error: ''? Ytp''

  2. Xcode 5 parece tener un tiempo lento intentando trabajar con el tradicional #import <AVFoundation/AVFoundation.h> con este código de Síntesis de Voz, las cosas parecían acelerarse un poco al usar el nuevo @import AVFoundation; .


No puedo creerlo, pero en realidad encontré la solución para esto: si no tiene auriculares conectados o alguna fuente de salida de audio, AVPlayer no funcionará y se imprimirá:

ERROR: >aqsrv> 65: Exception caught in (null) - error -66634


Obtengo exactamente el mismo registro de errores en el simulador, pero no tengo ningún problema con el código, ya sea en el simulador o en el dispositivo iPhone 5 como se indica en otro lugar. La diferencia podría ser que no estoy usando ninguno de esos 6 AVSpeechSythesizerDelegates opcionales y, en consecuencia, no lo he incluido en mi protocolo de clase. Por lo tanto, para ayudar a rastrear su error, puede intentarlo sin. Aquí está mi código de prueba, que lógicamente es el mismo que el suyo, menos el delegado y cualquier asignación de almacenamiento AVSpeechUtterance:

-(void)tts:(NSString*)text { #define MY_SPEECH_RATE 0.1666 #define MY_SPEECH_MPX 1.55 AVSpeechSynthesizer *textToSpeech = [[AVSpeechSynthesizer new]autorelease]; NSString *language = [AVSpeechSynthesisVoice currentLanguageCode]; if (language==nil) language = @"en-us"; AVSpeechUtterance *speak = [AVSpeechUtterance speechUtteranceWithString:text]; [speak setRate:MY_SPEECH_RATE]; [speak setPitchMultiplier:MY_SPEECH_MPX]; [speak setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:language]]; [textToSpeech speakUtterance:speak]; }

Como puede ver, no estoy usando ARC pero no creo que eso haga la diferencia. (También publicado en el Foro de Desarrolladores)


También veo estos errores (usando ARC pero no muli threaded) pero solo en el simulador, no en un dispositivo real.

Estoy trabajando en el supuesto de que son una limitación del simulador y se pueden ignorar de forma segura; todo lo demás parece estar funcionando bien.

Ali