Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Wit AI speech recognition python

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading