File size: 1,578 Bytes
b6093b0 8cdcb92 d63a8c1 8cdcb92 b6093b0 8cdcb92 b6093b0 2dcfc88 9876d02 b6093b0 9e23844 8cdcb92 d0c0836 5d7177a 2b0ce36 6c68a13 b6093b0 9876d02 6c68a13 d0c0836 6c68a13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
from utils.transcriber import transcriber
from utils.subtitler import subtitler
import logging, os
# Set up logging
logging.basicConfig(filename='main.log',
encoding='utf-8',
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
# API Function
def process_video(invideo_filename:str,
srt_path: str,
task: str,
max_words_per_line:int,
fontsize:str,
font:str,
bg_color:str,
text_color:str,
caption_mode:str,
config_file:str
):
invideo_filename = os.path.normpath(invideo_filename)
invideo_path_parts = invideo_filename.split(os.path.sep)
VIDEO_NAME = invideo_path_parts[-1]
OUTVIDEO_PATH = os.path.join(invideo_path_parts[-3], invideo_path_parts[-2], f"result_{VIDEO_NAME}")
if srt_path:
subtitler(invideo_filename, srt_path, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, caption_mode)
return OUTVIDEO_PATH, srt_path
SRT_PATH = os.path.abspath(f"{invideo_filename.split('.')[0]}.srt")
logging.info("Transcribing...")
if not os.path.exists(SRT_PATH):
transcriber(invideo_filename, SRT_PATH, max_words_per_line, task, config_file)
logging.info("Subtitling...")
subtitler(invideo_filename, SRT_PATH, OUTVIDEO_PATH, fontsize, font, bg_color, text_color, caption_mode)
return OUTVIDEO_PATH, SRT_PATH
|