|
@@ -10,9 +10,10 @@ from fastapi import FastAPI,File,Request,Response
|
|
|
import util,os, math, time
|
|
|
from pydantic import BaseModel
|
|
|
from fastapi.templating import Jinja2Templates
|
|
|
-import queue
|
|
|
+import queue, shutil
|
|
|
import threading
|
|
|
import rpyc
|
|
|
+import requests
|
|
|
|
|
|
q = queue.Queue()
|
|
|
router = APIRouter()
|
|
@@ -21,8 +22,10 @@ class text_in(BaseModel):
|
|
|
text: str
|
|
|
lang: int #0:eng 1:zh
|
|
|
avatar: int
|
|
|
+
|
|
|
dir_sound = ''
|
|
|
dir_anchor = ''
|
|
|
+tool_dest = '/var/www/html/tools/'
|
|
|
|
|
|
@router.post("/get_material/", tags=["tools"])
|
|
|
async def read_users(text_in: text_in):
|
|
@@ -37,6 +40,12 @@ def compose(txt,lang,avatar):
|
|
|
name_hash = str(time.time()).replace('.','')
|
|
|
makeMP3(name_hash,txt,lang)
|
|
|
call_anchor(name_hash,avatar)
|
|
|
+ shutil.copy(dir_sound+name_hash+".mp3",tool_dest+name_hash+'.mp3')
|
|
|
+ shutil.copy(dir_anchor+name_hash+".mp4",tool_dest+name_hash+'.mp4')
|
|
|
+ os.remove(dir_sound+name_hash+".mp3")
|
|
|
+ os.remove(dir_anchor+name_hash+".mp4")
|
|
|
+ notify_choozmo('sound at www.choozmo.com:8168/tools/'+name_hash+'.mp3')
|
|
|
+ notify_choozmo('avatar at www.choozmo.com:8168/tools.'+name_hash+'.mp4')
|
|
|
|
|
|
def makeMP3(name_hash,txt,lang):
|
|
|
if lang==0:
|
|
@@ -88,3 +97,11 @@ def call_anchor(name_hash,avatar):
|
|
|
break
|
|
|
fr.close()
|
|
|
fw.close()
|
|
|
+
|
|
|
+
|
|
|
+def notify_choozmo(msg):
|
|
|
+ #'WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD' is ChoozmoTeam
|
|
|
+ glist = ['WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD']
|
|
|
+ for gid in glist:
|
|
|
+ headers = {"Authorization": "Bearer " + gid,"Content-Type": "application/x-www-form-urlencoded"}
|
|
|
+ r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params={"message": msg})
|