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
    # to make certain it does not contain a lot of noise.
    assert 0 < audio.std() < 1
