【问题标题】:Wit AI speech recognition python机智AI语音识别python
【发布时间】:2023-01-20 02:24:42
【问题描述】:

我写的代码没有给出我想要的答案。

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

代码给了我“耶,得到了 Wit.ai 响应:{'entities': {}, 'intents': [], 'text': '', 'traits': {}}”

为什么?

【问题讨论】:

  • sa.mp3 不是 WAV 文件。您需要使用正确的格式标识。
  • 尝试 PCM 音频文件,因为这是 Wit 期望的默认格式。

标签: python wit.ai


【解决方案1】:

您错误响应的最可能原因是您向 Wit 发送了错误的格式。要么将文件更改为类似 sa.wav 的文件,要么将 Content-Type 更改为 audio/mpeg。

  • PCM(音频/原始)默认格式。

  • mp3(音频/mpeg)

  • wav(音频/wav)

    从机智导入机智

    客户=机智(“XXXYYYZZZ”)

    用 open('sa.mp3', 'rb') 作为 f: resp = client.speech(f, {'Content-Type': 'audio/mpeg'}) print('耶,得到了 Wit.ai 的回应:' + str(resp))`

文档:https://wit.ai/docs/http/20221114/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-15
    • 2010-11-30
    • 2021-07-04
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    相关资源
    最近更新 更多