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?

Asked By: hknnd

||

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

Docs: https://wit.ai/docs/http/20221114/

Answered By: iohans
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.