Closed luis990 closed 4 years ago
Case closed, resolved
Hi @luis990 , I'm experiencing the same problem. The code I simply tested, directly from the README:
client = Wit(access_token)
resp = None
with open(AUDIO_FILE, 'rb') as f:
resp = client.speech(f, None, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))
Were there any insights on this that helped you solve it?
Is your access token your “private” token?
The Client seems to raise an error when response's request code is 400, not letting itself raise the second error which contains information about the error.
I'm having the same problem! Could you provide a solution, please?
I have used the sample code from git but having the same problem. Any help would be appreciated? Below is the code
import requests
import json
from wit import Wit
wit_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
def RecognizeSpeech(AUDIO_FILENAME, num_seconds = 5):
client = Wit(wit_access_token)
with open(AUDIO_FILENAME, 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'})
return resp
if __name__ == "__main__":
text = RecognizeSpeech('recordings/mav_abs_1.wav', 4)
print("\nYou said: {}".format(text))
Use Server access token available under settings page for the wit.ai bot.
I have the following code running on a Raspberry Pi in python 3:
from wit import Wit import speech_recognition as sr
access_token='Here I have putted my access token'
r = sr.Recognizer()
def send(request, response): print('Sending to user...', response = ['text'])
def my_action(request): print('Recieved from user', request['text'])
actions = { 'send': send, 'my_action': my_action, }
client = Wit(access_token=access_token, actions=actions)
resp = client.message('Hola') print(resp)
But when I run it the following error appears: Traceback (most recent call last): File "/home/pi/Desktop/LL.py", line 22, in
resp = client.message('Hola')
File "/usr/local/lib/python3.4/dist-packages/wit/wit.py", line 72, in message
resp = req(self.logger, self.access_token, 'GET', '/message', params)
File "/usr/local/lib/python3.4/dist-packages/wit/wit.py", line 34, in req
' (' + rsp.reason + ')')
wit.wit.WitError: Wit responded with status: 400 (Bad Request)
Any help would be very much appreciated as I am relatively new to programming