-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit uses ffprobe, which comes with ffmpeg (a Whisper requirement), to check that the file being transcribed is an audio or video file that ffmpeg understands. The format, duration and size of the file is logged to make it a bit easier to analyze the speech-to-text logs. If an invalid file is supplied to the service it will raise an exception indicating that the format was invalid. This ultimately gets caught and logged. Closes #48 Closes #31
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
__pycache__/ | ||
whisper_models | ||
*.log | ||
.python-version |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
boto3 | ||
ffprobe3 | ||
openai-whisper | ||
python-dotenv | ||
pytest | ||
|
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,23 @@ | ||
from speech_to_text import inspect_media, SpeechToTextException | ||
|
||
import pytest | ||
|
||
|
||
def test_duration(): | ||
result = inspect_media("tests/data/en.wav") | ||
assert result["duration"] == 3.220000 | ||
|
||
|
||
def test_format(): | ||
result = inspect_media("tests/data/en.wav") | ||
assert result["format"] == "wav" | ||
|
||
|
||
def test_size(): | ||
result = inspect_media("tests/data/en.wav") | ||
assert result["size"] == 618318 | ||
|
||
|
||
def test_invalid_media(): | ||
with pytest.raises(SpeechToTextException): | ||
result = inspect_media("README.md") |