Package: rhasspy-silence
Rhasspy SilenceDetect speech/silence in voice commands withwebrtcvad.RequirementsPython 3.7webrtcvadInstallation$gitclonehttps://github.com/rhasspy/rhasspy-silence
$cdrhasspy-silence
$./configure
$make
$makeinstallHow it Worksrhasspy-silenceuses a state machine to decide when a voice command has started and stopped. The variables that control this machine are:skip_seconds- seconds of audio to skip before voice command detection startsspeech_seconds- seconds of speech before voice command has begunbefore_seconds- seconds of audio to keep before voice command has begunminimum_seconds- minimum length of voice command (seconds)maximum_seconds- maximum length of voice command before timeout (seconds, None for no timeout)silence_seconds- seconds of silence before a voice command has finishedThe sensitivity ofwebrtcvadis set withvad_mode, which is a value between 0 and 3 with 0 being the most sensitive.If there is no timeout, the final voice command audio will consist of:before_secondsworth of audio before the voice command had startedAt leastmin_secondsof audio during the voice commandEnergy-Based Silence DetectionBesides justwebrtcvad, silence detection using the denoised energy of the incoming audio is also supported. There are two energy-based methods:Threshold - simple threshold where energy above is considered speech and energy below is silenceMax/Current Ratio - ratio of maximum energy and current energy value is compared to a thresholdRatio below threshold is considered speech, ratio above is silenceMaximum energy value can be provided (static) or set from observed audio (dynamic)Both of the energy methods can be combined withwebrtcvad. When combined, audio is considered to be silence unlessbothmethods detect speech - i.e.,webrtcvadclassifies the audio chunk as speech and the energy value/ratio is above threshold. You can even combine all three methods usingSilenceMethod.ALL.Command Line InterfaceA CLI is included to test out the different parameters and silence detection methods. After installation, pipe raw 16-bit 16Khz mono audo to thebin/rhasspy-silencescript:$arecord-r16000-fS16_LE-c1-traw|bin/rhasspy-silence<ARGS>The characters printed to the console indicate howrhasspy-silenceis classifying audio frames:.- silence!- speechS- transition from silence to speech-- transition from speech to silence[- start of voice command]- end of voice commandT- timeoutBy changing the--output-typeargument, you can have the current audio energy or max/current ratio printed instead. These values can then be used to set threshold values for further testing.CLI Argumentsusage: 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