Use qwen3-asr throughout speech integrations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mock-STT-Worker für lokale Tests.
|
||||
|
||||
Simuliert den Whisper-STT-Worker:
|
||||
Simuliert den Qwen3-ASR-Adapter:
|
||||
GET /status → ready: true
|
||||
POST /transcribe → liefert festes Transkript
|
||||
|
||||
|
||||
+8
-8
@@ -220,7 +220,7 @@ def main() -> None:
|
||||
# Test 1: Multipart + Content-Length (bestehender Pfad)
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 1: Multipart + Content-Length")
|
||||
mp = build_multipart({"model": "whisper-1", "language": "de"},
|
||||
mp = build_multipart({"model": "qwen3-asr", "language": "de"},
|
||||
file_data=fake_webm)
|
||||
status, body = http_request(
|
||||
"POST", PORTS["router"], "/v1/audio/transcriptions",
|
||||
@@ -235,7 +235,7 @@ def main() -> None:
|
||||
# Test 2: Multipart + Transfer-Encoding chunked (einfach)
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 2: Multipart + chunked (einfach)")
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=fake_webm)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=fake_webm)
|
||||
chunked = build_chunked_body([mp])
|
||||
raw = (
|
||||
b"POST /v1/audio/transcriptions HTTP/1.1\r\n"
|
||||
@@ -254,7 +254,7 @@ def main() -> None:
|
||||
# Test 3: Mehrere unterschiedlich große Chunks
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 3: Mehrere unterschiedlich große Chunks")
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=fake_webm)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=fake_webm)
|
||||
# In 5 Chunks aufteilen (unterschiedlich groß)
|
||||
chunks = []
|
||||
sizes = [10, 50, 7, 100, 33]
|
||||
@@ -283,7 +283,7 @@ def main() -> None:
|
||||
# Test 4: Boundary über Chunk-Grenzen verteilt
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 4: Boundary über Chunk-Grenzen verteilt")
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=fake_webm)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=fake_webm)
|
||||
# Boundary-String finden und Chunk-Grenze genau dorthin setzen
|
||||
boundary_str = b"--testboundary123"
|
||||
idx = mp.find(boundary_str, 10) # zweite Boundary (vor file)
|
||||
@@ -310,7 +310,7 @@ def main() -> None:
|
||||
# Test 5: Chunk Extensions
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 5: Chunk Extensions")
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=fake_webm)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=fake_webm)
|
||||
chunks_ext = [
|
||||
(mp[:20], "ext1=value1"),
|
||||
(mp[20:60], None),
|
||||
@@ -335,7 +335,7 @@ def main() -> None:
|
||||
# hier explizit mit Trailer)
|
||||
# ------------------------------------------------------------------
|
||||
print("Test 6: 0-Chunk mit Trailer")
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=fake_webm)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=fake_webm)
|
||||
chunked = build_chunked_body([mp])
|
||||
# Trailer hinzufügen
|
||||
chunked_with_trailer = chunked.replace(
|
||||
@@ -376,7 +376,7 @@ def main() -> None:
|
||||
print("Test 8: Uploadgrößenlimit")
|
||||
# MAX_UPLOAD_SIZE = 1 MB, also 2 MB senden
|
||||
big_data = b"A" * (2 * 1024 * 1024)
|
||||
mp = build_multipart({"model": "whisper-1"}, file_data=big_data)
|
||||
mp = build_multipart({"model": "qwen3-asr"}, file_data=big_data)
|
||||
chunked = build_chunked_body([mp[:1024 * 1024], mp[1024 * 1024:]])
|
||||
raw = (
|
||||
b"POST /v1/audio/transcriptions HTTP/1.1\r\n"
|
||||
@@ -402,7 +402,7 @@ def main() -> None:
|
||||
+ b"WEBM_OPUS_AUDIO_DATA" * 100)
|
||||
boundary = "950bd961b24c4a32801e31b128c85e09"
|
||||
mp = build_multipart(
|
||||
{"model": "whisper-1", "language": "de"},
|
||||
{"model": "qwen3-asr", "language": "de"},
|
||||
file_data=webm_data,
|
||||
filename="recording.webm",
|
||||
boundary=boundary,
|
||||
|
||||
+12
-12
@@ -71,13 +71,13 @@ def test_quoted_boundary():
|
||||
boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"
|
||||
webm = b"\x1a\x45\xdf\xa3" + b"\x00\x01\x02\x03\xff\xfe\xfd" * 50
|
||||
body, ct = build(
|
||||
[("model", "whisper-1", None), ("file", webm, "t.webm")],
|
||||
[("model", "qwen3-asr", None), ("file", webm, "t.webm")],
|
||||
boundary, quoted=True,
|
||||
)
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == webm, "file_data mismatch"
|
||||
assert fn == "t.webm", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
print(" quoted boundary: OK")
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ def test_openwebui_style():
|
||||
f"\r\n--{boundary}\r\n"
|
||||
f'Content-Disposition: form-data; name="model"\r\n'
|
||||
f"\r\n"
|
||||
f"whisper-1\r\n"
|
||||
f"qwen3-asr\r\n"
|
||||
f"--{boundary}\r\n"
|
||||
f'Content-Disposition: form-data; name="temperature"\r\n'
|
||||
f"\r\n"
|
||||
@@ -119,7 +119,7 @@ def test_openwebui_style():
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == webm, "file_data mismatch"
|
||||
assert fn == "rec.webm", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
assert fl["temperature"] == "0.0", f"temperature mismatch: {fl!r}"
|
||||
print(" Open-WebUI-artig: OK")
|
||||
|
||||
@@ -128,13 +128,13 @@ def test_file_before_model():
|
||||
"""File-Feld vor model-Feld."""
|
||||
boundary = "boundary123"
|
||||
body, ct = build(
|
||||
[("file", b"DATA", "f.wav"), ("model", "whisper-1", None)],
|
||||
[("file", b"DATA", "f.wav"), ("model", "qwen3-asr", None)],
|
||||
boundary, quoted=False,
|
||||
)
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == b"DATA", "file_data mismatch"
|
||||
assert fn == "f.wav", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
print(" File vor model: OK")
|
||||
|
||||
|
||||
@@ -142,13 +142,13 @@ def test_file_after_model():
|
||||
"""model-Feld vor File-Feld."""
|
||||
boundary = "boundary456"
|
||||
body, ct = build(
|
||||
[("model", "whisper-1", None), ("file", b"DATA", "g.wav")],
|
||||
[("model", "qwen3-asr", None), ("file", b"DATA", "g.wav")],
|
||||
boundary, quoted=False,
|
||||
)
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == b"DATA", "file_data mismatch"
|
||||
assert fn == "g.wav", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
print(" File nach model: OK")
|
||||
|
||||
|
||||
@@ -182,13 +182,13 @@ def test_extra_headers_ignored():
|
||||
f"\r\n--{boundary}\r\n"
|
||||
f'Content-Disposition: form-data; name="model"\r\n'
|
||||
f"\r\n"
|
||||
f"whisper-1\r\n"
|
||||
f"qwen3-asr\r\n"
|
||||
f"--{boundary}--\r\n"
|
||||
).encode()
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == webm, "file_data mismatch"
|
||||
assert fn == "x.webm", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
print(" Extra-Header ignoriert: OK")
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ def test_all_fields():
|
||||
body, ct = build(
|
||||
[
|
||||
("file", b"AUDIO", "a.webm"),
|
||||
("model", "whisper-1", None),
|
||||
("model", "qwen3-asr", None),
|
||||
("language", "de", None),
|
||||
("prompt", "Kontext", None),
|
||||
("response_format", "verbose_json", None),
|
||||
@@ -209,7 +209,7 @@ def test_all_fields():
|
||||
fd, fn, fl = parse_multipart(body, ct)
|
||||
assert fd == b"AUDIO", "file_data mismatch"
|
||||
assert fn == "a.webm", f"filename mismatch: {fn!r}"
|
||||
assert fl["model"] == "whisper-1", f"model mismatch: {fl!r}"
|
||||
assert fl["model"] == "qwen3-asr", f"model mismatch: {fl!r}"
|
||||
assert fl["language"] == "de", f"language mismatch: {fl!r}"
|
||||
assert fl["prompt"] == "Kontext", f"prompt mismatch: {fl!r}"
|
||||
assert fl["response_format"] == "verbose_json", f"response_format mismatch: {fl!r}"
|
||||
|
||||
Reference in New Issue
Block a user