diff --git a/tests/test_server_extended.py b/tests/test_server_extended.py index d369df2..ca26c07 100644 --- a/tests/test_server_extended.py +++ b/tests/test_server_extended.py @@ -349,7 +349,7 @@ class TestStreamTranscription(unittest.TestCase): ): if stream: return server._stream_transcription( - file, language, None, 0.0, None, None, None + file, language, None, 0.0, None, None ) return {"text": "non-streamed"} @@ -366,6 +366,7 @@ class TestStreamTranscription(unittest.TestCase): mock_info = MagicMock() mock_info.language = "en" + mock_info.language_probability = 0.98 mock_info.duration = 1.0 mock_model = MagicMock() @@ -395,6 +396,9 @@ class TestStreamTranscription(unittest.TestCase): mock_seg.words = [] mock_info = MagicMock() + mock_info.language = "en" + mock_info.language_probability = 0.95 + mock_info.duration = 1.5 mock_model = MagicMock() mock_model.transcribe.return_value = (iter([mock_seg]), mock_info) mock_model_cls.return_value = mock_model @@ -426,6 +430,9 @@ class TestStreamTranscription(unittest.TestCase): segs.append(s) mock_info = MagicMock() + mock_info.language = "en" + mock_info.language_probability = 0.99 + mock_info.duration = 3.0 mock_model = MagicMock() mock_model.transcribe.return_value = (iter(segs), mock_info) mock_model_cls.return_value = mock_model @@ -441,7 +448,7 @@ class TestStreamTranscription(unittest.TestCase): data={"stream": "true"}, ) body = resp.text - events = [line for line in body.split("\n") if line.startswith("data: ") and "[DONE]" not in line] + events = [line for line in body.split("\n") if line.startswith("data: ") and "[DONE]" not in line and '"type": "metadata"' not in line] self.assertEqual(len(events), 3) for i, event in enumerate(events): data = json.loads(event.removeprefix("data: ")) diff --git a/whisper_live/server.py b/whisper_live/server.py index 1e9acfb..1a7a36b 100644 --- a/whisper_live/server.py +++ b/whisper_live/server.py @@ -505,11 +505,8 @@ class TranscriptionServer: yield f"data: {json.dumps(seg_dict)}\n\n" yield "data: [DONE]\n\n" - wl_metrics.track_rest_request(endpoint="transcriptions_stream", status=200) except Exception as e: yield f"data: {json.dumps({'error': str(e)})}\n\n" - wl_metrics.track_rest_request(endpoint="transcriptions_stream", status=500) - wl_metrics.track_error("rest_stream") finally: if tmp_path and os.path.exists(tmp_path): os.unlink(tmp_path)