[英]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.