• 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
ci: do not run tests which require OpenAI API key
2024-09-22
examples
Update script.sh
2024-09-03
scripts
chore: minor changes to scripts/client.py
2024-09-05
src/speaches
fix: `timestamp_granularities[]` handling (#28, #58, #81)
2024-09-22
tests
ci: do not run tests which require OpenAI API key
2024-09-22
.dockerignore
chore: ignore .env
2024-05-27
.envrc
init
2024-05-20
.gitattributes
docs: add live-transcription demo
2024-05-28
.gitignore
chore: update .gitignore
2024-07-03
.pre-commit-config.yaml
fix: pre-commit basedpyright not checking all files
2024-10-01
Dockerfile.cpu
chore: update default whisper model
2024-09-08
Dockerfile.cuda
chore: update default whisper model
2024-09-08
LICENSE
init
2024-05-20
README.md
fix: 404
2024-09-17
Taskfile.yaml
feat: dependency injection
2024-09-22
audio.wav
docs: update README.md
2024-05-27
compose.yaml
chore: format compose
2024-09-11
flake.lock
deps: update flake
2024-09-08
flake.nix
deps: update flake
2024-09-08
pyproject.toml
fix: pytest-asyncio fixture scope warnings
2024-09-22
uv.lock
fix: gradio pydantic error
2024-09-11
File name
Commit message
Commit date
__init__.py
feat: add /v1/models and /v1/model routes #14
2024-06-03
api_model_test.py
test: switch to async openai client
2024-09-22
api_timestamp_granularities_test.py
fix: `timestamp_granularities[]` handling (#28, #58, #81)
2024-09-22
conftest.py
test: switch to async openai client
2024-09-22
openai_timestamp_granularities_test.py
ci: do not run tests which require OpenAI API key
2024-09-22
sse_test.py
deps: add `pytest-async`
2024-09-08
Fedir Zadniprovskyi 2024-09-08 70bbc94 deps: add `pytest-async` UNIX
Raw Open in browser Change history
import json import os from fastapi.testclient import TestClient from faster_whisper_server.server_models import ( TranscriptionJsonResponse, TranscriptionVerboseJsonResponse, ) from httpx_sse import connect_sse import pytest import srt import webvtt import webvtt.vtt 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.parametrize(("file_path", "endpoint"), parameters) def test_streaming_transcription_text(client: TestClient, file_path: str, endpoint: str) -> None: extension = os.path.splitext(file_path)[1] with open(file_path, "rb") as f: data = f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "text", "stream": True}, } with connect_sse(client, "POST", endpoint, **kwargs) as event_source: for event in event_source.iter_sse(): print(event) assert len(event.data) > 1 # HACK: 1 because of the space character that's always prepended @pytest.mark.parametrize(("file_path", "endpoint"), parameters) def test_streaming_transcription_json(client: TestClient, file_path: str, endpoint: str) -> None: extension = os.path.splitext(file_path)[1] with open(file_path, "rb") as f: data = f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "json", "stream": True}, } with connect_sse(client, "POST", endpoint, **kwargs) as event_source: for event in event_source.iter_sse(): TranscriptionJsonResponse(**json.loads(event.data)) @pytest.mark.parametrize(("file_path", "endpoint"), parameters) def test_streaming_transcription_verbose_json(client: TestClient, file_path: str, endpoint: str) -> None: extension = os.path.splitext(file_path)[1] with open(file_path, "rb") as f: data = f.read() kwargs = { "files": {"file": (f"audio.{extension}", data, f"audio/{extension}")}, "data": {"response_format": "verbose_json", "stream": True}, } with connect_sse(client, "POST", endpoint, **kwargs) as event_source: for event in event_source.iter_sse(): TranscriptionVerboseJsonResponse(**json.loads(event.data)) def test_transcription_vtt(client: TestClient) -> None: with open("audio.wav", "rb") as f: data = f.read() kwargs = { "files": {"file": ("audio.wav", data, "audio/wav")}, "data": {"response_format": "vtt", "stream": False}, } response = client.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) def test_transcription_srt(client: TestClient) -> None: with open("audio.wav", "rb") as f: data = f.read() kwargs = { "files": {"file": ("audio.wav", data, "audio/wav")}, "data": {"response_format": "srt", "stream": False}, } response = client.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