Friday, April 20, 2012

Converting iPhone code to Android

I put up a problem on Android and didn't get any answer but I've found a similar problem on the iPhone platform with the answer but I don't know how to translate this into Java code. Please can anyone who is well versed in both languages give this a try.



NSString* userAgent = @"Mozilla/5.0";

NSURL *url = [NSURL URLWithString:[@"http://www.translate.google.com/translate_tts?tl=el&q=????????"
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];

[request setValue:userAgent forHTTPHeaderField:@"User-Agent"];

NSURLResponse* response = nil;
NSError* error = nil;
NSData* data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];


[data writeToFile:@"/var/tmp/tts.mp3" atomically:YES];




No comments:

Post a Comment