|
@@ -1,32 +1,21 @@
|
|
|
import pyttsx3
|
|
|
+
|
|
|
import rpyc
|
|
|
import random
|
|
|
import time
|
|
|
import codecs
|
|
|
import sys
|
|
|
import os
|
|
|
+from gtts import gTTS
|
|
|
+
|
|
|
fr=codecs.open('/tmp/script.txt','r','utf-8')
|
|
|
lines=fr.readlines()
|
|
|
fr.close()
|
|
|
txt=lines[0].strip()
|
|
|
|
|
|
-engine = pyttsx3.init()
|
|
|
-voices = engine.getProperty('voices')
|
|
|
-for v in voices:
|
|
|
- if 'Mandarin' in str(v.languages) or 'Mandarin' in v.id or 'Mandarin' in v.name:
|
|
|
- print(v.id)
|
|
|
- print(v.gender)
|
|
|
- print(v.name)
|
|
|
- print(v.age)
|
|
|
- print(str(v.languages))
|
|
|
-sys.exit()
|
|
|
-engine.setProperty('voice', voices[1].id)
|
|
|
-
|
|
|
-engine.setProperty('voice', 'zh')
|
|
|
-engine.setProperty('rate',175)
|
|
|
-engine.save_to_file(txt, '/tmp/ok2.mp3')
|
|
|
-
|
|
|
-engine.runAndWait()
|
|
|
+tts = gTTS(txt, lang='zh-tw')
|
|
|
+tts.save('/tmp/ok2.mp3')
|
|
|
+
|
|
|
|
|
|
|
|
|
val=random.randint(1000000,9999999)
|