0
我正在設計一個需要文本到語音的應用程序。我正在使用發佈的here將文本轉換爲語音的庫。我必須從Json url中檢索文本,並將這些值傳遞給文本到語音。我能夠檢索JSON數據並將其轉換爲文本到語音使用下面的代碼ObjectatIndex 0 ...從json數據連續轉換文本到語音
SBJSON *json = [[SBJSON alloc]init];
fliteEngine = [[FliteTTS alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.sampleurl.txt"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *jsonstring = [[NSString alloc]initWithData:response encoding:NSUTF8StringEncoding];
NSArray *asanasList = [json objectWithString:jsonstring error:nil];
NSArray *asanas =[asanasList objectForKey:@"yogagurubackpain"];
for(NSDictionary *test in asanas)
{
UrlValues *myasanas = [[UrlValues alloc]init];
myasanas.asanatitle = [test objectForKey:@"asanatitle"];
myasanas.asanatranscript = [test objectForKey:@"asanatranscript"];
myasanas.asanapicture = [test objectForKey:@"asanapicture"];
[data.yoga addObject:myasanas];
[myasanas release];
}
UrlValues *asana=[[data yoga]objectAtIndex:0];
self.AsanaName.text = [asana asanatitle];
self.AsanaTranscript.text = [asana asanatranscript];
NSString *imageUrl = [asana asanapicture];
NSString* mapUrl = [imageUrl stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapUrl]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
self.AsanaImage.image = image;
NSString *speak = self.AsanaTranscript.text;
[fliteEngine setVoice:@"cmu_us_rms"];
[fliteEngine speakText:speak];
[fliteEngine setPitch:100.0 variance:11.0 speed:0.4];
[imageData release];
[image release];
[jsonstring release];
[json release];
現在我的問題是我怎麼能去到下一個對象播放結束後自動第一個。該過程必須爲所有對象繼續。相應的圖像等必須在第一個文本到語音完成後在頁面上加載... Plz幫助我...
可以üplz幫我一個樣品因爲我是一個新手到iPhone開發.... Plzzzz – 2010-06-23 05:18:47