Adding test for settings
parent
c4b3738a24
commit
a4a09b37f0
@ -0,0 +1,18 @@
|
||||
from pydantic import BaseSettings, Field
|
||||
|
||||
|
||||
class WhisperSettings(BaseSettings):
|
||||
"""Whisper Application Settings.
|
||||
|
||||
All environment varaibles supplied should be prefixed with "WHISPER_".
|
||||
"""
|
||||
|
||||
base_asr_model: str = Field(
|
||||
default="medium.en", description="The base whisper model to host."
|
||||
)
|
||||
|
||||
class Config:
|
||||
env_prefix = "WHISPER_"
|
||||
|
||||
|
||||
whisper_settings = WhisperSettings()
|
@ -1,9 +1,13 @@
|
||||
from local_whisper.inference import transcribe
|
||||
from local_whisper.audio import load_audio
|
||||
from local_whisper.inference import transcribe
|
||||
|
||||
|
||||
def test_transcribe(sample_audio):
|
||||
with open(sample_audio, mode="rb") as af:
|
||||
audio = load_audio(af)
|
||||
result = transcribe(audio)
|
||||
assert result["text"].strip() == "Let's see, right now I'm playing Horizon Zero Dawn. I also had just recently finished BioShock Infinite."
|
||||
assert (
|
||||
result["text"].strip().lower()
|
||||
== "Let's see, right now I'm playing Horizon Zero Dawn. \
|
||||
I also had just recently finished BioShock Infinite.".lower()
|
||||
)
|
||||
|
@ -0,0 +1,25 @@
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
from pydantic.types import SecretStr
|
||||
|
||||
from local_whisper.settings import WhisperSettings
|
||||
|
||||
SETTING_DEFAULTS = {
|
||||
"BASE_ASR_MODEL": "medium.en",
|
||||
}
|
||||
|
||||
|
||||
def test_setting_defaults():
|
||||
"""Regression test for settings schema."""
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
savant_settings = WhisperSettings()
|
||||
assert len(savant_settings.dict()) == len(SETTING_DEFAULTS)
|
||||
for k, v in SETTING_DEFAULTS.items():
|
||||
_setting_value = getattr(savant_settings, k.lower())
|
||||
unmasked_setting = (
|
||||
_setting_value.get_secret_value()
|
||||
if isinstance(_setting_value, SecretStr)
|
||||
else _setting_value
|
||||
)
|
||||
unmasked_setting == v
|
Loading…
Reference in New Issue