我在试着让Dejavu来处理覆盆子(覆盆子皮3)。我正在尝试将麦克风输入的音频与mysql数据库中的文件进行匹配。我已经测试过,可以用pyaudio录制,但是我需要设置sample rate=24000&CHUNK=4056。我几乎使用了Dejavu示例附带的默认代码。在
当我运行代码时,我得到以下错误:IOError:[Errno Invalid sample rate]-9997
有人对如何解决这个问题有什么建议吗?在
下面是我的Python代码:import warnings
import json
warnings.filterwarnings("ignore")
from dejavu import Dejavu
from dejavu.recognize import FileRecognizer, MicrophoneRecognizer
# load config from a JSON file (or anything outputting a python dictionary)
with open("dejavu.cnf.SAMPLE") as f:
config = json.load(f)
if __name__ == '__main__':
# create a Dejavu instance
djv = Dejavu(config)
# Or recognize audio from your microphone for `secs` seconds
secs = 5
song = djv.recognize(MicrophoneRecognizer, seconds=secs)
if song is None:
print "Nothing recognized -- did you play the song out loud so your mic could hear it? :)"
else:
print "From mic with %d seconds we recognized: %s\n" % (secs, song)
以下是来自终端的日志:
^{pr2}$