Wit AI speech recognition python
Question:
The code i wrote does not give the answer i want.
from wit import Wit
client = Wit("XXXYYYZZZ")
with open('sa.mp3', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))`
the code gives me the "Yay, got Wit.ai response: {‘entities’: {}, ‘intents’: [], ‘text’: ”, ‘traits’: {}}"
why?
Answers:
The most likely reason for your errored response is that you are sending the wrong format to Wit. Either change the format of the file to something like sa.wav or change the Content-Type to audio/mpeg.
- PCM (audio/raw) Default format.
- mp3 (audio/mpeg)
- wav (audio/wav)
from wit import Wit
client = Wit("XXXYYYZZZ")
with open('sa.mp3', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/mpeg'})
print('Yay, got Wit.ai response: ' + str(resp))
The code i wrote does not give the answer i want.
from wit import Wit
client = Wit("XXXYYYZZZ")
with open('sa.mp3', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))`
the code gives me the "Yay, got Wit.ai response: {‘entities’: {}, ‘intents’: [], ‘text’: ”, ‘traits’: {}}"
why?
The most likely reason for your errored response is that you are sending the wrong format to Wit. Either change the format of the file to something like sa.wav or change the Content-Type to audio/mpeg.
- PCM (audio/raw) Default format.
- mp3 (audio/mpeg)
- wav (audio/wav)
from wit import Wit
client = Wit("XXXYYYZZZ")
with open('sa.mp3', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/mpeg'})
print('Yay, got Wit.ai response: ' + str(resp))