0

我正在使用 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.

有人对我如何解决这个问题有想法吗?

4

1 回答 1

0

尝试这样的事情:

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)
于 2019-05-27T16:41:04.617 回答