

chore: delete failing tests
@50b17e87c0a569cbe0039a6766dd98e376d8a8e7
--- tests/app_test.py
... | ... | @@ -1,77 +0,0 @@ |
1 | -from collections.abc import Generator | |
2 | -import json | |
3 | -import os | |
4 | -import time | |
5 | - | |
6 | -from fastapi.testclient import TestClient | |
7 | -import pytest | |
8 | -from starlette.testclient import WebSocketTestSession | |
9 | - | |
10 | -from faster_whisper_server.config import BYTES_PER_SECOND | |
11 | -from faster_whisper_server.server_models import TranscriptionVerboseJsonResponse | |
12 | - | |
13 | -SIMILARITY_THRESHOLD = 0.97 | |
14 | -AUDIO_FILES_LIMIT = 5 | |
15 | -AUDIO_FILE_DIR = "tests/data" | |
16 | -TRANSCRIBE_ENDPOINT = "/v1/audio/transcriptions?response_format=verbose_json" | |
17 | - | |
18 | - | |
19 | -@pytest.fixture() | |
20 | -def ws(client: TestClient) -> Generator[WebSocketTestSession, None, None]: | |
21 | - with client.websocket_connect(TRANSCRIBE_ENDPOINT) as ws: | |
22 | - yield ws | |
23 | - | |
24 | - | |
25 | -def get_audio_file_paths() -> list[str]: | |
26 | - file_paths: list[str] = [] | |
27 | - directory = "tests/data" | |
28 | - for filename in sorted(os.listdir(directory)[:AUDIO_FILES_LIMIT]): | |
29 | - file_paths.append(os.path.join(directory, filename)) # noqa: PERF401 | |
30 | - return file_paths | |
31 | - | |
32 | - | |
33 | -file_paths = get_audio_file_paths() | |
34 | - | |
35 | - | |
36 | -def stream_audio_data(ws: WebSocketTestSession, data: bytes, *, chunk_size: int = 4000, speed: float = 1.0) -> None: | |
37 | - for i in range(0, len(data), chunk_size): | |
38 | - ws.send_bytes(data[i : i + chunk_size]) | |
39 | - delay = len(data[i : i + chunk_size]) / BYTES_PER_SECOND / speed | |
40 | - time.sleep(delay) | |
41 | - | |
42 | - | |
43 | -def transcribe_audio_data(client: TestClient, data: bytes) -> TranscriptionVerboseJsonResponse: | |
44 | - response = client.post( | |
45 | - TRANSCRIBE_ENDPOINT, | |
46 | - files={"file": ("audio.raw", data, "audio/raw")}, | |
47 | - ) | |
48 | - data = json.loads(response.json()) # TODO: figure this out | |
49 | - return TranscriptionVerboseJsonResponse(**data) # pyright: ignore[reportCallIssue] | |
50 | - | |
51 | - | |
52 | -# @pytest.mark.parametrize("file_path", file_paths) | |
53 | -# def test_ws_audio_transcriptions( | |
54 | -# client: TestClient, ws: WebSocketTestSession, file_path: str | |
55 | -# ): | |
56 | -# with open(file_path, "rb") as file: | |
57 | -# data = file.read() | |
58 | -# | |
59 | -# streaming_transcription: TranscriptionVerboseJsonResponse = None # type: ignore # noqa: PGH003 | |
60 | -# thread = threading.Thread( | |
61 | -# target=stream_audio_data, args=(ws, data), kwargs={"speed": 4.0} | |
62 | -# ) | |
63 | -# thread.start() | |
64 | -# while True: | |
65 | -# try: | |
66 | -# streaming_transcription = TranscriptionVerboseJsonResponse( | |
67 | -# **ws.receive_json() | |
68 | -# ) | |
69 | -# except WebSocketDisconnect: | |
70 | -# break | |
71 | -# file_transcription = transcribe_audio_data(client, data) | |
72 | -# s = SequenceMatcher( | |
73 | -# lambda x: x == " ", file_transcription.text, streaming_transcription.text | |
74 | -# ) | |
75 | -# assert ( | |
76 | -# s.ratio() > SIMILARITY_THRESHOLD | |
77 | -# ), f"\nExpected: {file_transcription.text}\nReceived: {streaming_transcription.text}" |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?