Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #7 by newly initializing output path for srt files for each video… #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
.DS_Store
*.egg-info
auto_subtitle/__pycache__
build
5 changes: 3 additions & 2 deletions auto_subtitle/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ def get_audio(paths):


def get_subtitles(audio_paths: list, output_srt: bool, output_dir: str, transcribe: callable):
srt_path = output_dir if output_srt else tempfile.gettempdir()
srt_base_path = output_dir if output_srt else tempfile.gettempdir()
subtitles_path = {}

for path, audio_path in audio_paths.items():
srt_path = os.path.join(srt_path, f"{filename(path)}.srt")
srt_path = os.path.join(srt_base_path, f"{filename(path)}.srt")

print(
f"Generating subtitles for {filename(path)}... This might take a while."
Expand All @@ -103,6 +103,7 @@ def get_subtitles(audio_paths: list, output_srt: bool, output_dir: str, transcri
write_srt(result["segments"], file=srt)

subtitles_path[path] = srt_path
os.remove(audio_path)

return subtitles_path

Expand Down