2011-06-14 15 views
5

¿Qué tan difícil sería implementar algo similar al say "words" de AppleScript?
Es decir, ¿es solo un enlace binario y una importación, o algo tan desordenado como una implementación libxml?Text-to-speech en iPhone

Editar: Mi respuesta lo resuelve.


  • Acapela
    • una estafa grave
    • € 250 para el SDK, y eso es sin incluir actualizaciones
  • Ivona
    • sitio no presenta una versión de IOS con los otros
    • No t interesa
  • VoiceText
    • sitio es feo y difícil de navegar
    • No hay interés
  • OpenEars
    • código abierto, una ventaja definitiva
    • Con mucho, la mejor línea TTS he oído hablar de.
  • Flite
    • Súper baja calidad, no vale la pena utilizar
    • Sucks tal cual. OE lo mejoró mucho.
  • Google TTS
    • Bueno, pero requiere una conexión de red
    • No es ideal
+0

cheque esto: https://bitbucket.org/sfoster/iphone-tts/ – Satish

+0

comprobar mi respuesta http://stackoverflow.com/questions/12839671/text-to-speech-libraries-for-iphone/12839821 # 12839821 –

Respuesta

1

De alguna pregunta sobre SO (no recuerdo cuál, no se puede encontrar de nuevo), llegué a un enlace OpenEars.
Para algo tan ligero, no me puedo quejar.

Es un poco confuso de enchufar, pero el documentation es todo para Xcode 4. Exceptuando el error del usuario, no explotará un proyecto. Hay algunas advertencias (algunas de las cuales parecen causar un bloqueo en el tiempo de ejecución), pero se ve bien hasta ahora.

Edit: La versión más nueva de OE es MUCHO más fácil de instalar. Definitivamente recomendado.

+2

OpenEars la calidad es lo mismo que flite en realidad. Esto significa que tiene una calidad deficiente – vodkhang

+0

OpenEars tiene una calidad significativamente mejor que Flite solo, y es mucho más potente. – Thromordyn

7

He mirado en esto y por desgracia, las opciones son o muy caro o mala calidad :

Relacionado con esto, aquí es cómo se puede utilizar TTS en línea de Google (código tomado de iPhone SDK - Google TTS and encoding):

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"file.mp3"]; 

NSString *text = @"You are one chromosome away from being a potato."; 
NSString *urlString = [NSString stringWithFormat:@"http://www.translate.google.com/translate_tts?tl=en&q=%@",text]; 
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; 
[request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" forHTTPHeaderField:@"User-Agent"]; 
NSURLResponse* response = nil; 
NSError* error = nil; 
NSData* data = [NSURLConnection sendSynchronousRequest:request 
            returningResponse:&response 
               error:&error]; 
[data writeToFile:path atomically:YES]; 

AVAudioPlayer *player; 
NSError  *err; 
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) 
{  
    player = [[AVAudioPlayer alloc] initWithContentsOfURL: 
       [NSURL fileURLWithPath:path] error:&err]; 
    player.volume = 0.4f; 
    [player prepareToPlay]; 
    [player setNumberOfLoops:0]; 
    [player play];  
} 

El marco voz en off de Apple es privado, sólo puede utilizar en la accesibilidad.Al menos si quieres que tu solicitud sea aprobada. Pero si usted quiere usarlo mientras se decide sobre qué sistema utilizar, aquí está:

// Not App Store safe. Only available in real devices. 
// See http://arstechnica.com/apple/2010/02/iphone-voiceservices-looking-under-the-hood/ 

#define RTLD_LAZY 0x1 
#define RTLD_NOW 0x2 
#define RTLD_LOCAL 0x4 
#define RTLD_GLOBAL 0x8 

NSObject *voiceSynthesizer; 
void *voiceServices; 

-(void) say:(NSString*)text { 
    if (!voiceSynthesizer) 
    { 
     NSString *vsLocation = @"/System/Library/PrivateFrameworks/VoiceServices.framework/VoiceServices"; 
     voiceServices = dlopen(vsLocation.UTF8String, RTLD_LAZY); 
     voiceSynthesizer = [NSClassFromString(@"VSSpeechSynthesizer") new]; 
    } 
    [voiceSynthesizer performSelector:@selector(startSpeakingString:) withObject:text]; 
} 
+0

Se ve bien. Veré lo que puedo hacer. (Con la opción de Google, de todos modos.) – Thromordyn

+0

Parece que no puedo hacer funcionar el TTS en línea ... – Thromordyn

+0

¡Mentiras! Agregué el código del reproductor de mp3, debería funcionar. – Jano