我正在嘗試使用 Azure Speech to text 服務。在檔案中,我遇到了使用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引數獲取字級時間戳?
uj5u.com熱心網友回復:
有沒有辦法傳遞二進制檔案并使用
wordLevelTimestampsEnabled=true引數獲取字級時間戳?
正如Code Different所建議的,將評論轉換為社區 wiki 答案以幫助可能面臨類似問題的社區成員。
根據檔案,二進制檔案不能直接上傳。您應該通過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-sdk和Azure Speech Recognition - 使用二進制/十六進制資料而不是 WAV 檔案路徑
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/474381.html
