ASRT语音识别系统 文档

录音小工具的使用
  • Last Edit by AI柠檬
  • 2020-08-29 20:35:18
GitHub用户:wkyo 提交的PR [录音小工具代码规范化与重命名](https://github.com/nl8590687/ASRT_SpeechRecognition/pull/211) ## 相关介绍 对录音小工具的代码进行了规范化,抽离出录音部分作为单独函数存在,并将实际录音操作放置到`__main__`中,支持手动设置录音参数。 ``` usage: speech_recorder.py [-h] [-d DURATION] [-r SAMPLING_RATE] [-b {8,16,24,32}] [-c CHANNELS] [output] Simple Wave Audio Recorder positional arguments: output audio file to store audio stream (default: output.wav) optional arguments: -h, --help show this help message and exit -d DURATION, --duration DURATION maximum duration in seconds (default: 10) -r SAMPLING_RATE, --sampling-rate SAMPLING_RATE sampling rate (default: 16000) -b {8,16,24,32}, --sampling-bits {8,16,24,32} sampling bits (default: 16) -c CHANNELS, --channels CHANNELS audio channels (default: 1) ``` 修改后的录音工具与原始工具兼容,默认最大录音时长10s,支持在录音过程中通过Ctrl-C提前结束录音。 使用样例: ``` $ python speech_recorder.py -b 32 -d 5 ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave Start to record with 5-seconds audio Type Ctrl-C to get an early stop (a shorter audio) ................................................^C -*- Early stop with 3 seconds Recording finished Convert PCM frames to WAV... OK ```