[英]Convert cURL command to python using requests
我正在使用deepspeech和deespeech-server。 我能夠發送cURL命令:
curl -X POST --data-binary @what_time_is_it.wav http://localhost:8080/stt
這給了我正確的文本翻譯語音“現在幾點了”。
我現在正試圖用python腳本實現相同的結果。 我的代碼是:
import requests
data = {'data-binary': '@what_time_is_it.wav'}
response = requests.post("http://localhost:8080/stt", data=data)
print(response.content)
print(response.text)
我得到以下輸出:
b'Speech to text error'
在我的服務器上,我得到:
STT error: File format b'data'... not understood.
有沒有人有我如何解決這個問題的想法?
嘗試這樣的事情:
import requests
filepath = '/path/to/what_time_is_it.wav'
r = requests.post("http://localhost:8080/stt", data=open(filepath).read())
print(r.status_code)
print(r.content)
print(r.text)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.