Raspberry Pi Asynchronous/Continuous Python 中的语音识别
Raspberry Pi Asynchronous/Continuous Speech Recognition in Python
我想为 Python 中的 Raspberry Pi 创建一个语音识别脚本,并且需要一个 asynchronous/continuous 语音识别库。异步意味着我需要无穷无尽的 运行 识别,直到口语与一组单词匹配而无需任何键盘输入,然后将口语显示到终端并重新启动识别。我已经看过 PocketSphinx,但在谷歌搜索了几个小时后,我没有找到任何关于异步识别的信息。
你知道哪个图书馆有这方面的能力吗?
您可以在 Raspberry Pi 上使用 Pocketsphinx。您需要下载最新版本的 5prealpha。
它可以监听多个关键词。代码应该是这样的:
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
文件应如下所示,每行一个短语,并带有阈值
open the door /1e-40/
close the door /1e-40/
how are you /1e-30/
必须为每个关键短语调整阈值,以在错误警报和错误检测之间取得平衡。
嗯,您可以将 Jasper 的 name 更改为其他内容。也许,甚至是一个空字符串。
我想为 Python 中的 Raspberry Pi 创建一个语音识别脚本,并且需要一个 asynchronous/continuous 语音识别库。异步意味着我需要无穷无尽的 运行 识别,直到口语与一组单词匹配而无需任何键盘输入,然后将口语显示到终端并重新启动识别。我已经看过 PocketSphinx,但在谷歌搜索了几个小时后,我没有找到任何关于异步识别的信息。
你知道哪个图书馆有这方面的能力吗?
您可以在 Raspberry Pi 上使用 Pocketsphinx。您需要下载最新版本的 5prealpha。
它可以监听多个关键词。代码应该是这样的:
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
文件应如下所示,每行一个短语,并带有阈值
open the door /1e-40/
close the door /1e-40/
how are you /1e-30/
必须为每个关键短语调整阈值,以在错误警报和错误检测之间取得平衡。
嗯,您可以将 Jasper 的 name 更改为其他内容。也许,甚至是一个空字符串。