Parcourir la source

上傳檔案到 'AI_anchor2'

oak il y a 2 ans
Parent
commit
2f5c4882ca
2 fichiers modifiés avec 13 ajouts et 6 suppressions
  1. 6 5
      AI_anchor2/main1.py
  2. 7 1
      AI_anchor2/main2.py

+ 6 - 5
AI_anchor2/main1.py

@@ -442,10 +442,10 @@ def srt_to_csv(srt_file):
     with open("output/csv_produce/test.csv", 'w', newline='',encoding="big5") as csvfile:
         # 建立 CSV 檔寫入器
         writer = csv.writer(csvfile)
-        j=0
+        writer.writerow(["序號","開始時間","結束時間","字幕內容"])
         for context in subs:
             writer.writerow([context.index, context.start,context.end, context.text])
-            j+=1
+            
     return 
 
 def csv_to_text(csv_file,text_font):
@@ -535,8 +535,9 @@ def vedio_to_csv(sound_file):
     srt_to_csv(sound_srt_file)
 
 if __name__ == '__main__':
-    down=text_to_short_vedio_create()
-    if down:
-        vedio_to_csv("output/no_captions/test.mp4")
+    # down=text_to_short_vedio_create()
+    # if down:
+    #     vedio_to_csv("output/no_captions/test.mp4")
+    vedio_to_csv("output/no_captions/test.mp4")
 	
     

+ 7 - 1
AI_anchor2/main2.py

@@ -130,14 +130,20 @@ def csv_to_text(csv_file,text_font):
         # 讀取 CSV 檔案內容
         rows = csv.reader(csvfile)
 
+        j=0
         # 以迴圈輸出每一列
         for row in rows:
+
+            if j==0:
+                j = 1
+                continue
+            
             start = datetime.strptime(row[1], "%H:%M:%S,%f")
             end = datetime.strptime(row[2], "%H:%M:%S,%f") - datetime.strptime(row[1], "%H:%M:%S,%f")
             end_timeStamp=end.seconds+0.000001*end.microseconds
             start_timeStamp=start.minute*60+start.second+ 0.000001*start.microsecond
             text_form.append({'text':row[3],'start':start_timeStamp,'end':end_timeStamp,'size':36,'font':text_font})
-    
+            
     return text_form
 def text_to_short_vedio(mp4_file ,sound_file,output_filename,text_font):
     t = openshot.Timeline(1280, 720, openshot.Fraction(30000, 1000), 44100, 2, openshot.LAYOUT_STEREO)