-
Notifications
You must be signed in to change notification settings - Fork 528
Closed
Labels
Description
- 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.