def speak(self, text):
syllables = lazy_pinyin(text, style=pypinyin.TONE3)
print(syllables)
delay = 0
def preprocess(syllables):
temp = []
for syllable in syllables:
for p in TextToSpeech.punctuation:
syllable = syllable.replace(p, "")
if syllable.isdigit():
syllable = atc.num2chinese(syllable)
new_sounds = lazy_pinyin(syllable, style=pypinyin.TONE3)
for e in new_sounds:
temp.append(e)
else:
temp.append(syllable)
return temp
syllables = preprocess(syllables)
for syllable in syllables:
path = "syllables/"+syllable+".wav"
_thread.start_new_thread(TextToSpeech._play_audio, (path, delay))
delay += 0.355
评论列表
文章目录