Browse Source

finish import issue

deployer 3 years ago
parent
commit
6c4e0bf860
1 changed files with 9 additions and 12 deletions
  1. 9 12
      api/routers/toolAvatarVoiceOnly.py

+ 9 - 12
api/routers/toolAvatarVoiceOnly.py

@@ -3,7 +3,7 @@ from pydantic import BaseModel
 from gtts import gTTS
 import ffmpy
 
-
+import random
 from typing import Optional
 from fastapi.staticfiles import StaticFiles
 from fastapi import FastAPI,File,Request,Response
@@ -26,22 +26,19 @@ dir_anchor = ''
 
 @router.post("/get_material/", tags=["tools"])
 async def read_users(text_in: text_in):
-    q.put(memberOfQueue(text_in))
-    x = threading.Thread(target=memberOfQueue, args=(text_in))
+    x = threading.Thread(target=memberOfQueue, args=(text_in.text,text_in.lang,text_in.avatar))
     x.start()
     return {'msg':'Pleas wait'}
 
-def memberOfQueue(text_in):
-    q.put(compose(text_in))
+def memberOfQueue(txt,lang,avatar):
+    q.put(compose(txt,lang,avatar))
 
-def compose(text_in):
+def compose(txt,lang,avatar):
     name_hash = str(time.time()).replace('.','')
-    makeMP3(name_hash,text_in)
-    call_anchor(name_hash,text_in.avatar)
+    makeMP3(name_hash,txt,lang)
+    call_anchor(name_hash,avatar)
 
-def makeMP3(name_hash,text_in):
-    lang = text_in.lang
-    txt = text_in.text
+def makeMP3(name_hash,txt,lang):
     if lang==0:
         tts = gTTS(txt)
         tts.save(dir_sound+name_hash+"raw.mp3")
@@ -90,4 +87,4 @@ def call_anchor(name_hash,avatar):
         else:
             break
     fr.close()
-    fw.close()
+    fw.close()