Ver código fonte

add male speech test

ming 3 anos atrás
pai
commit
a2824a1696
2 arquivos alterados com 23 adições e 1 exclusões
  1. 9 0
      OpenshotService/openshot_video_generator.py
  2. 14 1
      api/main.py

+ 9 - 0
OpenshotService/openshot_video_generator.py

@@ -788,7 +788,15 @@ def anchor_video_eng(name_hash,name,text_content, image_urls,sub_titles,avatar):
     print("video at : www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4")
     #line notifs
 
+import pyttsx3
+def make_speech(text):
+    engine = pyttsx3.init()
+    #voices = engine.getProperty('voices')
+    engine.setProperty('voice', 'Mandarin')
+    engine.save_to_file(text, '/app/speech.mp3')
+    engine.runAndWait()
 
+    
 class video_service(rpyc.Service):
     def exposed_call_video(self,name_hash,name,text_content, image_urls,multiLang,avatar):
         print('ML:'+str(multiLang))
@@ -798,6 +806,7 @@ class video_service(rpyc.Service):
     def exposed_call_video_gen(self,name_hash,name,text_content, image_urls,multiLang,avatar):
         print('ML:'+str(multiLang))#this is long video version,
         video_gen(name_hash,name,text_content, image_urls,multiLang,avatar)
+    def expose_make_speech(self,text):
 
 
 

+ 14 - 1
api/main.py

@@ -675,7 +675,20 @@ def gen_avatar(name_hash, imgurl):
         db['avatar_queue'].delete(id=works[0]['id'])
         statement = 'UPDATE avatar_service_status SET status = 0 WHERE id=1;'  #only one row in this table, which id 1 one
         db.query(statement)
-
+def call_voice(text):
+    c = rpyc.connect("localhost", 8868)
+    c._config['sync_request_timeout'] = None
+    remote_svc = c.root
+    my_answer = remote_svc.call_avatar(text) # method call
+    src_path = '/home/ming/AI_Anchor/OpenshotService/speech.mp3'
+    shutil.copy(src_path,'/home/ming/speech.mp3')
+    os.remove(src_path)
+    
+@app.get("/make_voice")
+async def make_voice(text):
+    x = threading.Thread(target=call_voice, args=(text))
+    x.start()
+