跳转到主要内容

未提供项目描述

项目描述

Rhasspy Silence

Continuous Integration GitHub license

使用webrtcvad检测语音命令中的语音/静音。

要求

安装

$ git clone https://github.com/rhasspy/rhasspy-silence
$ cd rhasspy-silence
$ ./configure
$ make
$ make install

工作原理

rhasspy-silence 使用状态机来决定何时开始和结束语音命令。控制这个机器的变量有

  • skip_seconds - 在语音命令检测开始前要跳过的音频秒数
  • speech_seconds - 语音命令开始前的语音秒数
  • before_seconds - 语音命令开始前的音频秒数
  • minimum_seconds - 语音命令的最小长度(秒)
  • maximum_seconds - 语音命令超时前的最大长度(秒,None表示无超时)
  • silence_seconds - 语音命令完成后前的静音秒数

webrtcvad的灵敏度通过vad_mode设置,其值介于0到3之间,0为最灵敏。

State machine diagram for silence detection

如果没有超时,最终的语音命令音频将包括

  • 语音命令开始前的before_seconds音频
  • 至少min_seconds的语音命令音频

基于能量的静音检测

除了webrtcvad之外,还支持使用传入音频的降噪能量进行静音检测。有两种基于能量的方法

  • 阈值 - 简单的阈值,能量高于阈值的认为是语音,低于的是静音
  • 最大/当前比率 - 比较最大能量和当前能量值与阈值
    • 低于阈值的比率认为是语音,高于的是静音
    • 可以提供(静态)或从观察到的音频(动态)设置最大能量值

两种能量方法都可以与 webrtcvad 结合使用。结合使用时,除非 两种方法都检测到语音,否则音频被视为静音,即 webrtcvad 将音频片段分类为语音,能量值/比率高于阈值。您甚至可以使用 SilenceMethod.ALL 结合所有三种方法。

命令行界面

包含了一个命令行界面(CLI),用于测试不同的参数和静音检测方法。安装后,将原始16位16KHz单声道音频通过管道传输到 bin/rhasspy-silence 脚本。

$ arecord -r 16000 -f S16_LE -c 1 -t raw | bin/rhasspy-silence <ARGS>

打印到控制台的字符表示 rhasspy-silence 如何分类音频帧。

  • . - 静音
  • ! - 语音
  • S - 从静音到语音的转换
  • - - 从语音到静音的转换
  • [ - 语音命令开始
  • ] - 语音命令结束
  • T - 超时

通过更改 --output-type 参数,您可以打印当前音频能量或最大/当前比率。然后可以使用这些值来设置阈值以进行进一步测试。

CLI 参数

usage: rhasspy-silence [-h]
                       [--output-type {speech_silence,current_energy,max_current_ratio}]
                       [--chunk-size CHUNK_SIZE] [--skip-seconds SKIP_SECONDS]
                       [--max-seconds MAX_SECONDS] [--min-seconds MIN_SECONDS]
                       [--speech-seconds SPEECH_SECONDS]
                       [--silence-seconds SILENCE_SECONDS]
                       [--before-seconds BEFORE_SECONDS]
                       [--sensitivity {1,2,3}]
                       [--current-threshold CURRENT_THRESHOLD]
                       [--max-energy MAX_ENERGY]
                       [--max-current-ratio-threshold MAX_CURRENT_RATIO_THRESHOLD]
                       [--silence-method {vad_only,ratio_only,current_only,vad_and_ratio,vad_and_current,all}]
                       [--debug]

optional arguments:
  -h, --help            show this help message and exit
  --output-type {speech_silence,current_energy,max_current_ratio}
                        Type of printed output
  --chunk-size CHUNK_SIZE
                        Size of audio chunks. Must be 10, 20, or 30 ms for
                        VAD.
  --skip-seconds SKIP_SECONDS
                        Seconds of audio to skip before a voice command
  --max-seconds MAX_SECONDS
                        Maximum number of seconds for a voice command
  --min-seconds MIN_SECONDS
                        Minimum number of seconds for a voice command
  --speech-seconds SPEECH_SECONDS
                        Consecutive seconds of speech before start
  --silence-seconds SILENCE_SECONDS
                        Consecutive seconds of silence before stop
  --before-seconds BEFORE_SECONDS
                        Seconds to record before start
  --sensitivity {1,2,3}
                        VAD sensitivity (1-3)
  --current-threshold CURRENT_THRESHOLD
                        Debiased energy threshold of current audio frame
  --max-energy MAX_ENERGY
                        Fixed maximum energy for ratio calculation (default:
                        observed)
  --max-current-ratio-threshold MAX_CURRENT_RATIO_THRESHOLD
                        Threshold of ratio between max energy and current
                        audio frame
  --silence-method {vad_only,ratio_only,current_only,vad_and_ratio,vad_and_current,all}
                        Method for detecting silence
  --debug               Print DEBUG messages to the console

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面