2011-06-14 143 views
5

实现与AppleScript的say "words"类似的东西有多困难?
也就是说,它只是一个二进制链接和导入,或者像libxml实现一样混乱吗?iPhone上的文本到语音转换

编辑:我的答案解决了这个问题。


  • Acapela
    • 严重骗人货
    • €250的SDK,而这还不包括更新
  • 伊沃娜
    • 网站不存在在iOS版本其他
    • 否牛逼感兴趣
  • VoiceText
    • 网站是丑陋和难以导航
    • 不感兴趣
  • OpenEars
    • 开源,一个明确的加
    • 到目前为止,最好的离线TTS我听说过。
  • 弗莱特
    • 超级低质量,不值得使用
    • 吮吸原样。 OE改进了很多。
  • 谷歌TTS
    • 好,但需要网络连接
    • 不理想
+0

检查此: https://bitbucket.org/sfoster/iphone-tts/ – Satish 2011-06-14 16:49:51

+0

检查我的答案http://stackoverflow.com/questions/12839671/text-to-speech-libraries-for-iphone/12839821 #12839821 – 2013-04-12 02:33:12

回答

1

从这所以有些问题(忘了是哪一个,不能再找到它),我有一个链接OpenEars
对于这么轻的东西,我不能抱怨。

插入时有点混乱,但documentation全部用于Xcode 4.禁止用户错误,它不会爆炸项目。有几个警告(其中一些看起来像是应该在运行时导致崩溃),但目前看起来不错。

编辑:最新的OE版本更容易安装。绝对推荐。

+2

OpenEars质量实际上与过滤相同。这意味着它的质量很差 – vodkhang 2011-11-09 19:41:44

+0

OpenEars的质量明显好于Flite,而且它的功能更强大。 – Thromordyn 2012-04-02 18:38:16

7

我看着这个不幸的选项要么非常昂贵的质量好坏:

与此相关的,这里是你如何使用谷歌的在线TTS(从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];  
} 

从苹果画外音框架是私有的,只能用于辅助功能使用上。至少如果你希望你的申请获得批准。但是,如果你想在你决定使用什么系统来使用它,那就是:

// 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

看起来不错。我会看看我能做什么。 (无论如何,请使用Google选项。) – Thromordyn 2011-06-15 01:32:32

+0

我似乎无法获得在线TTS的工作... – Thromordyn 2011-06-15 13:12:59

+0

谎言!我添加了MP3播放器代码,它应该工作。 – Jano 2011-06-15 13:38:19