注意:有关我的设置(python版本,模块等)的所有详细信息都列在问题的底部.
如果这个问题是公然的,请提前道歉,但我已经和它摔跤了好几天了.希望有人可以提供一些新的亮点.
我正在从unittest- > 转换我的个人项目的单元测试pytest.以前我使用的是内置unittest.mock模块,但现在我正在尝试使用pytest-mock插件.
我有一种偷偷摸摸的感觉,我的测试是将模拟对象泄漏到彼此中.
原因如下:
高级细节:
# Python version
Python 3.5.2
# Pytest version ( and plugins )
pytest==3.0.7
pytest-benchmark==3.1.0a2
pytest-catchlog==1.2.2
pytest-cov==2.4.0
pytest-ipdb==0.1.dev2
pytest-leaks==0.2.2
pytest-mock==1.6.0
pytest-rerunfailures==2.1.0
pytest-sugar==0.8.0
pytest-timeout==1.2.0
python-dateutil==2.6.0
python-dbusmock==0.16.7
Run Code Online (Sandbox Code Playgroud)
当我使用以下命令运行我的测试时:
py.test --pdb --showlocals -v -R : -k test_subprocess.py
一切都很好,直到我们到达test_subprocess_check_command_type.此时我收到以下错误:
# Set mock return types
# mock_map_type_to_command.return_value = int
# action
with pytest.raises(TypeError) as excinfo:
scarlett_os.subprocess.Subprocess(test_command,
name=test_name,
fork=test_fork,
> run_check_command=True)
E Failed: DID NOT RAISE <class 'TypeError'>
excinfo …Run Code Online (Sandbox Code Playgroud) 刚刚在我的覆盆子pi上安装了pocketsphinx.我觉得我疯了但不确定我是否提供了正确的设备.
每当我跑:
src/programs/pocketsphinx_continuous -adcdev plughw:1,0 -nfft 2048 -samprate 48000
我得到以下内容:
root @ scarlettpi:/usr/install/pocketsphinx-0.8#src/programs/pocketsphinx_continuous -adcdev plughw:1,0 -nfft 2048 -samprate 48000 INFO:cmd_ln.c(691):解析命令行:/ usr/install/pocketsphinx -0.8/src/programs/.libs/lt-pocketsphinx_continuous\-adcdev plughw:1,0\-nfft 2048\-samprate 48000
当前配置:[NAME] [DEFLT] [VALUE] -adcdev plughw:1,0 -agc无无-agcthresh 2.0 2.000000e + 00 -alpha 0.97 9.700000e-01 -argfile
-ascale 20.0 2.000000e + 01 -aw 1 1 -backtrace无无-beam 1E-48 1.000000e-48 -bestpath是是-bestpathlw 9.5 9.500000e + 00 -bghist无无-ceplen 13 13 -cmn当前电流-cmninit 8.0 8.0 -compallsen无无-debug 0 -dict
- dictcase无无-dither无无-doublebw无无-ds 1 1 -fdict
-feat 1s_c_d_dd 1s_c_d_dd -featparams
-fillprob 1E-8 1.000000e-08 -frate 100 100 -fsg …
audio speech-recognition speech-to-text cmusphinx raspberry-pi
因此,蟒蛇的表现就像是从我的麦克风根本听不到任何东西.
这是问题所在.我有一个Python(2.7)脚本,假设使用Gstreamer访问我的麦克风并通过Pocketsphinx为我做语音识别.我正在使用Pulse Audio,而我的设备是Raspberry Pi.我的麦克风是Playstation 3 Eye.
现在,我已经获得了pocketphinx_continuous以正确运行并识别我在.dict和.lm文件中定义的单词.经过几次试运行后,准确度大约为85-90%.所以,我知道我的麦克风通常通过pocketsphinx +脉冲音频拾取声音.
仅供参考我执行以下操作:
pocketsphinx_continuous -lm /home/pi/dev/scarlettPi/config/speech/lm/scarlett.lm -dict /home/pi/dev/scarlettPi/config/speech/dict/scarlett.dic -hmm /home/pi/dev/scarlettPi/config/speech/model/hmm/en_US/hub4wsj_sc_8k -silprob 0.1 -wip 1e-4 -bestpath 0
Run Code Online (Sandbox Code Playgroud)
在我的python代码中,我试图做同样的事情,但我正在使用gstreamer访问python中的麦克风.(注意:我对Python有点新鲜)
这是我的代码(感谢Josip Lisec让我这么远):
import pi
from pi.becore import ScarlettConfig
from recorder import Recorder
from brain import Brain
import os
import json
import tempfile
#import sys
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import pygst
pygst.require('0.10')
gobject.threads_init()
import gst
scarlett_config=ScarlettConfig()
class Listener:
def __init__(self, gobject, gst):
self.failed …Run Code Online (Sandbox Code Playgroud) cmusphinx ×2
python ×2
audio ×1
gstreamer ×1
pulseaudio ×1
pytest ×1
python-3.5 ×1
python-3.x ×1
raspberry-pi ×1
unit-testing ×1