mirror of
https://github.com/m-bain/whisperX.git
synced 2025-07-01 18:17:27 -04:00
init commit
This commit is contained in:
19
tests/test_audio.py
Normal file
19
tests/test_audio.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os.path
|
||||
|
||||
import numpy as np
|
||||
|
||||
from whisper.audio import load_audio, log_mel_spectrogram, SAMPLE_RATE
|
||||
|
||||
|
||||
def test_audio():
|
||||
audio_path = os.path.join(os.path.dirname(__file__), "jfk.flac")
|
||||
audio = load_audio(audio_path)
|
||||
assert audio.ndim == 1
|
||||
assert SAMPLE_RATE * 10 < audio.shape[0] < SAMPLE_RATE * 12
|
||||
assert 0 < audio.std() < 1
|
||||
|
||||
mel_from_audio = log_mel_spectrogram(audio)
|
||||
mel_from_file = log_mel_spectrogram(audio_path)
|
||||
|
||||
assert np.allclose(mel_from_audio, mel_from_file)
|
||||
assert mel_from_audio.max() - mel_from_audio.min() <= 2.0
|
Reference in New Issue
Block a user