简体   繁体   English

Wit AI语音识别

[英]Wit AI speech recognition

I am trying to submit an audio in ogg format to https://api.wit.ai/speech?v=20200513 .我正在尝试向https://api.wit.ai/speech?v=20200513提交 ogg 格式的音频。 I need to receive a text representation of the voice.我需要接收语音的文本表示。 When I submit the code through curl request, it returns empty response as {"_text": "", "entities": ""} .当我通过 curl 请求提交代码时,它返回空响应作为{"_text": "", "entities": ""} I also tried to execute it with pywit.我也尝试用 pywit 执行它。 Below is the code:下面是代码:

from wit import Wit

client = Wit('XXXXXXXXXXXXXXXXX')
with open('2.ogg', 'rb') as f:
    print(f)
    resp = client.post_speech(f, content_type='audio/ogg')

print('Yay, got Wit.ai response: ' + str(resp))

My guess was that the file is not captured, but print shows _io.BufferedReader name='2.ogg' , which means that the file is stored in the buffer, but wit ai refuses to transcribe it.我的猜测是文件没有被捕获,但打印显示_io.BufferedReader name='2.ogg' ,这意味着文件存储在缓冲区中,但机智拒绝转录它。

Why does wit respond with empty _text ?为什么智慧以空_text回应?

Not sure why, but the problem happens only with OGG files even though documentation states that it does work with this file extension.不知道为什么,但问题只发生在 OGG 文件中,即使文档说明它确实适用于这个文件扩展名。 So, I had to convert the audio into WAV and try again.所以,我不得不将音频转换成 WAV,然后再试一次。 This time it worked perfectly well.这一次它运行得非常好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM