Watson Speech to Text - 构建 'WebSocket' 失败:URL 包含片段标识符
Watson Speech to Text - Failed to construct 'WebSocket': The URL contains a fragment identifier
我正在尝试将 Watson Speech 连接到文本 API,但是我收到以下针对 Firefox 和 Chrome 的错误。
注意:它之前工作正常,可能是 websocket 条款中的一些更新。
感谢您的帮助!
var token = "{{payload}}";
var model = "en-US_BroadbandModel"; // Change to your own model
var wsURI = 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=' +
token + '&model=' + model;
var ws = new WebSocket(wsURI);
在这一行中发现错误:
var ws = new WebSocket(wsURI);
浏览器控制台错误:
Firefox: "SyntaxError: An invalid or illegal string was specified"
Chrome: "Uncaught DOMException: Failed to construct 'WebSocket': The
URL contains a fragment identifier ('x3D;&model=en-US_BroadbandModel').
Fragment identifiers are not allowed in WebSocket URLs."
也许你需要转义令牌,你试过了吗?
顺便说一句。您尝试过 Watson Javascript SDK https://github.com/watson-developer-cloud/speech-javascript-sdk 吗?它为您处理这些较低级别的详细信息。
我正在尝试将 Watson Speech 连接到文本 API,但是我收到以下针对 Firefox 和 Chrome 的错误。 注意:它之前工作正常,可能是 websocket 条款中的一些更新。 感谢您的帮助!
var token = "{{payload}}";
var model = "en-US_BroadbandModel"; // Change to your own model
var wsURI = 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?watson-token=' +
token + '&model=' + model;
var ws = new WebSocket(wsURI);
在这一行中发现错误:
var ws = new WebSocket(wsURI);
浏览器控制台错误:
Firefox: "SyntaxError: An invalid or illegal string was specified"
Chrome: "Uncaught DOMException: Failed to construct 'WebSocket': The
URL contains a fragment identifier ('x3D;&model=en-US_BroadbandModel').
Fragment identifiers are not allowed in WebSocket URLs."
也许你需要转义令牌,你试过了吗?
顺便说一句。您尝试过 Watson Javascript SDK https://github.com/watson-developer-cloud/speech-javascript-sdk 吗?它为您处理这些较低级别的详细信息。