Skip to content

Commit

Permalink
Merge pull request #1 from explosion/add-tests
Browse files Browse the repository at this point in the history
Adding unit tests
  • Loading branch information
koaning committed Nov 8, 2023
2 parents 5bac920 + a3610c5 commit a50195d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 1 deletion.
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Unit Tests

on:
pull_request:
push:
branches:
- main

jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip" # caching pip dependencies

- name: Setup ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
id: setup-ffmpeg

- name: Check out Prodigy
uses: actions/checkout@v3
with:
repository: explosion/prodigy
ref: v1.14.0
path: ./prodigy
ssh-key: ${{ secrets.GHA_PRODIGY_READ }}

- name: Install Prodigy
run: |
ls -la
pip install ./prodigy
python -m prodigy --help
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .
pip install ruff pytest
- name: Run ruff
if: always()
shell: bash
run: python -m ruff prodigy_whisper tests

- name: Run pytest
if: always()
shell: bash
run: python -m pytest tests
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ You can install this plugin via `pip`.
pip install "prodigy-whisper @ git+https://github.com/explosion/prodigy-whisper"
```

You'll also want to make sure that `ffmpeg` is installed before running these recipes.

To learn more about this plugin, you can check the [Prodigy docs](https://prodi.gy/docs/plugins/#whisper).

## Issues?
Expand Down
1 change: 0 additions & 1 deletion prodigy_whisper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def add_transcript_input_metadata(stream: StreamType) -> StreamType:
"show_audio_timeline": segment,
"show_audio_minimap": not segment,
"audio_bar_width": 1,
"javascript": "console.log('this works yo');"
},
}

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.ruff]
line-length = 120
Empty file added tests/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from prodigy_whisper import whisper_audio_transcribe


def test_smoke_no_segment(tmpdir):
# Make sure we can train without errors
components = whisper_audio_transcribe("xxx", "audio", model="tiny.en")
assert "transcript" in next(components["stream"])


def test_smoke_segment(tmpdir):
# Make sure we can train without errors
components = whisper_audio_transcribe("xxx", "audio", model="tiny.en", segment=True)
for ex in components["stream"]:
assert "transcript" in ex
assert ex["meta"]["path"] == "audio/talking.mp3"
assert isinstance(ex["meta"]["segment_id"], int)

0 comments on commit a50195d

Please sign in to comment.