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 4042650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:01:56+00:00 2026-05-20T13:01:56+00:00

I’m using Google Translate to convert a piece of text to speech with this

  • 0

I’m using Google Translate to convert a piece of text to speech with this url:
http://translate.google.com/translate_tts?tl=%s&q=%s
Where the parameter tl contains the language code of the language of the text you want converted to speech, and q contains the text you want converted.

Normal words (without special characters) return the correct audio file.
So in my application this is what I do (no is the language code for Norwegian):

url = "http://translate.google.com/translate_tts?tl=%s&q=%s" % ('no', urllib.quote('kjendis'))
#url = http://translate.google.com/translate_tts?tl=no&q=kjendis
self.response.headers["Content-Type"] = "audio/mpeg"
self.response.out.write(urlfetch.fetch(url).content)

This returns the correct sound.
I’m using plain webapp btw.

But when I have a word with a special character in it (vår) something isn’t right.
The url generated is http://translate.google.com/translate_tts?tl=no&q=v%C3%A5r. (the å is correctly transformed to percent encoding)
When opening that url with my browser I get the correct sound, but when using urlfetch.fetch to read the same url the sound returned is not correct.

What is going wrong here? I can only assume that fetch is altering the url somehow.

  • 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-20T13:01:56+00:00Added an answer on May 20, 2026 at 1:01 pm

    Apparently the problem is not an App Engine problem, but it has to do with the way the Google Translate url handles different user agents.

    An example:

    #!/usr/bin/env python
    #coding=utf-8
    
    import urllib
    
    class MyOpener(urllib.FancyURLopener):
        version = "App/1.7" #doesn't work
        version = "Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)2011-03-10 15:38:34" #works
    
    def textToSpeech(text, languageCode='en'):
        url = "http://translate.google.com/translate_tts?tl=%s&q=%s" % (languageCode, urllib.quote(text))
        myopener = MyOpener()
        return myopener.open(url, 'rb').read()
    
    open('urllib.mp3', 'wb').write(textToSpeech('vår', 'no'))
    

    When using the Firefox user agent string for MyOpener everything works as expected, but when using the other user string the sound returned is not correct.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.