Skip to content

Commit

Permalink
Update CI & test-suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-plus committed Sep 3, 2024
1 parent ee867ca commit 0908a65
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
poetry install
poetry run pip uninstall -y faster-whisper
poetry run pip install "faster-whisper @ https://github.com/SYSTRAN/faster-whisper/archive/d57c5b40b06e59ec44240d93485a95799548af50.tar.gz"
poetry run pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
poetry run pip install --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
- name: Install ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
Expand Down
34 changes: 18 additions & 16 deletions tests/test_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ class TestTranscriber(unittest.TestCase):
def setUp(self) -> None:
self.audio_path = Path('data/test_audio.wav')

def test_transcribe_success(self):
with patch('openlrc.transcribe.BatchedInferencePipeline') as MockModel:
MockModel.return_value.transcribe.return_value = return_tuple

transcriber = Transcriber(model_name='tiny')
result, info = transcriber.transcribe(self.audio_path)
self.assertIsNotNone(result)
self.assertEqual(round(info.duration), 30)

def test_audio_file_not_found(self):
with patch('openlrc.transcribe.BatchedInferencePipeline') as MockModel:
MockModel.return_value.transcribe.return_value = return_tuple

transcriber = Transcriber(model_name='tiny')
with self.assertRaises(FileNotFoundError):
transcriber.transcribe('audio.wav')
@patch('openlrc.transcribe.BatchedInferencePipeline')
@patch('openlrc.transcribe.WhisperModel')
def test_transcribe_success(self, MockWhisperModel, MockBatchedInferencePipeline):
MockBatchedInferencePipeline.return_value.transcribe.return_value = return_tuple

transcriber = Transcriber(model_name='tiny')
result, info = transcriber.transcribe(self.audio_path)
self.assertIsNotNone(result)
self.assertEqual(round(info.duration), 30)

@patch('openlrc.transcribe.BatchedInferencePipeline')
@patch('openlrc.transcribe.WhisperModel')
def test_audio_file_not_found(self, MockWhisperModel, MockBatchedInferencePipeline):
MockBatchedInferencePipeline.return_value.transcribe.return_value = return_tuple

transcriber = Transcriber(model_name='tiny')
with self.assertRaises(FileNotFoundError):
transcriber.transcribe('audio.wav')

0 comments on commit 0908a65

Please sign in to comment.