更新自强 支持TTS播报
This commit is contained in:
Binary file not shown.
@@ -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()
|
||||
Reference in New Issue
Block a user