0

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?

iohans
  • 838
  • 1
  • 7
  • 15
hknnd
  • 3
  • 2

1 Answers1

0

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/

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
iohans
  • 838
  • 1
  • 7
  • 15
  • 1
    Gotta be careful putting four-space-indented code right below a bulleted list -- the indentation for the code can be interpreted as just being regular text inside the list element. – Charles Duffy Jan 19 '23 at 18:47