树莓派异步/连续语音识别在Python [英] Raspberry Pi Asynchronous/Continuous Speech Recognition in Python
问题描述
我想创建的树莓派Python中的语音识别脚本,需要一个异步/连续语音识别库。异步意味着我必须承认,直到比赛口语单词的数组无尽的运行没有从键盘输入任何内容,然后显示谈过,终端,并重新启动的认可。我已经有了一看PocketSphinx,但几个小时后,谷歌搜索,我没有找到关于与异步承认什么。
I want to create a speech recognition script for the Raspberry Pi in Python and need an asynchronous/continuous speech recognition library. Asynchronous means that I need endless running of the recognition until the spoken matches to an array of words without any input from a keyboard, and then display the spoken to the terminal and restart recognition. I already had a look at PocketSphinx, but after a few hours Googling, I didn't find anything about an Asynchronous recognition with that.
你知道的任何图书馆谁能够说?
Do you know any Library who is capable of that?
推荐答案
您可以在树莓派使用Pocketsphinx。您需要下载最新版本的5 prealpha。
You can use Pocketsphinx on Raspberry Pi. You need to download latest version 5prealpha.
它可以侦听多关键字句。在code应该是这样的:
It can listen for multiple keyphrases. The code should be something like this:
import sys, os
from pocketsphinx import *
import pyaudio
modeldir = "../../../model"
# Create a decoder with certain model
config = Decoder.default_config()
config.set_string('-hmm', os.path.join(modeldir, 'en-us/en-us'))
config.set_string('-dict', os.path.join(modeldir, 'en-us/cmudict-en-us.dict'))
config.set_string('-kws', 'keyphrase.list')
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)
stream.start_stream()
# Process audio chunk by chunk. On keyword detected perform action and restart search
decoder = Decoder(config)
decoder.start_utt()
while True:
buf = stream.read(1024)
decoder.process_raw(buf, False, False)
if decoder.hyp() != None:
print "Detected keyword", decoder.hyp(), "restarting search"
decoder.end_utt()
decoder.start_utt()
的 keypharse.list
文件应该是这样的,每行一个短语与阈值
The keypharse.list
file should look like this, one phrase per line with threshold
open the door /1e-40/
close the door /1e-40/
how are you /1e-30/
阈值必须调整为每一个关键词的误报和错误检测之间的平衡。
Thresholds must be tuned for every keyphrase to balance between false alarms and misdetections.
这篇关于树莓派异步/连续语音识别在Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!