[英]How can I put a custom header for websocket handshake with boost beast
[英]How do I pass the model type in boost beast websocket
我正在使用c ++ 11,野獸庫和IBM語音文本Web服務。
執行握手時,websocket接口(用於連接)需要authentication token
作為請求標頭。
引用Watson文檔中提供的此代碼 ,似乎我也必須將模型類型(如果需要)作為請求標頭傳遞
var IAM_access_token = '{access_token}';
var wsURI = 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize'
+ '?access_token=' + IAM_access_token
+ '&model=es-ES_BroadbandModel';
var websocket = new WebSocket(wsURI);
還有提到的卷曲請求格式來設置“模型”
curl -X POST -u "apikey:{apikey}"
--header "Content-Type: audio/flac"
--data-binary @{path}audio-file.flac
"https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_NarrowbandModel"
有人可以幫我弄清楚如何在我的websocket中傳遞“模型”(在c ++ 11中使用野獸)嗎?
這是我傳遞身份驗證令牌的方式:
mWebSocket.async_handshake_ex(mHost, "/speech-to-text/api/v1/recognize",
[mToken](request_type& reqHead) {
reqHead.insert(http::field::authorization,mToken);},
bind(&IbmWebsocketSession::send_start, shared_from_this(), placeholders::_1));
正如@ALanBirtles建議的
將所需的model
放在url中
mWebSocket.async_handshake_ex(mHost, "/speech-to-text/api/v1/recognize?model=en-US_NarrowbandModel",...
作品
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.