• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
yjyoon / whisper_server_speaches star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
whisper_server_speachestestsconftest.py
Download as .zip file
File name
Commit message
Commit date
.github/workflows
feat: switch to ghcr.io
01-10
configuration
feat: add instrumentation
2024-12-17
docs
rename to `speaches`
01-12
examples
rename to `speaches`
01-12
scripts
chore: misc changes
2024-10-03
src/speaches
rename to `speaches`
01-12
tests
rename to `speaches`
01-12
.dockerignore
chore: update .dockerignore
2024-11-01
.envrc
init
2024-05-20
.gitattributes
chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.7.2
2024-11-02
.gitignore
chore: update .gitignore
2024-07-03
.pre-commit-config.yaml
chore(deps): update pre-commit hook python-jsonschema/check-jsonschema to v0.31.0
01-12
Dockerfile
chore(deps): update ghcr.io/astral-sh/uv docker tag to v0.5.18
01-12
LICENSE
init
2024-05-20
README.md
rename to `speaches`
01-12
Taskfile.yaml
rename to `speaches`
01-12
audio.wav
chore: update volume names and mount points
01-10
compose.cpu.yaml
rename to `speaches`
01-12
compose.cuda-cdi.yaml
rename to `speaches`
01-12
compose.cuda.yaml
rename to `speaches`
01-12
compose.observability.yaml
chore(deps): update otel/opentelemetry-collector-contrib docker tag to v0.117.0
01-12
compose.yaml
rename to `speaches`
01-12
flake.lock
deps: update flake
2024-11-01
flake.nix
chore(deps): add loki and tempo package to flake
2024-12-17
mkdocs.yml
rename to `speaches`
01-12
pyproject.toml
rename to `speaches`
01-12
renovate.json
feat: renovate handle pre-commit
2024-11-01
uv.lock
rename to `speaches`
01-12
File name
Commit message
Commit date
__init__.py
feat: add /v1/models and /v1/model routes #14
2024-06-03
api_model_test.py
chore: auto-fix ruff errors
2024-10-01
api_timestamp_granularities_test.py
rename to `speaches`
01-12
conftest.py
rename to `speaches`
01-12
model_manager_test.py
rename to `speaches`
01-12
openai_timestamp_granularities_test.py
rename to `speaches`
01-12
speech_test.py
rename to `speaches`
01-12
sse_test.py
rename to `speaches`
01-12
Fedir Zadniprovskyi 01-12 7396159 rename to `speaches` UNIX
Raw Open in browser Change history
from collections.abc import AsyncGenerator, Generator from contextlib import AbstractAsyncContextManager, asynccontextmanager import logging import os from typing import Protocol from fastapi.testclient import TestClient from httpx import ASGITransport, AsyncClient from huggingface_hub import snapshot_download from openai import AsyncOpenAI import pytest import pytest_asyncio from pytest_mock import MockerFixture from speaches.config import Config, WhisperConfig from speaches.dependencies import get_config from speaches.main import create_app DISABLE_LOGGERS = ["multipart.multipart", "faster_whisper"] OPENAI_BASE_URL = "https://api.openai.com/v1" DEFAULT_WHISPER_MODEL = "Systran/faster-whisper-tiny.en" # TODO: figure out a way to initialize the config without parsing environment variables, as those may interfere with the tests # noqa: E501 DEFAULT_WHISPER_CONFIG = WhisperConfig(model=DEFAULT_WHISPER_MODEL, ttl=0) DEFAULT_CONFIG = Config( whisper=DEFAULT_WHISPER_CONFIG, # disable the UI as it slightly increases the app startup time due to the imports it's doing enable_ui=False, ) def pytest_configure() -> None: for logger_name in DISABLE_LOGGERS: logger = logging.getLogger(logger_name) logger.disabled = True # NOTE: not being used. Keeping just in case. Needs to be modified to work similarly to `aclient_factory` @pytest.fixture def client() -> Generator[TestClient, None, None]: os.environ["WHISPER__MODEL"] = "Systran/faster-whisper-tiny.en" with TestClient(create_app()) as client: yield client # https://stackoverflow.com/questions/74890214/type-hint-callback-function-with-optional-parameters-aka-callable-with-optional class AclientFactory(Protocol): def __call__(self, config: Config = DEFAULT_CONFIG) -> AbstractAsyncContextManager[AsyncClient]: ... @pytest_asyncio.fixture() async def aclient_factory(mocker: MockerFixture) -> AclientFactory: """Returns a context manager that provides an `AsyncClient` instance with `app` using the provided configuration.""" @asynccontextmanager async def inner(config: Config = DEFAULT_CONFIG) -> AsyncGenerator[AsyncClient, None]: # NOTE: all calls to `get_config` should be patched. One way to test that this works is to update the original `get_config` to raise an exception and see if the tests fail # noqa: E501 mocker.patch("speaches.dependencies.get_config", return_value=config) mocker.patch("speaches.main.get_config", return_value=config) # NOTE: I couldn't get the following to work but it shouldn't matter # mocker.patch( # "speaches.text_utils.Transcription._ensure_no_word_overlap.get_config", return_value=config # ) app = create_app() # https://fastapi.tiangolo.com/advanced/testing-dependencies/ app.dependency_overrides[get_config] = lambda: config async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as aclient: yield aclient return inner @pytest_asyncio.fixture() async def aclient(aclient_factory: AclientFactory) -> AsyncGenerator[AsyncClient, None]: async with aclient_factory() as aclient: yield aclient @pytest_asyncio.fixture() def openai_client(aclient: AsyncClient) -> AsyncOpenAI: return AsyncOpenAI(api_key="cant-be-empty", http_client=aclient) @pytest.fixture def actual_openai_client() -> AsyncOpenAI: return AsyncOpenAI( # `base_url` is provided in case `OPENAI_BASE_URL` is set to a different value base_url=OPENAI_BASE_URL ) # TODO: remove the download after running the tests # TODO: do not download when not needed @pytest.fixture(scope="session", autouse=True) def download_piper_voices() -> None: # Only download `voices.json` and the default voice snapshot_download("rhasspy/piper-voices", allow_patterns=["voices.json", "en/en_US/amy/**"])

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up