Closed allencarvallo closed 4 years ago
CODE
_from dotenv import loaddotenv import os from wit import Wit
_loaddotenv() _access_token = os.getenv('SERVER_ACCESSTOKEN') _client = Wit(accesstoken) resp = None with open('milk.wav', 'rb') as f: resp = client.speech(f, {'Content-Type': 'audio/wav'}) print() _print('Yay, got Wit.ai response: ' + str(resp)) print()
ERROR
Traceback (most recent call last): File "speech.py", line 15, in resp = client.speech(f, {'Content-Type': 'audio/wav'}) File "C:\Users\Using Wit with python\venv\lib\site-packages\wit\wit.py", line 87, in speech resp = req(self.logger, self.access_token, 'POST', '/speech', params, File "C:\Users\Using Wit with python\venv\lib\site-packages\wit\wit.py", line 40, in req raise WitError('Wit responded with status: ' + str(rsp.status_code) + wit.wit.WitError: Wit responded with status: 400 (Bad Request)
Can you verify this works when sending a request through cURL directly?
Yes. I have tried a message that i already trained and it worked.
CODE
_from dotenv import loaddotenv import os from wit import Wit
_loaddotenv() _access_token = os.getenv('SERVER_ACCESSTOKEN') _client = Wit(accesstoken) resp = None with open('milk.wav', 'rb') as f: resp = client.speech(f, {'Content-Type': 'audio/wav'}) print() _print('Yay, got Wit.ai response: ' + str(resp)) print()
ERROR
Traceback (most recent call last): File "speech.py", line 15, in resp = client.speech(f, {'Content-Type': 'audio/wav'}) File "C:\Users\Using Wit with python\venv\lib\site-packages\wit\wit.py", line 87, in speech resp = req(self.logger, self.access_token, 'POST', '/speech', params, File "C:\Users\Using Wit with python\venv\lib\site-packages\wit\wit.py", line 40, in req raise WitError('Wit responded with status: ' + str(rsp.status_code) + wit.wit.WitError: Wit responded with status: 400 (Bad Request)