|
@@ -2,7 +2,6 @@ from fastapi import APIRouter
|
|
|
from pydantic import BaseModel
|
|
|
from gtts import gTTS
|
|
|
import ffmpy
|
|
|
-
|
|
|
import random
|
|
|
from typing import Optional
|
|
|
from fastapi.staticfiles import StaticFiles
|
|
@@ -27,6 +26,24 @@ dir_sound = ''
|
|
|
dir_anchor = ''
|
|
|
tool_dest = '/var/www/html/tools/'
|
|
|
|
|
|
+
|
|
|
+@app.post("/genAvatar_uploadmp3/")
|
|
|
+async def genAvatar_uploadmp3(file: UploadFile = File(...)):
|
|
|
+ name_hash = str(time.time()).replace('.','')
|
|
|
+
|
|
|
+ with open(dir_sound+name_hash+".mp3", "wb+") as file_object:
|
|
|
+ file_object.write(file.file.read())
|
|
|
+
|
|
|
+
|
|
|
+ x = threading.Thread(target=makeAvatar, args=(name_hash))
|
|
|
+ x.start()
|
|
|
+ return {'msg':'ok'}
|
|
|
+
|
|
|
+def makeAvatar(name_hash):
|
|
|
+ call_anchor(name_hash,17)
|
|
|
+ notify_choozmo('avatar at www.choozmo.com:8168/tools/'+name_hash+'.mp4')
|
|
|
+ os.remove(dir_sound+name_hash+".mp3")
|
|
|
+
|
|
|
@router.post("/get_material/", tags=["tools"])
|
|
|
async def get_material(text_in: text_in):
|
|
|
x = threading.Thread(target=memberOfQueue, args=(text_in.text,text_in.lang,text_in.avatar))
|
|
@@ -35,6 +52,7 @@ async def get_material(text_in: text_in):
|
|
|
|
|
|
def memberOfQueue(txt,lang,avatar):
|
|
|
q.put(compose(txt,lang,avatar))
|
|
|
+
|
|
|
|
|
|
def compose(txt,lang,avatar):
|
|
|
name_hash = str(time.time()).replace('.','')
|