Your Name 3 gadi atpakaļ
vecāks
revīzija
aceba0d3f0
6 mainītis faili ar 234 papildinājumiem un 0 dzēšanām
  1. 11 0
      tests/chi_tts.py
  2. 79 0
      tests/congress.py
  3. 55 0
      tests/fonttest.py
  4. 11 0
      tests/rosa_test.py
  5. 73 0
      tests/testtts.py
  6. 5 0
      tests/tts2.py

+ 11 - 0
tests/chi_tts.py

@@ -0,0 +1,11 @@
+import rpyc
+import random
+import time
+import codecs
+import sys
+import os
+from gtts import gTTS
+
+tts = gTTS('你好我是立法委員', lang='zh-CN')
+
+tts.save('c:/tmp/ok2.mp3')

+ 79 - 0
tests/congress.py

@@ -0,0 +1,79 @@
+import pyttsx3
+import rpyc
+import random
+import time
+#conn = rpyc.classic.connect("192.168.1.110",18812)
+conn = rpyc.classic.connect("192.168.192.134",18812)
+
+
+ros = conn.modules.os 
+rsys = conn.modules.sys 
+
+
+fr=open('c:/video/congress.mp3','rb')
+fw=conn.builtins.open('/tmp/ok2.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/Wav2Lip-master')
+#ros.system('./proc.sh '+str(val)+' &')
+ros.system('./p2.sh '+str(val)+' &')
+
+
+while True:
+    print('waiting...')
+    if ros.path.exists('/tmp/results/'+str(val)):
+        break
+    time.sleep(5)
+    print('waiting...')
+
+
+
+ros.system('cp /home/jared/Wav2Lip-master/results/result_voice.mp4 /tmp')
+
+#ros.chdir('/home/jared/tests/libopenshot')
+#ros.system('python3 jaredtest.py')
+
+#ros.system('cp /tmp/out.mp4 /var/www/html/out.mp4')
+#
+#ros.system('telegram-send "video is ready, http://139.162.121.30:54321/out.mp4"')
+
+
+fr=conn.builtins.open('/home/jared/Wav2Lip-master/results/result_voice.mp4','rb')
+#fr=conn.builtins.open('/tmp/out.mp4','rb')
+
+fw=open('c:/video/result.mp4','wb')
+while True:
+    b=fr.read(1024)
+    if b:
+        fw.write(b)
+    else:
+        break
+
+fr.close()
+fw.close()
+
+
+
+#fr=conn.builtins.open('/home/jared/Wav2Lip-master/results/result_voice.mp4','rb')
+#fr=conn.builtins.open('/tmp/out.mp4','rb')
+
+#fw=open('result.mp4','wb')
+#while True:
+#    b=fr.read(1024)
+#    if b:
+#        fw.write(b)
+#    else:
+#        break
+
+#fr.close()
+#fw.close()

+ 55 - 0
tests/fonttest.py

@@ -0,0 +1,55 @@
+from PIL import Image,ImageDraw,ImageFont
+
+# sample text and font
+unicode_text = "中文測是..."
+#font = ImageFont.truetype("c:/portable/fonts/adv.ttf", 28, encoding="unic")
+#font = ImageFont.truetype("c:/portable/fonts/adv.ttf", 28,encoding='utf-8')
+#font = ImageFont.truetype("c:/portable/fonts/adv.ttf", 28,encoding='big5')
+#font = ImageFont.truetype("c:/portable/fonts/adv.ttf", 28,encoding='uni')
+
+#print(font)
+#print(font.)
+font = ImageFont.truetype("c:/portable/fonts/華康綜藝體.ttf", 40,encoding='big5')
+#font = ImageFont.truetype("c:/portable/fonts/華康綜藝體.ttf", 28,encoding='uni')
+#font = ImageFont.truetype("c:/portable/fonts/華康綜藝體.ttf", 28)
+
+#font = ImageFont.truetype("c:/windows/fonts/kaiu.ttf", 28,encoding='utf-8')
+
+# get the line size
+text_width, text_height = font.getsize(unicode_text)
+
+# create a blank canvas with extra space between lines
+canvas = Image.new('RGB', ( 500, 500), "orange")
+
+# draw the text onto the text canvas, and use black as the text color
+draw = ImageDraw.Draw(canvas)
+#text=u'距離除夕夜'
+#text = "\u9E9E"
+#text="\ufa53"
+#text = "\u4E2D\u6587"
+#u = u'\u6211'
+#text=u.encode('big5')
+text=u'\ua7da'
+#text=u"測試"
+#b_str = text.encode('big5')
+#b_str = b_str.decode('big5')
+
+
+
+
+
+def myunichchar(unicode_char):
+    mb_string = unicode_char.encode('big5')
+    try:
+        unicode_char = unichr(ord(mb_string[0]) << 8 | ord(mb_string[1]))
+    except NameError:
+        unicode_char = chr(mb_string[0] << 8 | mb_string[1])
+    return unicode_char
+
+
+text=myunichchar('中')+myunichchar('文')
+draw.text((5,5), text, 'blue', font)
+
+# save the blank canvas to a file
+canvas.save("unicode-text.png", "PNG")
+canvas.show()

