33 lines
789 B
Python
33 lines
789 B
Python
"""
|
|
SOWL-TTS
|
|
|
|
MicroPython library for the SOWL-TTS(暂行)
|
|
=======================================================
|
|
@dahanzimin From the Mixly Team
|
|
"""
|
|
import gc,time
|
|
from esp_tts import TTS
|
|
from machine import Pin
|
|
from pdm_i2s import PDMTX
|
|
from mixgo_sowl import onboard_asr
|
|
|
|
audio = PDMTX(dout_pin=Pin(0), sample_rate=16000, buffer_size=1024)
|
|
tts = TTS()
|
|
|
|
def play(text, speed=3):
|
|
try:
|
|
onboard_asr.pa_ctrl(1, 100)
|
|
if tts.parse_chinese(text):
|
|
audio.start()
|
|
while True:
|
|
data = tts.stream_play(speed)
|
|
if not data:
|
|
break
|
|
else:
|
|
xx= audio.write(data)
|
|
#time.sleep(0.2)
|
|
finally:
|
|
onboard_asr.pa_ctrl(0)
|
|
audio.stop()
|
|
gc.collect()
|