2012-06-15 51 views
4

我想加載多種語言以使用帶SSML for iPhone的IVONA SDK。 在Xcode/objective-C中沒有使用的文檔,只給出了SDK本身以及幾個C/java示例。如何將多種語言加載到IVONA SDK - 文本到語音

如何加載多種語言的文本,以便與IVONA SDK for iOS進行對話?

編輯1:見下文

負荷我的代碼的聲音在第一:

- (NSInteger) loadVoice: (NSString*) vox { 

if(voice != nil) { 
    XLog(@"(voice != nil)"); 
    [voice unload]; 
    voice = nil; 
} 


NSString *pathIvona = [[NSString alloc] initWithFormat:@"%@", vox]; 

self.paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
self.documentsDirectory = [self.paths objectAtIndex:0]; 
self.path = [self.documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", pathIvona]]; 



voice = [[IvonaVoice alloc] init:instance withLibrary:self.path withVox:self.path]; 

[pathIvona release]; 

if (voice == nil) { 
    XLog(@"Cannot load voice"); 
    [self setTtsError: @"Cannot load voice"]; 
    return 0; 
} 
[voice setParam:@"vol" withInteger: 99]; 
return 1; 
} 

試圖多種語言加載到一個流光與(流光仍然是零,它不變更)

NSArray *allVoices = [self getAvaliableVoxes]; 

/** 
* Here the streamer is still nil, 
* i cant find the mistake here. 
* 
*/ 
IvonaStreamer *streamer = [[IvonaStreamer alloc] initWithVoices:allVoices 
withText:[NSString stringWithContentsOfFile:self.path 
encoding:NSUTF8StringEncoding error:&error] atSpeed:[NSNumber numberWithFloat:-1]]; 

方法getAvailableVoices:

- (NSArray*)getAvaliableVoxes { 
XLog(@"-----------------------------------entered"); 


self.paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
self.documentsDirectory = [self.paths objectAtIndex:0]; 


NSFileManager *manager = [NSFileManager defaultManager]; 
NSArray *fileList = [manager contentsOfDirectoryAtPath:[self.paths objectAtIndex:0] error:nil]; 
for (NSString *s in fileList){ 
    //XLog(@"s: %@", s); 
} 


NSMutableArray *pathsIvona = [[NSMutableArray alloc] init]; 
NSEnumerator *e = [fileList objectEnumerator]; 
NSString *vox; 
while (vox = [e nextObject]) { 

if([[vox lastPathComponent] hasPrefix:@"vox_"]) { 
     XLog(@"vox: %@", vox); 
     [pathsIvona addObject: [vox lastPathComponent]]; 
     XLog(@"pathsIvona: %@", pathsIvona); 
    } 

} 

XLog(@"pathsIvona: %@", pathsIvona); 

return [pathsIvona autorelease]; 
} 

你怎麼可以加載與IVONA iOS版SDK中的一條拖多國語言?

+0

因爲這裏沒有人可以幫你,你可以寫信給伊沃娜開發商,我猜。 [Twitter](https://twitter.com/#!/ivonatts) [Facebook](http://www.facebook.com/ivonatts) –

+1

您是否有來自XLog語句輸出的日誌?也許添加到數組allVoices的對象不符合預期的initWithVoices數組:......您有沒有看過錯誤的機會? –

+0

@john做你的評論作爲答案,然後我可以標記它。這是問題的正確位置,我已經向數組添加了錯誤的對象。謝謝。 – brush51

回答

1

也許對象添加到數組allvoices公司不符合initWithVoices的預期陣列:...