0

I am using deepspeech and deespeech-server. I am able to send the cURL command:

curl -X POST --data-binary @what_time_is_it.wav http://localhost:8080/stt

This gives me the correct speech to text translation "what time is it".

I am now trying to achieve the same result with a python script. My code is:

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)

I get the following output:

b'Speech to text error'

And on my server I get:

STT error: File format b'data'... not understood.

Does anyone have ideas for how I might fix this?

Ivan Vinogradov
  • 4,269
  • 6
  • 29
  • 39
O.Awoniyi
  • 13
  • 5

1 Answers1

0

Try something like this:

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)
Ivan Vinogradov
  • 4,269
  • 6
  • 29
  • 39
  • Thanks! I only needed to edit the requests.post line to: r = requests.post("http://localhost:8080/stt", data=open(filepath, 'rb').read()) – O.Awoniyi May 29 '19 at 10:34