我当前在终端中使用此命令尝试以8 kHz采样率将16 bps的telephonic mono voice sample wav转录到IBM Speech-to-Text引擎。
curl -X POST \
-u "apikey goes here" \
--header "Content-Type: audio/wav", "model: en-US_NarrowbandModel" \
--data-binary @{path_url_goes_here)/OSR_us_000_0010_8k.wav \
"https://stream.watsonplatform.net/speech-to-text/api/v1/recognize"
但是,输出指出不支持输入wav:
curl: (3) Port number ended with ' '
{
"code_description": "Unsupported Media Type",
"code": 415,
"error": "Unable to transcode from audio/wav, to one of: audio/x-float-array; rate=16000; channels=1, application/srgs, application/srgs+xml, application/jsgf, application/fsm, application/bnf"
}
根据IBM supported audio format list,我已将模型更改为“NarrowbandModel”,以允许如上所述的最小输入采样率为8 kHz。
我的问题:
我的请求或音频文件有问题吗?
更新:我尝试将.wav转换为恒定的8和48 kHz采样率的MP3格式。更改为“Content-Type:音频/ mp3”后,也会产生与上述相同的输出。
最佳答案
尝试在网址中传递model = en-US_NarrowbandModel作为参数。以下curl命令对您的wav文件适用于我。
curl -X POST \
-u "apikey:XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type:audio/wav" \
--data-binary @OSR_us_000_0010_8k.wav \
"https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_NarrowbandModel"
{
"results": [
{
"alternatives": [
{
"confidence": 0.985,
"transcript": "the birch canoes slid on the smooth planks "
}
],
"final": true
},
关于api - IBM Speech中的curl “Unsupported Media Type”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53304838/