mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2445 from openmv/ml_gain
libraries/ml/ml/apps: Allow passing gain to audio init.
This commit is contained in:
commit
1f22d4fce7
@ -46,7 +46,7 @@ class MicroSpeech:
|
||||
_CATEGORY_COUNT = const(4)
|
||||
_AVERAGE_WINDOW_SAMPLES = const(1020 // _SLICE_TIME_MS)
|
||||
|
||||
def __init__(self, preprocessor=None, micro_speech=None, labels=None):
|
||||
def __init__(self, preprocessor=None, micro_speech=None, labels=None, gain_db=24):
|
||||
self.preprocessor = preprocessor
|
||||
if preprocessor is None:
|
||||
self.preprocessor = Model("audio_preprocessor")
|
||||
@ -59,7 +59,7 @@ class MicroSpeech:
|
||||
self.spectrogram = np.zeros((1, _SLICE_COUNT * _SLICE_SIZE), dtype=np.int8)
|
||||
self.pred_history = np.zeros((_AVERAGE_WINDOW_SAMPLES, _CATEGORY_COUNT), dtype=np.float)
|
||||
self.audio_started = False
|
||||
audio.init(channels=1, frequency=_AUDIO_FREQUENCY, gain_db=24, samples=_SAMPLES_PER_STEP * 2)
|
||||
audio.init(channels=1, frequency=_AUDIO_FREQUENCY, gain_db=gain_db, samples=_SAMPLES_PER_STEP * 2)
|
||||
|
||||
def audio_callback(self, buf):
|
||||
# Roll the audio buffer to the left, and add the new samples.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user