Your Name 3 éve
szülő
commit
72e6b5694a
3 módosított fájl, 29 hozzáadás és 7 törlés
  1. 7 0
      apis/main.py
  2. 4 0
      tests/rds_test.py
  3. 18 7
      tests/zhtest.py

+ 7 - 0
apis/main.py

@@ -23,6 +23,13 @@ async def read_item(search_query: str = Form(...)):
     return {"item_id": "Please use Telegram to get notifications. "}
 
 
+
+@app.post("/tts")
+async def tts(search_query: str = Form(...)):
+    return {"item_id": "Please use Telegram to get notifications. "}
+
+
+
 @app.get("/")
 async def root():
     return {"message": "Hello World"}

+ 4 - 0
tests/rds_test.py

@@ -0,0 +1,4 @@
+import redis
+r = redis.Redis(host='db.ptt.cx', port=6379, db=1)
+r.set('foo', 'bar')
+print(r.get('foo'))

+ 18 - 7
tests/zhtest.py

@@ -1,10 +1,21 @@
 import zhtts
+import celery
+import string
+import random
+# export CUDA_VISIBLE_DEVICES=0 ; python3.7 train.py -content /tmp/demo.wav -style input/girl52.wav
+#py -3.7 save_mel.py --face a1.mp4 --audio eng1.mp3 --checkpoint_path wav2lip_gan.pth
+#export CUDA_VISIBLE_DEVICES=0 ; python3.7 save_mel.py --face nina.mp4 --audio /tmp/demo.wav --checkpoint_path wav2lip_gan.pth
+from celery import Celery
 
-text = """
-防疫時期,機場旅客通常入境後都不想在機場排隊等專車、增加接觸人群被傳染的風險,在這情況下您可以選擇全台灣最安心的機場接送品牌。肯驛。它是日本計程車 MK 公司在台灣的指定合作廠商。
-提供乘客最專業且貼心的機場接送服務,可以為有幼兒的父母增加嬰幼兒汽座椅、提供寵物共乘等多樣化客製服務,外國旅客可以透過網頁預約接送,就算沒有台灣手機號碼,或人在國外收不到驗證碼簡訊,都能使用叫車吧
-為了應變新冠病毒影響班機航班,提供 6 小時前致電客服免費取消預約的服務。司機會在每趟服務前、後使用酒精消毒車內及車門把手,全程配戴口罩,手機安裝台灣社交距離軟體,每天自我健康監測。車上支援數位行動支付,減去付款接觸時的感染風險,全程落實防疫守則,讓乘客安心乘車。
-"""
+app = Celery('tasks', broker='redis://db.ptt.cx/0')
 
-tts = zhtts.TTS() # use fastspeech2 by default
-tts.text2wav(text, "/tmp/demo.wav")
+@app.task
+def to_wav(txt):
+    letters = string.digits
+    rstr= ''.join(random.choice(letters) for i in range(10))
+    #text2mel_name="TACOTRON"
+    tts = zhtts.TTS() # use fastspeech2 by default
+    #tts = zhtts.TTS(text2mel_name="TACOTRON") # use fastspeech2 by default
+
+    tts.text2wav(txt, "/var/wav/'+rstr+'.wav")
+    return rstr