在 WATSON 语音转文本 api 中传递 URL 而不是系统路径

Passing URL instead of system path in WATSON speech-to-text api

我使用存储在系统中的输入 flac 文件向 Watson 语音转文本 API 发出了 curl 请求。我使用 audio/flac 文件的路径存储在我的系统上。我想将它存储在云端的某个位置,并使用音频文件的 URL 作为我的输入。请让我知道该怎么做。 下面是 curl 请求,我使用存储在系统中的 flac 文件传递​​输入:

curl -X POST -u username:password --header "Content-Type: audio/flac" --header "Transfer-Encoding: chunked" --data-binary @/home/rishabh/Desktop/watson/test_file.flac "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true"

在上面的请求中,输入文件路径是:/home/rishabh/Desktop/watson/test_file.flac。如何将其作为 URL

传递

从 Watson 服务代表您下载文件的意义上讲,这是不可能的,但可以通过单个命令将文件下载并转发给 Watson,而不会在您的计算机上保存本地副本计算机:

curl "https://watson-test-resources.mybluemix.net/resources/weather.flac" | curl -X POST -u "username:password" --header "Content-Type: audio/flac" --header "Transfer-Encoding: chunked" --data-binary @- "https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true"

这里有几点需要注意:

  1. 有两个curl命令。第一个获取文件,第二个将其发送给 Watson。
  2. 他们与管道运营商相连,|
  3. 第二个 curl 命令被告知通过 --data-binary @- 标志接受第一个命令的输入。