2011-06-14 144 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