wit-ai / wit

Natural Language Interface for apps and devices
https://wit.ai/
933 stars 91 forks source link

Can not use api anymore #1158

Closed maxcogay closed 6 years ago

maxcogay commented 6 years ago

Do you want to request a feature, report a bug, or ask a question about wit? question What is the current behavior? I can not communicate with the bot anymore, but I can communicate the day before, but today it only returns bad requests Is my APP locked?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.Have call API from 'https://api.wit.ai/speech?

wit_access_token = 'SFGCBHUVEZDJ27CLFFP5ENQO2NOSEG2L';
        headers = {'authorization': 'Bearer ' + wit_access_token,'Content-Type': 'audio/wav'};
        Mic.Record(1024,pyaudio.paInt16,1,8000,3,"/home/l/PROJECT/Audio/WITAI.wav").profile();
with open("/home/l/PROJECT/Audio/WITAI.wav", "rb") as binary_file:
            data = binary_file.read();
        try:
            r = requests.post('https://api.wit.ai/speech?v=20180725',data=data,headers=headers);
            data = json.loads(r.content);
            TEXTWIT = format(data['_text']);

What is the expected behavior?

please tell me the result What is the App ID where you are experiencing this issue (if applicable)? 5b16ab19-c610-47f8-881c-5a94ff08caf8

stopachka commented 6 years ago

hey @maxcogay -- This may be related to the audio being sent. Can inspect it, to make sure there is actual text being said in the audio? If yes, please email me the wav file and I can try to repro (stopachka [at] fb [dat] com)

maxcogay commented 6 years ago

hey @stopachka , I have checked the audio file very well in advance, I can use the current is not

stopachka commented 6 years ago

Hey @maxcogay -- I am not sure what you mean by that sentence x} -- do you mind rephrasing?

maxcogay commented 6 years ago

hi @stopachka hello i sent the audio file through your mail :stepan.p@gmail.com , you can check it for me ,I'm a new member of github so I do not understand much about how to use your compassion

JulianoPensador commented 6 years ago

I´m having the same issue,yesterday was working just fine,but now I´m getting the "KeyError: '_text"

Here´s my code:

######################################################################## import requests import json from Gravador_E import record_audio, read_audio

Wit speech API endpoint

API_ENDPOINT = 'https://api.wit.ai/speech'

Wit.ai api access token

wit_access_token = 'OJZILMLT5N25GUKTLGTKCHTPTNQLFIVZ'

def RecognizeSpeech(AUDIO_FILENAME, num_seconds = 10):

# record audio of specified length in specified audio file
record_audio(num_seconds, AUDIO_FILENAME)

# reading audio
audio = read_audio(AUDIO_FILENAME)

# defining headers for HTTP request
headers = {'authorization': 'Bearer ' + wit_access_token,
           'Content-Type': 'audio/wav'}

# making an HTTP post request
resp = requests.post(API_ENDPOINT, headers = headers,
                     data = audio)

# converting response content to JSON format
data = json.loads(resp.content)

# get text from data
text = data['_text']

# return the text
return text

if name == "main":

text = RecognizeSpeech('myspeech.wav', 4) print((text))

#############################################################################

Here´s the Recording Code:

import pyaudio import wave

def record_audio(RECORD_SECONDS, WAVE_OUTPUT_FILENAME):

--------- SETTING PARAMS FOR OUR AUDIO FILE ------------

FORMAT = pyaudio.paInt16    # format of wave
CHANNELS = 1#2                # no. of audio channels
RATE = 44100                # frame rate
CHUNK = 2000                # frames per audio sample
#--------------------------------------------------------#

# creating PyAudio object
audio = pyaudio.PyAudio()

# open a new stream for microphone
# It creates a PortAudio Stream Wrapper class object
stream = audio.open(format=FORMAT,channels=CHANNELS,
                    rate=RATE, input=True,
                    frames_per_buffer=CHUNK)

#----------------- start of recording -------------------#

print("Escutando...")

# list to save all audio frames
frames = []

for i in range(int(RATE / CHUNK * RECORD_SECONDS)):
    # read audio stream from microphone
    data = stream.read(CHUNK)
    # append audio data to frames list
    frames.append(data)

#------------------ end of recording --------------------#   

print("Analisando...")

stream.stop_stream()    # stop the stream object
stream.close()          # close the stream object
audio.terminate()       # terminate PortAudio

#------------------ saving audio ------------------------#

# create wave file object
waveFile = wave.open(WAVE_OUTPUT_FILENAME, 'wb')

# settings for wave file object
waveFile.setnchannels(CHANNELS)
waveFile.setsampwidth(audio.get_sample_size(FORMAT))
waveFile.setframerate(RATE)
waveFile.writeframes(b''.join(frames))

# closing the wave file object
waveFile.close()

def read_audio(WAVE_FILENAME):

function to read audio(wav) file

with open(WAVE_FILENAME, 'rb') as f:
    audio = f.read()
return audio
stopachka commented 6 years ago

Hey team, apologies for the inconvenience, we ended up with an unexpected bug that lay quietly in our speech api, which affected your usage. We've went ahead patched the service, so things should be working once more, with a long-term fix on the way.

JulianoPensador commented 6 years ago

Yeah,that fixed it,Thank you guys