4

我想加载多种语言以使用 IVONA SDK 和 SSML for iPhone。在Xcode/objective-C中没有使用文档,只给出了 SDK 本身和几个 C/java 示例。

如何使用适用于 iOS 的 IVONA SDK 加载多种语言的文本讲话?

编辑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 SDK 在 iOS 上的一个流媒体中加载多种语言?

4

1 回答 1

1

也许添加到数组 allVoices 的对象不符合预期的 initWithVoices 数组:...

于 2012-06-26T10:23:33.823 回答