增加TVOC检测库,修复ASR声音采集

This commit is contained in:
dahanzimin
2025-06-03 17:51:27 +08:00
parent be654a5874
commit e799b7491c
3 changed files with 48 additions and 3 deletions

View File

@@ -104,3 +104,7 @@ class AI:
self._ai.delete(_id)
else:
raise AttributeError('This model can only run face recognition')
def stop(self):
if self._ai is not None:
self._ai.stop()

View File

@@ -156,9 +156,11 @@ class LED:
onboard_led = LED(onboard_bot.led_pwm)
class Voice_Energy:
def read(self):
_dat = onboard_asr._rreg(0x08, 3) #在语音识别里获取
return (_dat[0] | _dat[1] << 8) // 10
def read(self, samples=10):
values = []
for _ in range(samples):
values.append(int.from_bytes(onboard_asr._rreg(0x08, 3)[:2], 'little')) #在语音识别里获取
return sorted(values)[samples // 2]
onboard_sound = Voice_Energy()