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

[Text-to-Speech] failed with combine of special characters, e.g Spanish + ";" #602

Closed
1 task
josepmao opened this issue Mar 2, 2017 · 6 comments
Closed
1 task
Assignees

Comments

@josepmao
Copy link

josepmao commented Mar 2, 2017

  • Steps to reproduce
    With following code:
String text = "La guerra es de vital importancia para el Estado; es el dominio de la vida o de la muerte, el camino hacia la supervivencia o la pérdida del Imperio: es forzoso manejarla bien.";
InputStream stream =service.synthesize(**text**, Voice.ES_ENRIQUE, AudioFormat.WAV).execute();

Get error:

SEVERE: GET https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?text=La%20guerra%20es%20de%20vital%20importancia%20para%20el%20Estado;%20es%20el%20dominio%20de%20la%20vida%20o%20de%20la%20muerte,%20el%20camino%20hacia%20la%20supervivencia%20o%20la%20p%C3%A9rdida%20del%20Imperio:%20es%20forzoso%20manejarla%20bien.&voice=es-ES_EnriqueVoice&accept=audio/wav, status: 400, error: 'ascii' codec can't decode byte 0xc3 in position 82: ordinal not in range(128)
com.ibm.watson.developer_cloud.service.exception.BadRequestException: 'ascii' codec can't decode byte 0xc3 in position 82: ordinal not in range(128)
	at com.ibm.watson.developer_cloud.service.WatsonService.processServiceCall(WatsonService.java:416)
	at com.ibm.watson.developer_cloud.service.WatsonService$1.execute(WatsonService.java:180)
	at Jmaotest.testTTS(Jmaotest.java:67)
	at Jmaotest.main(Jmaotest.java:26)

Change second line code to:

String output = URLEncoder.encode(text, "UTF-8").replace("+", "%20");
InputStream stream =service.synthesize(output, Voice.ES_ENRIQUE, AudioFormat.WAV).execute();

It works as expected.

Because in Java-SDK, we use HTTP GET to send request, thus need URL-encoded, while it seems not working fine while in Spanish.

Suggest either improve URL-encoder part, or change to use POST method.

@jeffpk62
Copy link
Contributor

jeffpk62 commented Mar 2, 2017

@germanattanasio moving to a POST seems like a good first attempt at a fix. I can look at this tomorrow.

@germanattanasio
Copy link
Contributor

great

@jeffpk62 jeffpk62 removed their assignment Mar 6, 2017
@jeffpk62
Copy link
Contributor

jeffpk62 commented Mar 6, 2017

@germanattanasio I took a look, and converting to a POST requires changing a number of tests accordingly. Using URL encoding may be better, but then we break tests for other reasons and I don't think we want to double URL encode the string. Also, the okhttp library may be URL encoding the string already, but I don't know it well enough and lack the time to work through it. I'm really sorry; I just don't have the cycles to handle this right now.

@germanattanasio
Copy link
Contributor

I'm going to assign this @blakesteve

@josepmao
Copy link
Author

@germanattanasio @blakesteve any update here?

@blakesteve
Copy link
Contributor

Reopening due to reversion, see #635

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

No branches or pull requests

4 participants