java - 沃森语音到文本未经授权的请求错误 401
问题描述
我尝试使用 IBM Watson GitHub 存储库中的代码,我不得不对粘贴时遇到的一些错误进行一些更改。然后我尝试运行代码以查看它从音频文件到文本的转录。但我得到错误 401 未经授权。我试图查看解决方案,但没有找到。她是我的密码,
SpeechToText service = new SpeechToText();
IamOptions options1 = new IamOptions.Builder()
.apiKey("{apikey}")
.build();
service.setIamCredentials(options1);
File audio = new File("C:\\Users\\usern\\Downloads\\audio-file.FLAC");
RecognizeOptions options = new RecognizeOptions.Builder()
.audio(audio)
.contentType(HttpMediaType.AUDIO_FLAC)
.build();
SpeechRecognitionResults transcript = service.recognize(options).execute().getResult();
System.out.println(transcript);
解决方案
所以我要解决这个问题的答案是添加service.setEndPoint("https://gateway-lon.watsonplatform.net/speech-to-text/api");
为第二行。我的 URL 是在查看 IBM 云服务网站上的凭证时找到的,并不是说该 URL 与我在伦敦的我所在的 URL 可能不同。
推荐阅读
- debian - 在 Debian 上安装 php-gd ext
- ruby-on-rails - Rspec/Capybara 测试后表单中缺少参数,但手动测试时参数在 dev 中提交得很好
- javascript - 模态中的进度条不更新
- java - 如何进行音高转换?
- javascript - 来自 Android App 和 Chrome 的 WebRTC P2P 视频流每秒冻结
- android - 在Android中使用edittext过滤搜索后单击Listview错误位置
- javascript - 页面刷新后不存储本地存储
- php - 从另一台服务器接收 http post 时出现错误 403
- django - React 和 Django 部署
- javascript - 为什么重新分配导入的对象会抛出 ReferenceError?