Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print googleSpeechURL: ordinal not in range(128) #1

Open
IL2 opened this issue Nov 8, 2013 · 1 comment
Open

print googleSpeechURL: ordinal not in range(128) #1

IL2 opened this issue Nov 8, 2013 · 1 comment

Comments

@IL2
Copy link

IL2 commented Nov 8, 2013

I've ran into error
$ python PiTranslate.py -o en -d ru -t "hello"
Origin: en
Destination: ru
Text: hello
Traceback (most recent call last):
File "PiTranslate.py", line 53, in
speakDestinationText(translation)
File "PiTranslate.py", line 29, in speakDestinationText
print googleSpeechURL
UnicodeEncodeError: 'ascii' codec can't encode characters in position 50-55: ordinal not in range(128)

If you change
print googleSpeechURL
to
print googleSpeechURL.encode("utf-8")
this line goes fine, but next line fails:
Origin: en
Destination: ru
Text: hello
http://translate.google.com/translate_tts?tl=ru&q=Привет
Traceback (most recent call last):
File "PiTranslate.py", line 53, in
speakDestinationText(translation)
File "PiTranslate.py", line 30, in speakDestinationText
subprocess.call(["mplayer",googleSpeechURL], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(_popenargs, *_kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
TypeError: execv() arg 2 must contain only strings

Changing
subprocess.call(["mplayer",googleSpeechURL], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
to
subprocess.call(["mplayer",googleSpeechURL.encode("utf-8")], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
throws no error, but no translated speech played. I guess subprocess should be called with parameters encoded in the other way.

Sometimes it throws
$ python PiTranslate.py -o en -d ru -t "hello"
Origin: en
Destination: ru
Text: hello
http://translate.google.com/translate_tts?tl=ru&q=TranslateApiException: Cannot find an active Azure Market Place Translator Subscription associated with the request credentials. : ID=XXXX.V2_Json.Translate.XXXXXXXX

@jiserra
Copy link
Contributor

jiserra commented Feb 16, 2014

I've made a pull request that fixes the encoding problem.

The Azure problem is fixed by going to https://datamarket.azure.com/dataset/1899a118-d202-492c-aa16-ba21c33c06cb and "buying" the first package for $0. That solved all my Azure problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants