You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
local-whisper/tests/unit/test_audio.py

16 lines
608 B
Python

2 years ago
from local_whisper.audio import DEFAULT_SAMPLE_RATE, load_audio
def test_audio(sample_audio):
print(sample_audio)
with open(sample_audio, mode="rb") as f:
audio = load_audio(f)
# Assert Mono
assert audio.ndim == 1
# Test the file length is appropriate size
assert DEFAULT_SAMPLE_RATE * 8 < audio.shape[0] < DEFAULT_SAMPLE_RATE * 12
# Taking the standard diviation of audio data can be used to check
# Amplitude Variability, Noise Detection, or Normalization. Hear we just want
2 years ago
# to make certain it does not contain a lot of noise.
assert 0 < audio.std() < 1