Mercurial
annotate dictation/webrtc_test.py @ 280:49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 18 Aug 2026 19:14:53 -0700 |
| parents | 78699f810817 |
| children |
| rev | line source |
|---|---|
|
275
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
1 import asyncio |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
2 import json |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
3 import math |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
4 from pathlib import Path |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
5 import tempfile |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
6 import unittest |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
7 import wave |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
8 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
9 from aiortc import RTCPeerConnection, RTCSessionDescription |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
10 from aiortc.contrib.media import MediaPlayer |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
11 import numpy as np |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
12 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
13 from dictation.config import DictationConfig |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
14 from dictation.server import DictationService, Offer |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
15 from dictation.transcriber import Transcript |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
16 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
17 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
18 class FakeTranscriber: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
19 async def warmup(self): |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
20 return None |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
21 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
22 async def transcribe(self, samples, *, final): |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
23 return Transcript( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
24 "final transcript" if final else "partial transcript", |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
25 "en", |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
26 0.99, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
27 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
28 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
29 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
30 def write_test_audio(path: str) -> None: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
31 sample_rate = 16000 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
32 speech = np.array( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
33 [ |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
34 int(1600 * math.sin(2 * math.pi * 440 * index / sample_rate)) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
35 for index in range(sample_rate * 2) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
36 ], |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
37 dtype=np.int16, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
38 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
39 silence = np.zeros(sample_rate, dtype=np.int16) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
40 with wave.open(path, "wb") as output: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
41 output.setnchannels(1) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
42 output.setsampwidth(2) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
43 output.setframerate(sample_rate) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
44 output.writeframes(np.concatenate((speech, silence)).tobytes()) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
45 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
46 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
47 def test_config() -> DictationConfig: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
48 return DictationConfig( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
49 host="127.0.0.1", |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
50 port=8090, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
51 model_dir=Path("/tmp/model"), |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
52 compute_type="int8_float16", |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
53 max_sessions=1, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
54 partial_interval_ms=500, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
55 silence_ms=200, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
56 max_utterance_seconds=5, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
57 speech_threshold=0.01, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
58 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
59 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
60 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
61 class WebRtcTest(unittest.IsolatedAsyncioTestCase): |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
62 async def test_audio_track_returns_transcript_events(self): |
|
280
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
63 loop_errors = [] |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
64 loop = asyncio.get_running_loop() |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
65 previous_exception_handler = loop.get_exception_handler() |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
66 loop.set_exception_handler( |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
67 lambda _loop, context: loop_errors.append(context) |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
68 ) |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
69 self.addCleanup( |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
70 loop.set_exception_handler, |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
71 previous_exception_handler, |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
72 ) |
|
275
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
73 service = DictationService(test_config(), FakeTranscriber()) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
74 await service.start() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
75 client = RTCPeerConnection() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
76 channel = client.createDataChannel("transcripts") |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
77 messages = [] |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
78 final_received = asyncio.Event() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
79 audio_file = tempfile.NamedTemporaryFile(suffix=".wav", delete=False) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
80 audio_file.close() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
81 write_test_audio(audio_file.name) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
82 player = MediaPlayer(audio_file.name) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
83 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
84 @channel.on("message") |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
85 def on_message(message): |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
86 event = json.loads(message) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
87 messages.append(event) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
88 if event["type"] == "transcript.final": |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
89 final_received.set() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
90 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
91 client.addTrack(player.audio) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
92 offer = await client.createOffer() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
93 await client.setLocalDescription(offer) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
94 answer = await service.accept_offer( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
95 Offer( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
96 sdp=client.localDescription.sdp, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
97 type=client.localDescription.type, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
98 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
99 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
100 await client.setRemoteDescription( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
101 RTCSessionDescription( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
102 sdp=answer["sdp"], |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
103 type=answer["type"], |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
104 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
105 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
106 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
107 try: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
108 try: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
109 await asyncio.wait_for(final_received.wait(), timeout=10) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
110 except TimeoutError as error: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
111 server_states = [ |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
112 { |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
113 "connection": session.peer.connectionState, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
114 "ice": session.peer.iceConnectionState, |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
115 "channel": ( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
116 session.channel.readyState |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
117 if session.channel is not None |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
118 else None |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
119 ), |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
120 "audioTask": ( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
121 "missing" |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
122 if session.audio_task is None |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
123 else ( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
124 repr(session.audio_task.exception()) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
125 if session.audio_task.done() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
126 and not session.audio_task.cancelled() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
127 else "running" |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
128 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
129 ), |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
130 } |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
131 for session in service.sessions.values() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
132 ] |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
133 self.fail( |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
134 "Timed out waiting for transcript: " |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
135 f"client={client.connectionState}/" |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
136 f"{client.iceConnectionState}, " |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
137 f"server={server_states}, messages={messages}" |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
138 ) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
139 event_types = [message["type"] for message in messages] |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
140 self.assertIn("ready", event_types) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
141 self.assertIn("speech.started", event_types) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
142 self.assertIn("transcript.partial", event_types) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
143 self.assertIn("transcript.final", event_types) |
|
280
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
144 channel.send("commit") |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
145 await asyncio.sleep(0.2) |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
146 self.assertNotEqual(client.connectionState, "closed") |
|
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
147 self.assertIn(answer["sessionId"], service.sessions) |
|
275
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
148 finally: |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
149 await client.close() |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
150 await service.close() |
|
280
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
151 await asyncio.sleep(0.6) |
|
275
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
152 Path(audio_file.name).unlink(missing_ok=True) |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
153 self.assertEqual(service.sessions, {}) |
|
280
49e9e591c9bb
Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
MrJuneJune <me@mrjunejune.com>
parents:
275
diff
changeset
|
154 self.assertEqual(loop_errors, []) |
|
275
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
155 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
156 |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
157 if __name__ == "__main__": |
|
78699f810817
Add Qwen3-VL and WebRTC dictation services
MrJuneJune <me@mrjunejune.com>
parents:
diff
changeset
|
158 unittest.main() |