diff --git a/src/audio/mfcc/tune/setup_mfcc.m b/src/audio/mfcc/tune/setup_mfcc.m index 9ebc952e734c..95f3c8d24ccf 100644 --- a/src/audio/mfcc/tune/setup_mfcc.m +++ b/src/audio/mfcc/tune/setup_mfcc.m @@ -60,6 +60,17 @@ function setup_mfcc() setup.num_mel_bins = 40; setup.low_freq = 125; setup.high_freq = 7500; + setup.mel_log = 'log10'; + setup.top_db = 8.0; + setup.mmax_coef = 0; + setup.dynamic_mmax = true; + setup.remove_dc_offset = false; + setup.enable_vad = true; + setup.update_controls = true; + setup.pcan_strength = 0; + setup.pcan_offset = 0; + setup.pcan_gain_bits = 0; + setup.pcan_smoothing_coef = 0; setup.tplg_fn = 'mel40_10ms.conf'; export_mfcc_setup(gen_cfg, setup); @@ -77,6 +88,7 @@ function setup_mfcc() setup.enable_dtx = false; setup.dtx_trailing_silence_hops = 0; setup.dtx_silence_hops_interval = 0; + setup.comment = 'enable_vad=0 enable_dtx=0: streaming MWW must see every hop, and VAD is not run.'; setup.tplg_fn = 'mel40_10ms_compress.conf'; export_mfcc_setup(gen_cfg, setup); @@ -126,13 +138,43 @@ function setup_mfcc() setup.pcan_smoothing_coef = 819; setup.compress_output = true; setup.update_controls = false; - setup.enable_vad = false; + setup.enable_vad = true; setup.enable_dtx = false; setup.dtx_trailing_silence_hops = 0; setup.dtx_silence_hops_interval = 0; + setup.comment = ['enable_vad=1 enable_dtx=0 update_controls=0: VAD runs to populate energy/vad_flag\n' ... + '# for MWW gating; DTX off so every hop is still emitted; no kcontrol notifications.']; setup.tplg_fn = 'mel40_10ms_pcan_compress.conf'; export_mfcc_setup(gen_cfg, setup); + % 40 mel bins, 10 ms hop with soft AGC int8 output for microWakeWord, a + % light alternative to PCAN. The int8 range -1.0 .. +1.0 covers 50 dB of + % log10 Mel power below the AGC normalized peak. + setup = get_mel_spectrogram_config(); + setup.frame_length = 30.0; + setup.frame_shift = 10.0; + setup.num_mel_bins = 40; + setup.low_freq = 125; + setup.high_freq = 7500; + setup.mel_log = 'log10'; + setup.mel_offset = 0; + setup.mel_scale = 0.4; % 1.0 is 25 dB + setup.enable_agc8 = true; + setup.agc_target = 3.0; % allows +75 dB boost for quiet input + setup.agc_floor = -1.0; + setup.agc_release = 10066; % 3 dB/s at 100 hops/s + setup.agc_release_speech = 335; % 0.1 dB/s + setup.compress_output = true; + setup.update_controls = false; + setup.enable_vad = true; % slower AGC release in speech, vad_flag for MWW + setup.enable_dtx = false; + setup.dtx_trailing_silence_hops = 0; + setup.dtx_silence_hops_interval = 0; + setup.comment = ['enable_vad=1 enable_dtx=0 update_controls=0: VAD runs to populate energy/vad_flag\n' ... + '# for the AGC release and MWW gating; DTX off so every hop is still emitted.']; + setup.tplg_fn = 'mel40_10ms_agc8_compress.conf'; + export_mfcc_setup(gen_cfg, setup); + end function cfg = get_mfcc_default_config() @@ -181,6 +223,11 @@ function setup_mfcc() cfg.pcan_offset = 80.0; cfg.pcan_gain_bits = 21; cfg.pcan_smoothing_coef = 819; + cfg.enable_agc8 = false; + cfg.agc_target = 0; % 0 = default 0.25 + cfg.agc_floor = 0; % 0 = default -2.0 + cfg.agc_release = 0; % Q9.23 per hop, 0 = default 4194 + cfg.agc_release_speech = 0; % Q9.23 per hop, 0 = default 419 end function cfg = get_mel_spectrogram_config() @@ -229,6 +276,11 @@ function setup_mfcc() cfg.pcan_offset = 80.0; cfg.pcan_gain_bits = 21; cfg.pcan_smoothing_coef = 819; + cfg.enable_agc8 = false; + cfg.agc_target = 0; % 0 = default 0.25 + cfg.agc_floor = 0; % 0 = default -2.0 + cfg.agc_release = 0; % Q9.23 per hop, 0 = default 4194 + cfg.agc_release_speech = 0; % Q9.23 per hop, 0 = default 419 end function export_mfcc_setup(gen_cfg, cfg) @@ -266,8 +318,12 @@ function export_mfcc_setup(gen_cfg, cfg) v = cfg.dtx_trailing_silence_hops; [b8, j] = add_w16b(v, b8, j); % DTX trailing silence hops v = cfg.dtx_silence_hops_interval; [b8, j] = add_w16b(v, b8, j); % DTX silence frame interval v = cfg.pcan_smoothing_coef; [b8, j] = add_w32b(v, b8, j); % PCAN smoothing coef in Q14 +v = q_convert(cfg.agc_target, 7); [b8, j] = add_w16b(v, b8, j); % AGC8 target in Q8.7 +v = q_convert(cfg.agc_floor, 7); [b8, j] = add_w16b(v, b8, j); % AGC8 floor in Q8.7 +v = cfg.agc_release; [b8, j] = add_w16b(v, b8, j); % AGC8 release in Q9.23 +v = cfg.agc_release_speech; [b8, j] = add_w16b(v, b8, j); % AGC8 speech release in Q9.23 % Reserved -for i = 1:4 +for i = 1:2 [b8, j] = add_w32b(0, b8, j); end @@ -309,22 +365,25 @@ function export_mfcc_setup(gen_cfg, cfg) v = cfg.update_controls; [b8, j] = add_w8b(v, b8, j); % bool v = cfg.compress_output; [b8, j] = add_w8b(v, b8, j); % bool v = cfg.enable_pcan; [b8, j] = add_w8b(v, b8, j); % bool -% reserved_bool[3] -for i = 1:3 +v = cfg.enable_agc8; [b8, j] = add_w8b(v, b8, j); % bool +% reserved_bool[2] +for i = 1:2 [b8, j] = add_w8b(0, b8, j); end %% Export tplg_fn = [gen_cfg.mfcc_conf_path cfg.tplg_fn]; +howto = 'cd src/audio/mfcc/tune; octave setup_mfcc.m'; +if isfield(cfg, 'comment') + howto = sprintf('%s\n# %s', howto, sprintf(cfg.comment)); +end switch gen_cfg.tplg_ver case 1 sof_tplg_write(tplg_fn, b8, "DEF_MFCC_PRIV", ... - "Exported with script setup_mfcc.m", ... - "cd src/audio/mfcc/tune; octave setup_mfcc.m"); + "Exported with script setup_mfcc.m", howto); case 2 sof_tplg2_write(tplg_fn, b8, "mfcc_config", ... - "Exported MFCC configuration", ... - "cd src/audio/mfcc/tune; octave setup_mfcc.m"); + "Exported MFCC configuration", howto); otherwise error("Illegal tplg_ver, use 1 for topology v1 or 2 topology v2."); end diff --git a/src/audio/microwakeword/README.md b/src/audio/microwakeword/README.md index 040a595dac06..0932f9463127 100644 --- a/src/audio/microwakeword/README.md +++ b/src/audio/microwakeword/README.md @@ -191,7 +191,7 @@ The built-in models and the bytes control use the same model blob: `struct sof_m - the trigger threshold (Q0.8) and the number of averaged probabilities, so each model carries its own trigger tuning, - reserved words. -A bare TFLite flatbuffer without the header is still accepted and uses the default trigger settings `MWW_DETECT_THRESHOLD_Q8` and `MWW_DETECT_AVG_LEN`. +A bare TFLite flatbuffer without the header is still accepted and uses the default trigger settings `MWW_DETECT_THRESHOLD_Q8` and `MWW_DETECT_AVG_LEN`. The tune scripts `sof_mww_train_pcan.py` and `sof_mww_int8_state.py` emit the blobs with the header. --- diff --git a/src/audio/microwakeword/tune/README.md b/src/audio/microwakeword/tune/README.md index 8a524cb8ef2e..ac67a444fe8d 100644 --- a/src/audio/microwakeword/tune/README.md +++ b/src/audio/microwakeword/tune/README.md @@ -11,27 +11,21 @@ This directory contains offline scripts to train, quantize, verify, and export s - [sof_mww_generate_keyword_dataset_piper_tts.sh](sof_mww_generate_keyword_dataset_piper_tts.sh): Synthesizes positive keyword WAVs with single-speaker Piper TTS voices, pitch/tempo perturbation (via `sox`), Gaussian gain jitter, and Room Impulse Response (RIR) reverberation. - [sof_mww_generate_keyword_dataset.sh](sof_mww_generate_keyword_dataset.sh): Multi-speaker generation with `piper-sample-generator` (LibriTTS-R). - [sof_mww_prepare_silence_unknown.sh](sof_mww_prepare_silence_unknown.sh): Prepares negative dataset classes (`silence` and `unknown`) by slicing background noise and non-target words from Google Speech Commands v2. + - [sof_mww_prepare_common_voice.py](sof_mww_prepare_common_voice.py): Selects a repeatable set of Mozilla Common Voice (CC0) sentence clips from extracted language releases into a `speech` class of continuous speech negatives, with a per-speaker limit and a transcript exclusion regex for the keyword. Common Voice is downloaded from Mozilla Data Collective. + - [sof_mww_split_utterances.py](sof_mww_split_utterances.py): Splits recordings of a repeated keyword into one 48 kHz mono WAV per utterance. Speech is detected from the 100 - 7000 Hz band energy of 20 ms frames, and the room noise before and after each utterance is kept up to `--max-pad` and `--max-pad-after` seconds. Needs `scipy`. + - [sof_mww_anonymize_clips.py](sof_mww_anonymize_clips.py): Copies keyword clips to `