finished revising the script.
This commit is contained in:
@@ -3,19 +3,6 @@ import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Try to load the .env file so the wizard knows what's already configured
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
# Path logic matching main.py
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Expected: .../video_transcription/../.env_files -> .../personal_development/.env_files
|
||||
env_path = os.path.abspath(os.path.join(script_dir, '../.env_files/.env.aitranscribe'))
|
||||
if os.path.exists(env_path):
|
||||
load_dotenv(env_path)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def clear_screen():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
@@ -43,25 +30,50 @@ def print_header():
|
||||
def main():
|
||||
clear_screen()
|
||||
print_header()
|
||||
|
||||
# Try to load the .env file so the wizard knows what's already configured
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
env_path = os.path.abspath(os.path.join(script_dir, '../.env_files/.env.aitranscribe'))
|
||||
if os.path.exists(env_path):
|
||||
load_dotenv(env_path)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# 1. Input File/Folder
|
||||
# 1. Input File/Folder (Multiple)
|
||||
input_paths = []
|
||||
while True:
|
||||
input_path = get_input("Enter the path to the video file or folder")
|
||||
prompt_text = "Enter a path to a video file or folder"
|
||||
if input_paths:
|
||||
prompt_text += " (or press Enter to finish)"
|
||||
|
||||
# Clean up input:
|
||||
# 1. Remove surrounding quotes (common when pasting paths)
|
||||
input_path = get_input(prompt_text)
|
||||
|
||||
if not input_path:
|
||||
if input_paths:
|
||||
break
|
||||
else:
|
||||
print("Error: You must provide at least one path.")
|
||||
continue
|
||||
|
||||
# Clean up input
|
||||
input_path = input_path.strip('"\'')
|
||||
# 2. Handle escaped spaces (e.g., "My\ Folder" -> "My Folder")
|
||||
input_path = input_path.replace(r'\ ', ' ')
|
||||
|
||||
# Expand user (~) and resolve absolute path
|
||||
input_path = os.path.abspath(os.path.expanduser(input_path))
|
||||
|
||||
if os.path.exists(input_path):
|
||||
break
|
||||
print(f"Error: Path '{input_path}' does not exist. Please try again.\n")
|
||||
input_paths.append(input_path)
|
||||
print(f"Added: {input_path}")
|
||||
else:
|
||||
print(f"Error: Path '{input_path}' does not exist. Please try again.\n")
|
||||
|
||||
print(f"Selected: {input_path}\n")
|
||||
print("\nSelected Inputs:")
|
||||
for p in input_paths:
|
||||
print(f" - {p}")
|
||||
print("")
|
||||
|
||||
# 2. Languages
|
||||
source_lang = get_input("Source Language (e.g., French, es)", default="auto")
|
||||
@@ -84,12 +96,13 @@ def main():
|
||||
print(" It will only run if the new subtitled video is successfully created.")
|
||||
do_delete_source = get_yes_no("Delete original source files after embedding?", default="n")
|
||||
|
||||
do_prefer_deep = get_yes_no("Prefer DeepTranslate (Free) over Gemini API?", default="n")
|
||||
|
||||
hf_token = None
|
||||
if do_diarize:
|
||||
if not os.getenv("HF_TOKEN"):
|
||||
print("\nSpeaker Diarization requires a HuggingFace Token.")
|
||||
hf_token = get_input("Enter your HuggingFace Token (hidden)", default="")
|
||||
# In a real app we might use getpass, but standard input is fine for this wizard level
|
||||
else:
|
||||
print("Using HF_TOKEN from environment.")
|
||||
|
||||
@@ -98,7 +111,9 @@ def main():
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
main_script = os.path.join(script_dir, "ai_transcriber", "main.py")
|
||||
|
||||
cmd = [sys.executable, main_script, input_path]
|
||||
cmd = [sys.executable, main_script]
|
||||
# Add all inputs
|
||||
cmd.extend(input_paths)
|
||||
|
||||
cmd.extend(["--lang", target_lang])
|
||||
cmd.extend(["--model", model_size])
|
||||
@@ -120,12 +135,17 @@ def main():
|
||||
if hf_token:
|
||||
cmd.extend(["--hf-token", hf_token])
|
||||
|
||||
if do_prefer_deep:
|
||||
cmd.append("--prefer-deep")
|
||||
|
||||
# 6. Confirmation and Execution
|
||||
clear_screen()
|
||||
print_header()
|
||||
print("Configuration Complete!")
|
||||
print("-" * 30)
|
||||
print(f"Input: {input_path}")
|
||||
print("Inputs:")
|
||||
for p in input_paths:
|
||||
print(f" - {p}")
|
||||
print(f"Source Lang: {source_lang}")
|
||||
print(f"Target Lang: {target_lang}")
|
||||
print(f"Model: {model_size}")
|
||||
@@ -133,6 +153,7 @@ def main():
|
||||
print(f"Embed Subs: {do_embed}")
|
||||
print(f"Delete Src: {do_delete_source}")
|
||||
print(f"Diarization: {do_diarize}")
|
||||
print(f"Prefer Deep: {do_prefer_deep}")
|
||||
print("-" * 30)
|
||||
|
||||
if not get_yes_no("Run this job now?", default="y"):
|
||||
@@ -155,4 +176,4 @@ def main():
|
||||
print("\nJob interrupted by user.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
Reference in New Issue
Block a user