• 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_speachestestsapp_test.py
Download as .zip file
File name
Commit message
Commit date
.github/workflows
update pre-commit deps, replace custom pyright hook
2024-07-03
examples
chore: update docker tag to latest
2024-06-03
faster_whisper_server
fix: models route not returning openai compatible response
2024-07-03
tests
fix: models route not returning openai compatible response
2024-07-03
.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
update pre-commit deps, replace custom pyright hook
2024-07-03
Dockerfile.cpu
fix task enum vals, fix env var parsing, improve gradio, use uv in dockerfile
2024-06-23
Dockerfile.cuda
fix task enum vals, fix env var parsing, improve gradio, use uv in dockerfile
2024-06-23
LICENSE
init
2024-05-20
README.md
Update README.md
2024-06-26
Taskfile.yaml
switch to using uv
2024-07-03
audio.wav
docs: update README.md
2024-05-27
compose.yaml
chore: update docker tag to latest
2024-06-03
flake.lock
init
2024-05-20
flake.nix
switch to using uv
2024-07-03
lsyncd.conf
chore: add lsyncd config
2024-06-03
pyproject.toml
fix: models route not returning openai compatible response
2024-07-03
requirements-all.txt
switch to using uv
2024-07-03
requirements-dev.txt
fix: models route not returning openai compatible response
2024-07-03
requirements.txt
switch to using uv
2024-07-03
File name
Commit message
Commit date
__init__.py
feat: add /v1/models and /v1/model routes #14
2024-06-03
api_model_test.py
fix: models route not returning openai compatible response
2024-07-03
app_test.py
chore: fix ruff errors
2024-07-03
conftest.py
fix: models route not returning openai compatible response
2024-07-03
sse_test.py
chore: fix ruff errors
2024-07-03
Fedir Zadniprovskyi 2024-07-03 eb226c5 chore: fix ruff errors UNIX
Raw Open in browser Change history
from collections.abc import Generator import json import os import time from fastapi.testclient import TestClient import pytest from starlette.testclient import WebSocketTestSession from faster_whisper_server.config import BYTES_PER_SECOND from faster_whisper_server.server_models import TranscriptionVerboseJsonResponse SIMILARITY_THRESHOLD = 0.97 AUDIO_FILES_LIMIT = 5 AUDIO_FILE_DIR = "tests/data" TRANSCRIBE_ENDPOINT = "/v1/audio/transcriptions?response_format=verbose_json" @pytest.fixture() def ws(client: TestClient) -> Generator[WebSocketTestSession, None, None]: with client.websocket_connect(TRANSCRIBE_ENDPOINT) as ws: yield ws def get_audio_file_paths() -> list[str]: file_paths: list[str] = [] directory = "tests/data" for filename in sorted(os.listdir(directory)[:AUDIO_FILES_LIMIT]): file_paths.append(os.path.join(directory, filename)) # noqa: PERF401 return file_paths file_paths = get_audio_file_paths() def stream_audio_data(ws: WebSocketTestSession, data: bytes, *, chunk_size: int = 4000, speed: float = 1.0) -> None: for i in range(0, len(data), chunk_size): ws.send_bytes(data[i : i + chunk_size]) delay = len(data[i : i + chunk_size]) / BYTES_PER_SECOND / speed time.sleep(delay) def transcribe_audio_data(client: TestClient, data: bytes) -> TranscriptionVerboseJsonResponse: response = client.post( TRANSCRIBE_ENDPOINT, files={"file": ("audio.raw", data, "audio/raw")}, ) data = json.loads(response.json()) # TODO: figure this out return TranscriptionVerboseJsonResponse(**data) # pyright: ignore[reportCallIssue] # @pytest.mark.parametrize("file_path", file_paths) # def test_ws_audio_transcriptions( # client: TestClient, ws: WebSocketTestSession, file_path: str # ): # with open(file_path, "rb") as file: # data = file.read() # # streaming_transcription: TranscriptionVerboseJsonResponse = None # type: ignore # noqa: PGH003 # thread = threading.Thread( # target=stream_audio_data, args=(ws, data), kwargs={"speed": 4.0} # ) # thread.start() # while True: # try: # streaming_transcription = TranscriptionVerboseJsonResponse( # **ws.receive_json() # ) # except WebSocketDisconnect: # break # file_transcription = transcribe_audio_data(client, data) # s = SequenceMatcher( # lambda x: x == " ", file_transcription.text, streaming_transcription.text # ) # assert ( # s.ratio() > SIMILARITY_THRESHOLD # ), f"\nExpected: {file_transcription.text}\nReceived: {streaming_transcription.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