-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update version to 2.8.1 and enhance installation script
- Loading branch information
Showing
6 changed files
with
264 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
. ./activate | ||
set -e | ||
# uv run python -m unittest discover tests | ||
pytest | ||
pytest --tb=long -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# pylint: disable=bad-option-value,useless-option-value,no-self-use,protected-access,R0801 | ||
# flake8: noqa E501 | ||
|
||
|
||
""" | ||
Tests transcribe_anything | ||
""" | ||
|
||
|
||
import os | ||
import shutil | ||
import unittest | ||
from pathlib import Path | ||
|
||
from dotenv import load_dotenv | ||
|
||
from transcribe_anything.insanely_fast_whisper import ( | ||
run_insanely_fast_whisper, | ||
) | ||
from transcribe_anything.util import has_nvidia_smi, is_mac_arm | ||
|
||
load_dotenv() # take environment variables from .env. | ||
|
||
HF_TOKEN = os.getenv("HF_TOKEN") | ||
|
||
|
||
HERE = Path(os.path.abspath(os.path.dirname(__file__))) | ||
LOCALFILE_DIR = HERE / "localfile" | ||
TESTS_DATA_DIR = LOCALFILE_DIR / "text_video_insane" / "en" | ||
TEST_WAV = LOCALFILE_DIR / "video.wav" | ||
PROJECT_ROOT = HERE.parent | ||
|
||
CAN_RUN_TEST = (has_nvidia_smi() or is_mac_arm()) and HF_TOKEN is not None | ||
|
||
|
||
class InsanelFastWhisperDiarizationTester(unittest.TestCase): | ||
"""Tester for transcribe anything.""" | ||
|
||
@unittest.skipUnless(CAN_RUN_TEST, "No GPU, or HF_TOKEN not set") | ||
def test_local_file(self) -> None: | ||
"""Check that the command works on a local file.""" | ||
shutil.rmtree(TESTS_DATA_DIR, ignore_errors=True) | ||
run_insanely_fast_whisper( | ||
input_wav=TEST_WAV, | ||
model="small", | ||
output_dir=TESTS_DATA_DIR, | ||
task="transcribe", | ||
language="en", | ||
hugging_face_token=HF_TOKEN, | ||
) | ||
expected_file = TESTS_DATA_DIR / "speaker.json" | ||
self.assertTrue(expected_file.exists()) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |