【问题标题】:How to find a word in an audio file in Python?如何在 Python 的音频文件中查找单词?
【发布时间】:2017-11-14 16:39:21
【问题描述】:

我有一个包含口语单词的音频文件。我确定它包含单词,我需要检测单词的开头和结尾。

关于如何使用 python 做到这一点的任何想法?

这就是我所做的。 我尝试在 Python 中使用 Speech_recognition 库。

import speech_recognition as sr
r = sr.Recognizer()
with sr.WavFile("a.wav") as source:              
    audio = r.record(source)                        

try:
    list = r.recognize_google(audio,key=None)                 
    print list
except LookupError:                                
    print("Could not understand audio")

这将转录音频,但不提供单词出现时间的时间戳。我知道我可以将我的音频文件分成几部分,然后通过谷歌语音识别器继续输入它,直到我得到我想要的部分,但这似乎是一个糟糕的主意。我还设想了转录不太准确的情况,因此我确定文件中的单词可能无法准确转录。

我也尝试过 pocketsphinx,但我不确定如何让它提供文件中某个单词的可能位置(它严重转录了测试文件)。

理想情况下,我会搜索一个函数:find_likely_location_of_word(word),它返回一个开始时间戳和一个结束时间戳。

我认为这必须是已经做过很多次的事情,所以也许有人至少可以为我指出正确的方向?

【问题讨论】:

  • 还有返回时间戳的 API,例如 IBM Watson。这是关于速度/准确性的平衡。转录速度较慢但更准确,定位更快且更可靠,但容易出现误报。

标签: python speech-recognition pocketsphinx google-speech-api


【解决方案1】:

把你要找的词叫做“var”

    import speech_recognition as sr
r = sr.Recognizer()
with sr.WavFile("a.wav") as source:              
    audio = r.record(source)                        

try:
    list = r.recognize_google(audio,key=None)                 
    if var in list:
        print("word found")

except LookupError:                                
    print("Could not understand audio")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-02
    • 2016-07-27
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    相关资源
    最近更新 更多