ming 3 年 前
コミット
5d2783f38d
2 ファイル変更41 行追加0 行削除
  1. BIN
      AI_anchor_API.docx
  2. 41 0
      api/main.py

BIN
AI_anchor_API.docx


+ 41 - 0
api/main.py

@@ -998,6 +998,47 @@ async def make_voice(in_text:text_in):
     x = threading.Thread(target=call_voice, args=(in_text.text,))
     x.start()
 
+def call_speech(text):
+    conn = rpyc.classic.connect("192.168.1.105",18812)
+    ros = conn.modules.os
+    fr=open(dir_sound+fileName+".mp3",'rb')# voice
+    #warning!!!    file my be replaced by other process
+    fw=conn.builtins.open('/tmp/output.mp3','wb')
+
+    while True:
+        b=fr.read(1024)
+        if b:
+            fw.write(b)
+        else:
+            break
+
+    fr.close()
+    fw.close()
+
+    val=random.randint(1000000,9999999)
+    ros.chdir('/home/jared/to_video')
+    ros.system('./p'+str(avatar)+'.sh '+str(val)+' &')
+
+    while True:
+        print('waiting...')
+        if ros.path.exists('/tmp/results/'+str(val)):
+            break
+        time.sleep(5)
+        print('waiting...')
+
+    fr=conn.builtins.open('/tmp/results/'+str(val)+'.mp4','rb')
+    fw=open(dir_anchor+fileName+".mp4",'wb')
+    while True:
+        b=fr.read(1024)
+        if b:
+            fw.write(b)
+        else:
+            break
+
+    fr.close()
+    fw.close()
+
+
 def verify_jwt_token(token):
     for row in db.query('SELECT * FROM jwt_black_list'):
         print(row)