更新自强 支持TTS播报

This commit is contained in:
dahanzimin
2025-12-04 16:32:26 +08:00
parent cba45d0e2e
commit 9ee32c3c7e
5 changed files with 35 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
"""
SANT-TTS
MicroPython library for the SANT-TTS(暂行)
=======================================================
@dahanzimin From the Mixly Team
"""
import gc
from esp_tts import TTS
from machine import Pin
from pwm_audio import PWMAudio
from mixgo_sant import onboard_bot
audio = PWMAudio(Pin(46))
tts = TTS()
def paly(text, speed=3):
try:
onboard_bot.spk_en(1, 100)
if tts.parse_chinese(text):
audio.start()
while True:
data = tts.stream_play(speed)
if not data:
break
else:
audio.write(data)
finally:
onboard_bot.spk_en(0)
audio.stop()
gc.collect()