Closed JVTEAM closed 4 years ago
I'm also getting 400 (Bad Request) after uploading wav file using just the example code:
client = Wit("mykey")
resp = client.message('what is the weather in London?') //works fine
print('Yay, got Wit.ai response: ' + str(resp))
resp = None
with open("Recording.wav", 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'}) //raises an error 400
print('Yay, got Wit.ai response: ' + str(resp))
app id 266939828014790
Hi @JVTEAM, the latest code is using the latest API version - check out the updated documentation.
@EviGL I was able to run a successful speech request using:
client = Wit(access_token=access_token)
with open('speech.wav', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))
Is the file properly encoded? My file has 16k sample rate, monochannel, 256k bit rate, 16-bit signed integer PCM sample encoding.
It failed on every device I was using it for. Switched to Google speech input.
The new key is text
, not _text
.
Do you want to request a feature, report a bug, or ask a question about pywit? Bug What is the current behavior? If I install from source I get inputWords = str(resp['_text']) KeyError: '_text' If I install from pip I get wit.wit.WitError: Wit responded with status: 400 (Bad Request)
I ran the same code on another machine that has worked in the past and it worked fine. If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. import subprocess import time import re from wit import Wit
the wit.ai API key (this is a fake one you will need to sign up for your own at wit.ai)
client_wit = Wit('MYCODE')
def listen(): inputWords = "" while (re.search('[a-zA-Z]', inputWords) is None):
using subprocess to call the sox recording software with a configuration to trim silence from the recording and stop recording when the speaker has finished
use the wit.ai class to interface with the API and send off the wav file from above for STT functions
if called direct then run the function
if name == 'main': print(listen())
What is the expected behavior? It will get a response back from wit.ai for my chatbot to respond to.
If applicable, what is the App ID where you are experiencing this issue? If you do not provide this, we cannot help. 2025978014172865