I want the speech to be recorded by raspberry, send it to wit.ai and then get the response on my page(wich is actually the .py script and according to which I could run my conditions). Actually its the part of my project Home Automation using raspberry. So when I say 'light on' it could do so by running the scripts. I did the lot of search on google read the docs but ...did not got my problem solved. Any help is heartly appreciated... Thank you :)


The easiest way would be to use a pre-made module to communicate with Wit. Usually, searching for whatever you're trying to do along with "Python" brings up many libraries, and I found pywit quickly by searching for "Python Wit.ai".

Instructions and usage guidance is given there; you can install it using Pip with pip install wit. (pip3 for Python 3)

You can send a request to Wit to convert speech to text as follows:

from wit import Wit

client = Wit(access_token)
resp = None
with open('test.wav', 'rb') as f:
  resp = client.speech(f, None, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))

You will of course need to integrate that into your web server, but it should be relatively straightforward to collect a WAV file from the user and return the output.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.