简体   繁体   English

对于像https://watson-speech.mybluemix.net/microphone-streaming.html这样的简单语音转文本应用程序,是否有一些libcurl脚本?

[英]Is there a bit of libcurl script for a simple speech-to-text application like this https://watson-speech.mybluemix.net/microphone-streaming.html?

I made a lite plan on IBM and wanted to transcribe speech from a microphone into a container and create an audio file on my server. 我在IBM上制定了一个精简计划,希望将语音从麦克风转录到容器中,并在服务器上创建音频文件。 (as on the example page here For this, I use the libcurl of PHP. (如此处示例页面所示为此,我使用了PHP的libcurl。

How do I use the API key and the other variables I got via JSON-snippet? 如何使用通过JSON代码段获得的API密钥和其他变量?

"apikey": "<api-key>",
"iam_apikey_description": "<description>",
"iam_apikey_name": "<apikey-name>",
"iam_role_crn": "<role-crn>",
"iam_serviceid_crn": "<serviceid_crn>",
"url": "https://gateway-lon.watsonplatform.net/speech-to-text/api"

I tried this: 我尝试了这个:

$json      = file_get_contents('./srv/lb/watson/watson.json');
$json_data = json_decode($json,true);

$file      = fopen('./srv/data/0001.flac', 'r');
$size      = filesize('./srv/data/0001.flac');
$filedata  = fread($file,$size);
$headers   = array(
"Content-Type: audio/flac",
"Transfer-Encoding: chunked"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $json_data['url']);
curl_setopt($ch, CURLOPT_USERPWD, "apikey:".$json_data['apikey']);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $filedata);
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$executed = curl_exec($ch);
curl_close($ch);
var_dump($executed);

But I got: 但是我得到了:

string(153) "{ "code": 404, "code_description": "Not Found", "error": "No route found for http://gateway-lon.watsonplatform.net/speech-to-text/api (usher)" }" string(153)“ {”代码“:404,” code_description“:”未找到“,”错误“:”未找到http://gateway-lon.watsonplatform.net/speech-to-text/api的路由(招待员)” }”

React.createElement("div", { className: "shopping-list" }, React.createElement("h1", null, "Shopping List for ", props.name), React.createElement("ul", null, React.createElement("li", null, "Instagram"), React.createElement("li", null, "WhatsApp"), React.createElement("li", null, "Oculus"))); React.createElement(“ div”,{className:“购物清单”},React.createElement(“ h1”,null,“购物清单”,props.name),React.createElement(“ ul”,null,React .createElement(“ li”,null,“ Instagram”),React.createElement(“ li”,null,“ WhatsApp”),React.createElement(“ li”,null,“ Oculus”))))); Thanks for contributing an answer to Stack Overflow! 感谢您为Stack Overflow提供答案! project v2 started 项目v2已启动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IBM Watson语音到文本发送麦克风数据关闭连接 - IBM Watson Speech-to-Text sending microphone data closes connection 用于语音转文本WebSocket的IBM Watson JavaScript SDK - IBM Watson JavaScript SDK for Speech-To-Text WebSocket Issue IBM Watson Speech-to-Text JavaScript SDK:如何获取消息? - IBM Watson Speech-to-Text JavaScript SDK: how to get messages? 语音到文本识别不准确 - Speech-to-text Recognition is not accurate 如何将 Speech-to-Text 添加到使用 React Native 编写的聊天应用程序中 - How to add Speech-to-Text into a chat application that is written on React Native 针对盲人的JavaScript语音转文本 - JavaScript Speech-to-Text for blind people 显示Google Cloud语音转文字 - Displaying Google Cloud Speech-to-Text 在Microsoft BotFramework WebChat中集成用于文本到语音和语音到文本的认知语音服务 - Integrating Cognitive Speech Service for both Text-to-Speech and Speech-to-Text in Microsoft BotFramework WebChat 如何使用 AIFF 文件进行语音转文本 - How to get speech-to-text working with an AIFF file 谷歌语音转文本 API 示例代码将无法运行 - Google speech-to-text API sample code will not run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM