API 文档可以在这里找到:https ://github.com/watson-developer-cloud/java-sdk
当我尝试使用该服务时,它会正确验证,然后在合成方法上失败。
TextToSpeech tts_service = new TextToSpeech();
tts_service.setUsernameAndPassword("<username>", "<password>");
tts_service.synthesize("The cat sat on the mat", Voice.EN_LISA, "audio/ogg; codecs=opus");
错误的堆栈跟踪如下所示。我也尝试了不带语音和格式参数的合成方法(因为它有默认值),但是当我这样做时服务失败并出现相同的错误。
2015 年 11 月 25 日下午 4:58:55 com.ibm.watson.developer_cloud.service.WatsonService 执行严重: https ://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?text=The% 20cat%20sat%20on%20the%20mat&voice=en-US_LisaVoice&Accept=audio%2Fogg%3B%20codecs%3Dopus,状态:400,错误:不允许使用参数 [u'Accept']。2015 年 11 月 25 日下午 4:58:55 com.vaadin.server.DefaultErrorHandler doDefault SEVERE:com.ibm.watson.developer_cloud.service.BadRequestException:不允许使用参数 [u'Accept']。在 com.ibm.watson.developer_cloud.service.WatsonService.execute(WatsonService.java:128) 在 com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech.synthesize(TextToSpeech.java:119)
我很感激这方面的一些帮助,并希望使用 java API 而不是 REST 调用。
谢谢。