+ 11 - 0
tests/rosa_test.py

@@ -0,0 +1,11 @@
+import librosa
+import soundfile as sf
+import numpy as np
+
+y, sr = librosa.load('c:/tmp/source.wav', sr=44100) # y is a numpy array of the wav file, sr = sample rate
+y_shifted = librosa.effects.pitch_shift(y, sr, n_steps=0) # shifted by 4 half steps
+#librosa.write_wav('c:/tmp/test.wav', y_shifted, sr)
+
+
+# Write out audio as 24bit PCM WAV
+sf.write('c:/tmp/test.wav', y_shifted, sr, subtype='PCM_24')

+ 73 - 0
tests/testtts.py

@@ -0,0 +1,73 @@
+import pyttsx3
+import rpyc
+import random
+import time
+#conn = rpyc.classic.connect("192.168.1.110",18812)
+conn = rpyc.classic.connect("192.168.192.134",18812)
+
+
+ros = conn.modules.os 
+rsys = conn.modules.sys 
+
+
+
+engine = pyttsx3.init()
+#engine.say("I will speak this text")
+#engine.save_to_file("中文測試,我會講中文", 'test.mp3')
+engine.setProperty('rate',175)
+
+#engine.save_to_file("你好,我是,集仕多股份有限公司,開發的,人工智慧主播。", 'test.mp3')
+engine.save_to_file("我們和幸福空間合作,全自動的方式,產生人工智慧影片。集仕多股份有限公司團隊製作。", 'test.mp3')
+
+engine.runAndWait()
+
+
+
+fr=open('test.mp3','rb')
+fw=conn.builtins.open('/tmp/ok2.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/Wav2Lip-master')
+ros.system('./proc.sh '+str(val)+' &')
+
+
+while True:
+    print('waiting...')
+    if ros.path.exists('/tmp/results/'+str(val)):
+        break
+    time.sleep(5)
+    print('waiting...')
+
+
+
+ros.system('cp /home/jared/Wav2Lip-master/results/result_voice.mp4 /tmp')
+ros.chdir('/home/jared/tests/libopenshot')
+ros.system('python3 jaredtest.py')
+
+ros.system('cp /tmp/out.mp4 /var/www/html/out.mp4')
+
+ros.system('telegram-send "video is ready, http://139.162.121.30:54321/out.mp4"')
+
+#fr=conn.builtins.open('/home/jared/Wav2Lip-master/results/result_voice.mp4','rb')
+fr=conn.builtins.open('/tmp/out.mp4','rb')
+
+fw=open('result.mp4','wb')
+while True:
+    b=fr.read(1024)
+    if b:
+        fw.write(b)
+    else:
+        break
+
+fr.close()
+fw.close()

+ 5 - 0
tests/tts2.py

@@ -4,11 +4,16 @@ import random
 import time
 
 import sys
+import codecs
 
 engine = pyttsx3.init()
 #engine.say("I will speak this text")
 #engine.save_to_file("中文測試,我會講中文", 'test.mp3')
 engine.setProperty('rate',175)
+
+fr=codecs.open('/tmp/script.txt','r','u-tf8')
+lines=fr.readlines()
+fr.close()
 engine.say("你好,我是,集仕多股份有限公司,開發的,人工智慧主播,這是一個測試影片。我們與幸福空間合作,只要給我們影片的腳本文字檔案,我們立刻可以產生影片。", 'test.mp3')
 
 engine.runAndWait()