Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 语音到文本应用程序:实时计算麦克风中所说的特定单词数_Python 3.x_Python Sounddevice - Fatal编程技术网

Python 3.x 语音到文本应用程序:实时计算麦克风中所说的特定单词数

Python 3.x 语音到文本应用程序:实时计算麦克风中所说的特定单词数,python-3.x,python-sounddevice,Python 3.x,Python Sounddevice,假设您想编写一个python程序,计算麦克风中无限期出现多少个“嘿,Siri”或“嘿,Google” import sounddevice as sd import numpy # Make sure NumPy is loaded before it is used in the callback import heySiri_recognizer as hsr heySiri_counter =0 def callback(indata, outdata, frames, time, s

假设您想编写一个python程序,计算麦克风中无限期出现多少个“嘿,Siri”或“嘿,Google”

import sounddevice as sd
import numpy  # Make sure NumPy is loaded before it is used in the callback
import heySiri_recognizer as hsr

heySiri_counter =0
def callback(indata, outdata, frames, time, status):
    if status:
        print(status)
    if indata.hsr():
        heySiri_counter += 1
    outdata[:] = indata
try:
    with sd.Stream(device=(args.input_device, args.output_device),
                   samplerate=args.samplerate, blocksize=args.blocksize,
                   dtype=args.dtype, latency=args.latency,
                   channels=args.channels, callback=callback):
        print('#' * 80)
        print('press Return to quit')
        print('#' * 80)
        input()
        print(heySiri_counter)
except KeyboardInterrupt:
    parser.exit('')
except Exception as e:
    parser.exit(type(e).__name__ + ': ' + str(e))
在上面的代码中,如果您能帮助/评论我如何实现这一点(多线程、异步、块大小(音频缓冲区)等),以及假设的heySiri_识别器模块,我非常感谢