我在我的 Linux 机器上正确安装了 Pocketsphinx,现在我想使用 Pocketsphinx 将音频文件 (.wave) 转换为文本,我该怎么做?有没有明确的命令和简短的命令来做到这一点?像这样的命令:
./src/programs/pocketsphinx_continuous -samprate 8000 -nfft 2048 -adcdev hw:1,0 -lm 2530.lm -dict 2530.dic myvoice.wav
Run Code Online (Sandbox Code Playgroud)
以及如何使用 python 做到这一点?提前致谢。
python speech-recognition voice-recognition cmusphinx pocketsphinx
我在Windows上使用pocketsphinx_continuous.将输出重定向到文本文件使用"-infile"参数,但失败并显示"-inmic yes".
正如在问题中所指出的那样,袖珍华丽冲洗了什么?pocketsphinx忽略了stdout(至少在使用-inmic时).
有没有什么方法可以将pocketsphinx_continuous识别的单词"-inmic yes"保存到文本文件中?
具体来说,我希望我的Java程序运行pocketsphinx_continuous.exe并从麦克风输入中识别单词.
使用-backtrace与-logfn亚历山大Solovets的建议确实是节省了与日志指定文件中沿结果.但是,日志不会像结果发送到终端那样频繁保存.我希望结果输出尽可能快,所以我从源代码构建了pocketsphinx_continuous.exe,并进行了以下更改continous.c.
在continuous.c中:
hyp = ps_get_hyp(ps, NULL );
if (hyp != NULL)
{
printf("%s\n", hyp);
FILE * fp;
fp = fopen("file.txt", "a+");
fprintf(fp, hyp);
fprintf(fp, "\r\n");
fclose(fp);
}
Run Code Online (Sandbox Code Playgroud) 当我跑步时pocketsphinx_continuous -inmic yes,我收到这个错误:ERROR: "acmod.c", line 85: Acoustic model definition is not specified neither with -mdef option nor with -hmm.
我已经阅读了StackOverflow问题以及Pocketsphinx FAQ中的信息,但这些信息都没有帮助.
这是完整的堆栈跟踪:
INFO: cmd_ln.c(691): Parsing command line:
pocketsphinx_continuous \
-inmic yes
Current configuration:
[NAME] [DEFLT] [VALUE]
-adcdev
-agc none none
-agcthresh 2.0 2.000000e+00
-alpha 0.97 9.700000e-01
-argfile
-ascale 20.0 2.000000e+01
-aw 1 1
-backtrace no no
-beam 1e-48 1.000000e-48
-bestpath yes yes
-bestpathlw 9.5 9.500000e+00
-bghist no no
-ceplen 13 13
-cmn …Run Code Online (Sandbox Code Playgroud) 据我所知,我正在使用Python口袋里的狮身人面像教程
https://metakermit.com/2011/python-speech-recognition-helloworld/
(完整代码在这里):
import sys,os
def decodeSpeech(hmmd,lmdir,dictp,wavfile):
"""
Decodes a speech file
"""
try:
import pocketsphinx as ps
import sphinxbase
except:
print """Pocket sphinx and sphixbase is not installed
in your system. Please install it with package manager.
"""
speechRec = ps.Decoder(hmm = hmmd, lm = lmdir, dict = dictp)
wavFile = file(wavfile,'rb')
wavFile.seek(44)
speechRec.decode_raw(wavFile)
result = speechRec.get_hyp()
return result[0]
if __name__ == "__main__":
hmdir = "/usr/share/pocketsphinx/model/hmm/en_US/"
lmd = "/usr/share/pocketsphinx/model/lm/en_US/hub4.5000.DMP"
dictd = "/usr/share/pocketsphinx/model/lm/en_US/cmu07a.dic"
wavfile = sys.argv[1]
recognised = decodeSpeech(hmdir,lmd,dictd,wavfile)
print …Run Code Online (Sandbox Code Playgroud) 我正在使用带有树莓派的 Pocketsphinx 来实现家庭自动化。我用支持的命令编写了一个简单的 JSGF 语法文件。现在,我想在命令之前使用诸如“嘿计算机”之类的激活短语,以避免错误检测,并且仅在说出激活短语后才执行语音识别。
如果我没弄错的话,pocketsphinx 支持两种语音识别模式:关键字识别模式和语言模型/JSGF 语法模式。
在解决如何拒绝语法外单词的问题时,pocketsphinx 常见问题解答中说:
如果要识别多个命令,可以使用关键字发现模式或关键字激活模式结合切换到语法进行实际操作。
我的问题是,这种从关键字识别模式到语法模式的“切换”究竟是如何实现的?(我应该怎么做才能实现它?)。与此相关,“关键字发现模式”和“关键字激活模式”有什么区别?
谢谢!
在python3中安装pocketsphinx时遇到这个问题
我正在使用 anaconda3, windows 10 。
pip install --upgrade pocketsphinx
以下是我在安装 Pocketsphinx 时遇到的错误。
Collecting pocketsphinx
Using cached pocketsphinx-0.1.3.zip
Building wheels for collected packages: pocketsphinx
Running setup.py bdist_wheel for pocketsphinx ... error
Complete output from command /home/geek/anaconda3/bin/python -u -c
"import setuptools, tokenize;__file__='/tmp/pip-build-k634wg4p
/pocketsphinx/setup.py';f=getattr(tokenize, 'open',
open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d
/tmp/tmp6ts477xjpip-wheel- --python-tag cp36:
running bdist_wheel
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include
/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig-
outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
unable to execute 'swig': …Run Code Online (Sandbox Code Playgroud) 我尝试安装 pocketsphinx 并收到以下错误:
jandornhege@JanDornhegeUbuntu:~/Hermes/Basefunktions$ pip install pocketsphinx
Collecting pocketsphinx
Using cached https://files.pythonhosted.org/packages/cd/4a/adea55f189a81aed88efa0b0e1d25628e5ed22622ab9174bf696dd4f9474/pocketsphinx-0.1.15.tar.gz
Building wheels for collected packages: pocketsphinx
Building wheel for pocketsphinx (setup.py) ... error
ERROR: Complete output from command /home/jandornhege/anaconda3
.....
deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:10: fatal error: pulse/pulseaudio.h: Datei oder Verzeichnis nicht gefunden
#include <pulse/pulseaudio.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pocketsphinx
Run Code Online (Sandbox Code Playgroud) (在我的 mac pro 上使用 ubuntu 16 0n。)
要集成 gstreamer 和 pocketsphinx,我需要三个 .pc 文件,如官方网站所述:
- gstreamer-1.0.pc
- gstreamer-base-1.0.pc
- gstreamer-plugins-base-1.0.pc
我启动一个新的空 ubuntu 18。通过安装 gstreamer
$ sudo apt-get install libgstreamer1.0-dev
Run Code Online (Sandbox Code Playgroud)
但在上一个命令之后,三个重要的 .pc 文件中仅存在两个。如果我 cd 到/usr/并运行:
sudo find . -print | grep -i 'gstreamer-plugins-base-1.0'
Run Code Online (Sandbox Code Playgroud)
终端返回空(未找到)。同时,
sudo find . -print | grep -i 'gstreamer-base-1.0'
和
sudo find . -print | grep -i 'gstreamer-1.0'
Run Code Online (Sandbox Code Playgroud)
会给我正确的路径。
丢失的gstreamer-plugins-base-1.0.pc文件在哪里?谢谢。
如果只有两个而不是三个.pc 文件,pocketsphinx 的配置将不起作用。
我有一个在 Alpine 发行版上运行的 docker 映像,为了让我的一个要求工作 - pocketsphinx==0.1.15,我必须在我的 DockerFile 中安装一些依赖项:
FROM python:3.7-alpine
RUN apk update && \
apk add --virtual build-deps gcc musl-dev && \
apk add --no-cache postgresql-dev && \
apk add ffmpeg && \
apk add swig && \
apk add libasound2-dev && \
rm -rf /var/cache/apk/*
Run Code Online (Sandbox Code Playgroud)
幸运的是, ffmpeg 和 swig 在 Alpine 软件包存储库中都可用,但不幸的是 libasound2-dev 不是。我试图避免从 Alpine 发行版迁移到 Ubuntu,但我不确定是否可以在 Alpine 映像上安装 libasound2-dev。有没有办法实现这一目标?谢谢!
pocketsphinx ×9
cmusphinx ×4
python ×2
alpine-linux ×1
anaconda ×1
apt-get ×1
docker ×1
gcc ×1
gstreamer ×1
linux-mint ×1
pip ×1
plugins ×1
python-3.x ×1
ubuntu ×1