Azure 语音转文本 REST API V3 二进制数据

标签 azure rest text-to-speech azure-speech

我正在尝试使用 Azure 语音转文本服务。在文档中,我遇到了使用 V1 API 版本的示例: https://$region.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1

基本上每个正确文档的链接都是针对 V3 API 的。

https://{endpoint}/speechtotext/v3.0

在此V1示例中,您可以轻松以二进制形式发送文件。

curl --location --request POST \
"https://$region.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US" \
--header "Ocp-Apim-Subscription-Key: $key" \
--header "Content-Type: audio/wav" \
--data-binary $audio_file

但我无法弄清楚如何提供用于获取字级时间戳的wordLevelTimestampsEnabled=true参数。

另一方面,我尝试使用V3 API,我可以轻松提供wordLevelTimestampsEnabled=true参数,但我不知道如何发送二进制文件文件数据。

curl -L -X POST 'https://northeurope.api.cognitive.microsoft.com/speechtotext/v3.0/transcriptions' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Ocp-Apim-Subscription-Key: $key' --data-raw '{
  "contentUrls": [
    "https://url-to-file.dev/test-file.wav"
  ],
  "properties": {
    "diarizationEnabled": false,
    "wordLevelTimestampsEnabled": true,
    "punctuationMode": "DictatedAndAutomatic",
    "profanityFilterMode": "Masked"
  },
  "locale": "pl-PL",
  "displayName": "Transcription using default model for pl-PL"
}'

有没有办法传递二进制文件并使用 wordLevelTimestampsEnabled=true 参数获取字级时间戳?

最佳答案

Is there a way to pass a binary file and also get word level timestamps with wordLevelTimestampsEnabled=true parameter?

根据Code Different的建议,将评论转换为社区 wiki 答案,以帮助可能面临类似问题的社区成员。

根据 documentation ,二进制文件不能直接上传。您应该通过 contentUrls 属性提供 URL。

例如:

{
  "contentUrls": [
    "<URL to an audio file to transcribe>",
  ],
  "properties": {
    "diarizationEnabled": false,
    "wordLevelTimestampsEnabled": true,
    "punctuationMode": "DictatedAndAutomatic",
    "profanityFilterMode": "Masked"
  },
  "locale": "en-US",
  "displayName": "Transcription of file using default model for en-US"
}

您可以引用Speech-to-text REST API v3.0 , cognitive-services-speech-sdkAzure Speech Recognition - use binary / hexadecimal data instead of WAV file path

关于Azure 语音转文本 REST API V3 二进制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72185246/

相关文章:

azure - 作为 Azure DevOps 发布管道的一部分从应​​用服务中删除文件

ruby-on-rails - 502 网关错误,失败 (13 : Permission denied) - with Nginx and Unicorn

python - 是否可以使用 Python SDK 检查特定 Azure blob 上是否有租约?

python - 设置江湖骗子测试的查询参数

java - TTS 中读取 "Strings"的编号

azure - 如何从 azure ADF 管道运行 Azure CLI 命令?

python - Django REST Framework 授权 token

java - 如何修复 Tomcat 的 'javax.servlet.ServletException: Servlet.init()' 错误

c# - C#如何获取单词对应的发音音素?

android - SpeechToText synthesizeToFile 不排队