我正在尝试使用 bing 语音到文本将一些声音文件转录为文本。
以下命令在命令行中工作(在 Windows 10 上使用 git bash):
curl -v -X POST "https://speech.platform.bing.com/speech/recognition/interactive/
cognitiveservices/v1?language=<LANG>&format=detailed" -H "Transfer-Encoding:
chunked" -H "Ocp-Apim-Subscription-Key: <MY KEY>" -H "Content-type:
audio/wav; codec=audio/pcm; samplerate=16000" --data-binary @<MY .WAV-FILE>
我试过这个,但它不起作用:
httr::POST(url = myURL,
add_headers("Ocp-Apim-Subscription-Key" = key,
"Content-type" = "audio/wav; codec=audio/pcm; samplerate=16000",
"Transfer-Encoding" = "chunked"),
body = (list("file" = upload_file("PATH_TO_FILE.wav"))),
verbose())
它返回此输出:响应
[https://speech.platform.bing.com/speech/recognition/dictation/
cognitiveservices/v1?language=<LANG>&format=detailed]
Date: 2017-11-29 13:29
Status: 200
Content-Type: text/plain
Size: 75 B
我相信该请求与 .wav 文件的解释有关,并且我需要以某种方式将“--data-binary”标签添加到 httr-request 中。我可以看到我的“内容类型”是纯文本,尽管我已经指定了。此外:API 文档指定我需要在我的 wav 文件前面加上一个 at 符号。
任何帮助将非常感激。
干杯。
编辑:链接到 API 文档 https://docs.microsoft.com/da-dk/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=curl#tabpanel_AFC9x30-dR_curl