Skip to content

Commit

Permalink
v2.2.0, now adds language name to folder when explicitly set
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed May 5, 2023
1 parent 43f1168 commit 63a6d6d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ is closed then to get back into the environment `cd transcribe_anything` and exe
* All tests are run by `tox`, simply go to the project directory root and run it.

# Versions
* 2.2.0: Now explictly setting a language will put the file in a folder with that language name, allowing multi language passes without overwriting.
* 2.1.2: yt-dlp pinned to new minimum version. Fixes downloading issues from old lib. Adds audio normalization by default.
* 2.1.1: Updates keywords for easier pypi finding.
* 2.1.0: Unknown args are now assumed to be for whisper and passed to it as-is. Fixes https://github.com/zackees/transcribe-anything/issues/3
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
EMAIL = "dont@email.me"
AUTHOR = "Zach Vorhies"
REQUIRES_PYTHON = ">=3.9.0"
VERSION = "2.1.2"
VERSION = "2.2.0"

# The text of the README file
with open(os.path.join(HERE, "README.md"), encoding="utf-8", mode="r") as fd:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_transcribe_anything.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def test_initial_prompt(self) -> None:
],
cwd=LOCALFILE_DIR,
)
# Expect that when the language is explicitly set that the output file ends up in
# that language folder.
expected_output = os.path.join(LOCALFILE_DIR, "video", "en", "out.txt")
self.assertTrue(
os.path.exists(expected_output),
f"Path {expected_output} doesn't exist, instead it was {os.listdir(LOCALFILE_DIR)}", # pylint: disable=line-too-long
)

def test_fetch_command_installed(self) -> None:
"""Check that the command works on a live short video."""
Expand Down
4 changes: 4 additions & 0 deletions transcribe_anything/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def transcribe(
# https://example.com/, which will yield a basename of "".
basename = os.path.basename(os.path.dirname(url_or_file))
basename = sanitize_path(basename)
output_dir_was_generated = False
if output_dir is None:
output_dir_was_generated = True
if url_or_file.startswith("http"):
# Try and the title of the video using yt-dlp
# If that fails, use the basename of the url
Expand All @@ -60,6 +62,8 @@ def transcribe(
output_dir = basename
else:
output_dir = os.path.splitext(basename)[0]
if output_dir_was_generated and language is not None:
output_dir = os.path.join(output_dir, language)
if os.path.exists(output_dir):
shutil.rmtree(output_dir)
os.makedirs(output_dir, exist_ok=True)
Expand Down

0 comments on commit 63a6d6d

Please sign in to comment.