Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5928353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:16:56+00:00 2026-05-22T14:16:56+00:00

I am developing a text-to-speech iphone app that support multi-languages. Here is my request

  • 0

I am developing a text-to-speech iphone app that support multi-languages.

Here is my request URL

requestUrlStr = @"http://www.translate.google.com/translate_tts?tl=en&q=hello";

for english the above url has no problem

but for Chinese

requestUrlStr = @"http://www.translate.google.com/translate_tts?tl=zh-TW&q=你好";

I know the above url will give ‘Bad URL’, so I used follow method to encode the string into UTF-8

requestUrlStr = [requestUrlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

It will become

http://www.translate.google.com/translate_tts?tl=zh-CN&q=%E4%BD%A0%E5%A5%BD

Then the Google TTS cannot recognize this Chinese text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:16:57+00:00Added an answer on May 22, 2026 at 2:16 pm

    You have to pretend to be a User-Agent other than the default (appName, etc) in your NSURLRequest. Try this (I use Greek language) …

    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];
    

    UPDATE 2017

    Since our favorite companies enjoy to update and deprecate things, here is the above example as it should be now…

    NSString* text = @"καλημέρα";
    NSString* lang = @"el";
    
    NSString* sUrl = [NSString stringWithFormat:@"https://translate.google.com/translate_tts?q=%@&tl=%@&client=tw-ob", text, lang];
    sUrl = [sUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
    NSURL* url = [NSURL URLWithString:sUrl];
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"GET"];
    [request setValue:@"Mozilla/5.0" forHTTPHeaderField:@"User-Agent"];
    
    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
                                                          delegate:nil
                                                     delegateQueue:[NSOperationQueue mainQueue]];
    
    [[session dataTaskWithRequest:request
                completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                    [data writeToFile:@"/var/tmp/tts.mp3" atomically:YES];
                }
      ] resume];
    

    The ...delegate:nil delegateQueue:[NSOperationQueue mainQueue] can be omitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing: http://www.buscatiendas.com.mx I've seen people entering text for queries with lots of typos.
I'm developing an app that has a feature to search a text ( searchString
I am developing an app that needs to send text messages, so I have
alt text http://img63.imageshack.us/img63/5726/screenshot20100125at124.png I keep getting multiple error windows for an app i'm developing
I'm developing a PHP-MySQL app that enables registered users to enter text comments. Problem
I'm developing an iPhone app. One of the screens contains several text fields, and
I am currently developing a web service that is configured to receive SMS text
I am developing an iPhone application and I use HTML to display formatted text.
I m developing app where there is list and above edit text,the moment i
I am developing an app in which User can tweet some predefined text. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.