Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wit responded with status 400 #79

Closed
luis990 opened this issue Jan 7, 2017 · 7 comments
Closed

Wit responded with status 400 #79

luis990 opened this issue Jan 7, 2017 · 7 comments

Comments

@luis990
Copy link

luis990 commented Jan 7, 2017

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

@luis990
Copy link
Author

luis990 commented Jan 7, 2017

Case closed, resolved

@luis990 luis990 closed this as completed Jan 7, 2017
@pnmartinez
Copy link

pnmartinez commented Aug 21, 2017

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?

@luis990
Copy link
Author

luis990 commented Aug 29, 2017

Is your access token your “private” token?

@luis990 luis990 reopened this Aug 29, 2017
@333444555
Copy link

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.
#126 should help you diagnose this further.

@Longman-Stan
Copy link

I'm having the same problem! Could you provide a solution, please?

@Prateek13727
Copy link

Prateek13727 commented Jun 2, 2020

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))

@RAJAT--PALIWAL
Copy link

Use Server access token available under settings page for the wit.ai bot.

@lycai-fb lycai-fb closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants