首页 文章

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

提问于
浏览
1

我使用存储在我系统上的输入flac文件向Watson语音到文本API发出了卷曲请求 . 我使用了音频/ flac文件的路径,它存储在我的系统中 . 我想将它存储在 Cloud 上,并使用音频文件的URL作为我的输入 . 请让我知道如何做到这一点 . 下面是我使用存储在我系统上的flac文件传递输入的curl请求:

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传递

1 回答

  • 3

    在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"

    这里有几点需要注意:

    • 有两个 curl 命令 . 第一个获取文件,第二个将其发送给Watson .

    • 它们与管道操作员连接, |

    • 第二个 curl 命令被告知通过 --data-binary @- 标志接受来自第一个的输入 .

相关问题