-
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: add tests for MacOS whisper MPS functionality
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Tests transcribe_anything | ||
""" | ||
|
||
# pylint: disable=bad-option-value,useless-option-value,no-self-use,protected-access,R0801 | ||
# flake8: noqa E501 | ||
|
||
import os | ||
import shutil | ||
import unittest | ||
from pathlib import Path | ||
|
||
|
||
from transcribe_anything.util import is_mac_arm | ||
from transcribe_anything.whisper_mac import run_whisper_mac_english | ||
|
||
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" | ||
|
||
CAN_RUN_TEST = is_mac_arm() | ||
|
||
|
||
class MacOsWhisperMpsTester(unittest.TestCase): | ||
"""Tester for transcribe anything.""" | ||
|
||
@unittest.skipUnless(CAN_RUN_TEST, "Not mac") | ||
def test_local_file(self) -> None: | ||
"""Check that the command works on a local file.""" | ||
shutil.rmtree(TESTS_DATA_DIR, ignore_errors=True) | ||
run_whisper_mac_english( | ||
input_wav=TEST_WAV, | ||
model="small", | ||
output_dir=TESTS_DATA_DIR, | ||
) | ||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |