Closed RobWills closed 9 years ago
I've fixed the issue, it will be available in the next release. For you I would suggest you to extend the TextToSpeech
class and override
InputStream synthesize(final String text, final Voice voice, final String outputFormat)
Example:
public class TextToSpeechHotFix extends TextToSpeech {
@Override
public InputStream synthesize(final String text, final Voice voice, final String outputFormat) {
final RequestBuilder request = RequestBuilder.get(PATH_SYNTHESIZE);
request.withQuery(TEXT, text);
request.withQuery(VOICE, voice.getName());
if (outputFormat != null && !outputFormat.startsWith("audio/"))
throw new IllegalArgumentException(
"format needs to be an audio mime type, for example: audio/wav or audio/ogg; codecs=opus");
request.withQuery(ACCEPT, outputFormat != null ? outputFormat : HttpMediaType.AUDIO_WAV);
final Response response = execute(request.build());
return ResponseUtil.getInputStream(response);
}
}
German,
Much obliged for such a quick and personal response. Keep up the good work.
Regards,
I've fixed the issue, it will be available in the next release. For you I would suggest you to extend the TextToSpeech class and override
InputStream synthesize(final String text, final Voice voice, final String outputFormat)
with:
public class TextToSpeechHotFix extends TextToSpeech {
@Override public InputStream synthesize(final String text, final Voice voice, final String outputFormat) { final RequestBuilder request = RequestBuilder.get(PATH_SYNTHESIZE); request.withQuery(TEXT, text); request.withQuery(VOICE, voice.getName()); if (outputFormat != null && !outputFormat.startsWith("audio/")) throw new IllegalArgumentException( "format needs to be an audio mime type, for example: audio/wav or audio/ogg; codecs=opus");
request.withQuery(ACCEPT, outputFormat != null ? outputFormat : HttpMediaType.AUDIO_WAV);
final Response response = execute(request.build());
return ResponseUtil.getInputStream(response);
} }
When I call the synthesize method of TextToSpeech() like so:
I get a bad request exception:
Is this a bug in the API or am I calling it wrong? I have been using other services in the same API without any problem. It seems to be adding the "Accept" HttpHeader title as a query parameter from what I can tell.
Apologies if it is my error. Rob Wills.