• 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_speachestestssse_test.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
docs: usage pages (and more)
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
rename to `speaches`
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 72b312c rename to `speaches` UNIX
Raw Open in browser Change history
import json from pathlib import Path import anyio from httpx import AsyncClient from httpx_sse import aconnect_sse import pytest import srt import webvtt import webvtt.vtt from speaches.api_models import ( CreateTranscriptionResponseJson, CreateTranscriptionResponseVerboseJson, ) FILE_PATHS = ["audio.wav"] # HACK ENDPOINTS = [ "/v1/audio/transcriptions", "/v1/audio/translations", ] parameters = [(file_path, endpoint) for endpoint in ENDPOINTS for file_path in FILE_PATHS] @pytest.mark.asyncio @pytest.mark.parametrize(("file_path", "endpoint"), parameters) async def test_streaming_transcription_text(aclient: AsyncClient, file_path: str, endpoint: str) -> None: extension = Path(file_path).suffix[1:] async with await anyio.open_file(file_path, "rb") as f: data = await f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "text", "stream": True}, } async with aconnect_sse(aclient, "POST", endpoint, **kwargs) as event_source: async for event in event_source.aiter_sse(): print(event) assert len(event.data) > 1 # HACK: 1 because of the space character that's always prepended @pytest.mark.asyncio @pytest.mark.parametrize(("file_path", "endpoint"), parameters) async def test_streaming_transcription_json(aclient: AsyncClient, file_path: str, endpoint: str) -> None: extension = Path(file_path).suffix[1:] async with await anyio.open_file(file_path, "rb") as f: data = await f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "json", "stream": True}, } async with aconnect_sse(aclient, "POST", endpoint, **kwargs) as event_source: async for event in event_source.aiter_sse(): CreateTranscriptionResponseJson(**json.loads(event.data)) @pytest.mark.asyncio @pytest.mark.parametrize(("file_path", "endpoint"), parameters) async def test_streaming_transcription_verbose_json(aclient: AsyncClient, file_path: str, endpoint: str) -> None: extension = Path(file_path).suffix[1:] async with await anyio.open_file(file_path, "rb") as f: data = await f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "verbose_json", "stream": True}, } async with aconnect_sse(aclient, "POST", endpoint, **kwargs) as event_source: async for event in event_source.aiter_sse(): CreateTranscriptionResponseVerboseJson(**json.loads(event.data)) @pytest.mark.asyncio async def test_transcription_vtt(aclient: AsyncClient) -> None: async with await anyio.open_file("audio.wav", "rb") as f: data = await f.read() kwargs = { "files": {"file": ("audio.wav", data, "audio/wav")}, "data": {"response_format": "vtt", "stream": False}, } response = await aclient.post("/v1/audio/transcriptions", **kwargs) assert response.status_code == 200 assert response.headers["content-type"] == "text/vtt; charset=utf-8" text = response.text webvtt.from_string(text) text = text.replace("WEBVTT", "YO") with pytest.raises(webvtt.vtt.MalformedFileError): webvtt.from_string(text) @pytest.mark.asyncio async def test_transcription_srt(aclient: AsyncClient) -> None: async with await anyio.open_file("audio.wav", "rb") as f: data = await f.read() kwargs = { "files": {"file": ("audio.wav", data, "audio/wav")}, "data": {"response_format": "srt", "stream": False}, } response = await aclient.post("/v1/audio/transcriptions", **kwargs) assert response.status_code == 200 assert "text/plain" in response.headers["content-type"] text = response.text list(srt.parse(text)) text = text.replace("1", "YO") with pytest.raises(srt.SRTParseError): list(srt.parse(text))

          
        
    
    
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