如何将多种语言加载到IVONA SDK的文本转语音功能中

4

我希望能够使用IVONA SDK和SSML在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;
}  

尝试将多种语言加载到一个流媒体器中(流媒体器仍为nil,没有改变)
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];
}

如何在iOS上使用IVONA SDK在一个播放器中加载多种语言?


既然这里没有人能帮助你,我猜你可以写信给Ivona的开发者们。 Twitter Facebook - Pavel Oganesyan
1
你有 XLog 语句输出的日志吗?也许添加到数组 allVoices 的对象不符合预期的 initWithVoices 数组... 你有看过错误吗? - john.k.doe
@john 请将您的评论作为答案,这样我就可以标记它了。问题确实出在那里,我向数组中添加了错误的对象。谢谢。 - brush51
1个回答

1

可能添加到数组 allVoices 中的对象不符合预期的 initWithVoices 数组……


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接