PyAudio 录音直到退出

PyAudio Record until exit

我对 Pyaudio 的了解不够,在网上找不到它。我想要脚本 运行 直到我停止它,当我停止时,它必须保存记录。 Pyaudio 中的示例代码记录固定时间。

您需要做的是在遇到键盘异常时使用错误处理来保存音频,(在这种情况下,按 Ctrl + C 之类的东西结束程序。

While True:
    try:
        recording_function()

    except KeyboardInterrupt:
        save_function() #record to a file
    except: 
        #generic error processing