Commit
·
ae3fc6e
1
Parent(s):
2f59878
removed deprecated donwload_video util from cli.
Browse files
cli.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
from argparse import ArgumentParser
|
| 2 |
-
from utils.download_video import download_video
|
| 3 |
from utils.transcriber import transcriber
|
| 4 |
from utils.subtitler import subtitler
|
| 5 |
from utils.convert_video_to_audio import convert_video_to_audio
|
|
@@ -12,8 +11,7 @@ logging.basicConfig(filename='main.log',
|
|
| 12 |
format='%(asctime)s %(levelname)s %(message)s',
|
| 13 |
datefmt='%m/%d/%Y %I:%M:%S %p')
|
| 14 |
|
| 15 |
-
def main(
|
| 16 |
-
invideo_filename:str,
|
| 17 |
max_words_per_line:int,
|
| 18 |
fontsize:int,
|
| 19 |
font:str,
|
|
@@ -25,33 +23,20 @@ def main(video_url:str,
|
|
| 25 |
SRT_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.srt")
|
| 26 |
OUTVIDEO_PATH = os.path.join(INVIDEO_DIR, f"result_{invideo_filename}.mp4")
|
| 27 |
with tqdm(total=100, desc="Overall Progress") as pbar:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
INAUDIO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.m4a")
|
| 32 |
convert_video_to_audio(INVIDEO_PATH,INAUDIO_PATH)
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
else:
|
| 40 |
-
INVIDEO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.mp4")
|
| 41 |
-
INAUDIO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.m4a")
|
| 42 |
-
if not os.path.exists(INAUDIO_PATH):
|
| 43 |
-
convert_video_to_audio(INVIDEO_PATH,INAUDIO_PATH)
|
| 44 |
-
pbar.update(50)
|
| 45 |
-
if not os.path.exists(SRT_PATH):
|
| 46 |
-
transcriber(INAUDIO_PATH, SRT_PATH, max_words_per_line)
|
| 47 |
-
pbar.update(25)
|
| 48 |
-
subtitler(INVIDEO_PATH, SRT_PATH, OUTVIDEO_PATH, fontsize, font, bg_color, text_color)
|
| 49 |
-
pbar.update(25)
|
| 50 |
|
| 51 |
if __name__ == '__main__':
|
| 52 |
parser = ArgumentParser()
|
| 53 |
parser.add_argument('--invideo_filename', required=True, type=str, help='Filename to caption.')
|
| 54 |
-
parser.add_argument('--video_url', required=False, default=None, type=str, help='A video file to be subtitled (Optional)')
|
| 55 |
parser.add_argument("--max_words_per_line", type=int, default=None, help="the maximum number of words in a segment. (int)")
|
| 56 |
parser.add_argument('--fontsize', required=False, default=32, type=int, help='Font size for captions (int)')
|
| 57 |
parser.add_argument('--font', required=False, default="FuturaPTHeavy", type=str, help='Font style for captions (str)')
|
|
@@ -59,8 +44,7 @@ if __name__ == '__main__':
|
|
| 59 |
parser.add_argument('--text_color', required=False, default="white", type=str, help='color value for caption text. (str)')
|
| 60 |
args = parser.parse_args()
|
| 61 |
# Example usage
|
| 62 |
-
main(args.
|
| 63 |
-
args.invideo_filename,
|
| 64 |
args.max_words_per_line,
|
| 65 |
args.fontsize,
|
| 66 |
args.font,
|
|
|
|
| 1 |
from argparse import ArgumentParser
|
|
|
|
| 2 |
from utils.transcriber import transcriber
|
| 3 |
from utils.subtitler import subtitler
|
| 4 |
from utils.convert_video_to_audio import convert_video_to_audio
|
|
|
|
| 11 |
format='%(asctime)s %(levelname)s %(message)s',
|
| 12 |
datefmt='%m/%d/%Y %I:%M:%S %p')
|
| 13 |
|
| 14 |
+
def main(invideo_filename:str,
|
|
|
|
| 15 |
max_words_per_line:int,
|
| 16 |
fontsize:int,
|
| 17 |
font:str,
|
|
|
|
| 23 |
SRT_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.srt")
|
| 24 |
OUTVIDEO_PATH = os.path.join(INVIDEO_DIR, f"result_{invideo_filename}.mp4")
|
| 25 |
with tqdm(total=100, desc="Overall Progress") as pbar:
|
| 26 |
+
INVIDEO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.mp4")
|
| 27 |
+
INAUDIO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.m4a")
|
| 28 |
+
if not os.path.exists(INAUDIO_PATH):
|
|
|
|
| 29 |
convert_video_to_audio(INVIDEO_PATH,INAUDIO_PATH)
|
| 30 |
+
pbar.update(50)
|
| 31 |
+
if not os.path.exists(SRT_PATH):
|
| 32 |
+
transcriber(INAUDIO_PATH, SRT_PATH, max_words_per_line)
|
| 33 |
+
pbar.update(25)
|
| 34 |
+
subtitler(INVIDEO_PATH, SRT_PATH, OUTVIDEO_PATH, fontsize, font, bg_color, text_color)
|
| 35 |
+
pbar.update(25)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
if __name__ == '__main__':
|
| 38 |
parser = ArgumentParser()
|
| 39 |
parser.add_argument('--invideo_filename', required=True, type=str, help='Filename to caption.')
|
|
|
|
| 40 |
parser.add_argument("--max_words_per_line", type=int, default=None, help="the maximum number of words in a segment. (int)")
|
| 41 |
parser.add_argument('--fontsize', required=False, default=32, type=int, help='Font size for captions (int)')
|
| 42 |
parser.add_argument('--font', required=False, default="FuturaPTHeavy", type=str, help='Font style for captions (str)')
|
|
|
|
| 44 |
parser.add_argument('--text_color', required=False, default="white", type=str, help='color value for caption text. (str)')
|
| 45 |
args = parser.parse_args()
|
| 46 |
# Example usage
|
| 47 |
+
main(args.invideo_filename,
|
|
|
|
| 48 |
args.max_words_per_line,
|
| 49 |
args.fontsize,
|
| 50 |
args.font,
|
main.py
CHANGED
|
@@ -9,6 +9,8 @@ from utils.api_configs import api_configs
|
|
| 9 |
from utils.read_html import read_html
|
| 10 |
import shutil, os, logging, uvicorn, secrets
|
| 11 |
|
|
|
|
|
|
|
| 12 |
app = FastAPI()
|
| 13 |
security = HTTPBasic()
|
| 14 |
api_configs_file = os.path.abspath("api_config_example.yml")
|
|
|
|
| 9 |
from utils.read_html import read_html
|
| 10 |
import shutil, os, logging, uvicorn, secrets
|
| 11 |
|
| 12 |
+
#TODO: upgrade project dependencies for the soon to be released version of faster-whisper that supports distil-largev3
|
| 13 |
+
|
| 14 |
app = FastAPI()
|
| 15 |
security = HTTPBasic()
|
| 16 |
api_configs_file = os.path.abspath("api_config_example.yml")
|