import urllib.request, urllib.error, urllib.parse
url = 'http://translate.google.com/translate_tts?tl=en&q=text'
request = urllib.request.Request(url)
request.add_header('User-agent', 'Mozilla/5.0')
opener = urllib.request.build_opener()
f = open('data.mp3', 'wb')
f.write(opener.open(request).read())
f.close()
How to pass a string + web url and receive the response using python