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

  • Home
  • SEARCH
  • 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 3846526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:24:41+00:00 2026-05-19T16:24:41+00:00

I searched through existing threads but couldn’t find any solutions.. here’s my question. I’m

  • 0

I searched through existing threads but couldn’t find any solutions.. here’s my question.

I’m using google’s text to speech to download mp3 files. The function works great for english characters.. and languages using english characters. Unfortunately, for Russian (or any non-latin characters) my script generates the correct url, but doesnt download any content (but it does download a 0kb file.. empty)

file_put_contents($filepath,file_get_contents("http://translate.google.com/translate_tts?tl=".$lang."&q=".rawurlencode($transtext).""));

So a sample french word (phone) http://translate.google.com/translate_tts?tl=fr&q=t%C3%A9l%C3%A9phone

When I go to the page manually, and download the file, everything works.. but not with the file_get_contents.

  • 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-19T16:24:41+00:00Added an answer on May 19, 2026 at 4:24 pm

    You should add the input encoding parameter (ie=UTF-8) and encode the translation text accordingly.

    For example, the following PHP snippet can be used to download the audio file for “téléphone” (in French) from the Google TTS service. Notice it does not work properly without the input encoding parameter.

    $transtext = "t\xe9l\xe9phone"; // ISO-8859-1 string to be encoded in UTF-8
    $base_url = 'http://translate.google.com/translate_tts?';
    $qs = http_build_query(array(
        'tl' => 'fr',
        'ie' => 'UTF-8',
        'q' => utf8_encode($transtext)
    ));
    $contents = file_get_contents($base_url . $qs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi searched through the questions here, but couldn't find anything. I'm new at writing
I've googled and searched through Matlab Central, but cannot find any way to open
although I searched through existing threads for my problem I havent found a solution
i searched through Stack overflow but fail to find a solution in regards to
I've searched through the other expected Class Name error questions on here, but they
I've asked Google and searched through the NServiceBus website and forums, but I can't
I've searched around, and saw some tips, but still couldn't find the solution to
Searched through net, could't find a way to read/write file metadata using C or
Searched through and didn't find any good resources/tutorials, if someone could please explain how
So I have searched through a few question here regarding the AlertDialog, and I'm

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.