【发布时间】:2017-10-19 10:20:32
【问题描述】:
我正在尝试让异步回调为 IBM Watson 语音转文本工作。
我得到了 curl 函数的工作
curl -X POST -u "c94c7025-09f5-4cee-94dd-8f73348b60d8":"4TOriExZooKh" \
--header "Content-Type: audio/wav" \
--data-binary @uploads/001528fe-9545-4c3f-9d0d-aec4cd61caee.wav \
"https://stream.watsonplatform.net/speech-to-text/api/v1/recognitions?callback_url=http://34.234.215.13/callback.php&model=en-US_NarrowbandModel&profanity_filter=false&events=recognitions.completed_with_results&user_token=audio&results_ttl=10"
据我了解,结果或通知应作为 POST 发送到回调 URL
https://console.bluemix.net/docs/services/speech-to-text/async.html#create
上面的代码应该将完成的结果发送到callback.php
callback.php
<?php
header('Content-Type:text/plain');
echo $_GET["challenge_string"];
foreach ($_POST as $key => $value)
error_log($key . "--" . $value);
回显用于 url 注册,然后用于通过 POST 发送的任何数据,我将其传递到 foreach 循环中。
但是转换完成后我根本没有得到任何数据或结果。
access log
[14/Oct/2017:00:22:39 +0000] "POST /callback.php HTTP/1.1" 200 166 "-" "Jersey/2.22.1 (Apache HttpClient 4.5)"
error log
[:error] [pid 2046] [client 169.48.114.147:54645] PHP Notice: Undefined index: challenge_string in /var/www/html/callback.php on line 10
我无法理解出了什么问题?当我进行同步调用时,我能够让它工作,即一个又一个 POST。
【问题讨论】:
标签: php speech-to-text ibm-watson