|
1 | 1 | use std::sync::{LazyLock, Mutex}; |
2 | 2 |
|
3 | | -use speexdsp::preprocess::{SpeexPreprocess, SpeexPreprocessConst}; |
| 3 | +use speexdsp::preprocess::SpeexPreprocess; |
4 | 4 |
|
5 | 5 | use crate::audio::AudioProcessParams; |
6 | 6 |
|
@@ -60,48 +60,18 @@ pub fn process_speex_f32_stream( |
60 | 60 | let mut st = |
61 | 61 | SpeexPreprocess::new(FRAME_SIZE, SPEEXDSP_SAMPLE_RATE as usize).unwrap(); |
62 | 62 |
|
63 | | - st.preprocess_ctl( |
64 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_DENOISE, |
65 | | - if config.is_speex_denoise_enabled() { |
66 | | - 1 |
67 | | - } else { |
68 | | - 0 |
69 | | - }, |
70 | | - ) |
71 | | - .unwrap(); |
72 | | - |
| 63 | + st.set_denoise(config.is_speex_denoise_enabled()); |
73 | 64 | st.set_noise_suppress(config.speex_noise_suppress); |
74 | 65 |
|
75 | | - st.preprocess_ctl( |
76 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_VAD, |
77 | | - if config.speex_vad_enabled { 1 } else { 0 }, |
78 | | - ) |
79 | | - .unwrap(); |
80 | | - st.preprocess_ctl( |
81 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_PROB_START, |
82 | | - config.speex_vad_threshold, |
83 | | - ) |
84 | | - .unwrap(); |
85 | | - st.preprocess_ctl( |
86 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_AGC, |
87 | | - if config.speex_agc_enabled { 1 } else { 0 }, |
88 | | - ) |
89 | | - .unwrap(); |
90 | | - st.preprocess_ctl( |
91 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_AGC_TARGET, |
92 | | - config.speex_agc_target, |
93 | | - ) |
94 | | - .unwrap(); |
95 | | - st.preprocess_ctl( |
96 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_DEREVERB, |
97 | | - if config.speex_dereverb_enabled { 1 } else { 0 }, |
98 | | - ) |
99 | | - .unwrap(); |
100 | | - st.preprocess_ctl( |
101 | | - SpeexPreprocessConst::SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, |
102 | | - config.speex_dereverb_level, |
103 | | - ) |
104 | | - .unwrap(); |
| 66 | + st.set_vad(config.speex_vad_enabled); |
| 67 | + st.set_prob_start(config.speex_vad_threshold); |
| 68 | + |
| 69 | + st.set_agc(config.speex_agc_enabled); |
| 70 | + st.set_agc_target(config.speex_agc_target); |
| 71 | + |
| 72 | + st.set_dereverb(config.speex_dereverb_enabled); |
| 73 | + st.set_dereverb_level(config.speex_dereverb_level); |
| 74 | + |
105 | 75 | st |
106 | 76 | }) |
107 | 77 | .collect(), |
|
0 commit comments