覆盆子Python wit.ai使用

时间:2015-01-22 07:15:54

标签: python raspberry-pi wit.ai

我已经在我的树莓上安装了wip,但是当我想使用它时,我收到了这个错误

[wit] initialized sox: 14.4.0    
[wit] init state machine
[wit] initialized with device: default    
[wit] ready. state=idle    
formats: can't open input  `default': snd_pcm_open error: No such file or directory
[wit] couldn't open input device using alsa. Trying with coreaudio...
formats: no handler for given file type `coreaudio'    
[wit] Failed to open input device    
task '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value',
/home/martin/rust/src/libcore/option.rs:357

2 个答案:

答案 0 :(得分:3)

修改~/.asoundrc并添加以下内容:

pcm.!default {
    type asym
    playback.pcm {
        type plug
        slave.pcm "hw:0,0"
    }
    capture.pcm {
        type plug
        slave.pcm "hw:1,0"
    } 
}
  

这个小ALSA配置设置使用默认声卡作为播放设备(hw:0,0)并将hw:1,0(假设是您的USB麦克风)设置为默认捕获设备。

(取自http://wiki.audacityteam.org/wiki/USB_mic_on_Linux下的&#34;设置默认录制设备&#34;。)

要确定在slave.pcm之后应该写什么,请运行以下命令:

aplay -l
arecord -l

结果将分别指出playback.pcmcapture.pcm下的内容。

例如,arecord -l会在我的机器上产生以下输出:

**** List of CAPTURE Hardware Devices ****
card 1: USBSA [Andrea PureAudio USB-SA], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

slave.cpm旁边的文字应为"hw:X,Y",其中X和Y取自上面输出的第二行:

card X: ..., device Y: ...

答案 1 :(得分:1)

以上更正。需要编辑〜/ .asoundrc

请注意文件名中的“a”。

pcm.!default {
    type asym
    playback.pcm {
        type plug
        slave.pcm "hw:0,0"
    }
    capture.pcm {
        type plug
        slave.pcm "hw:1,0"
    } 
}