Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat(dictation): stream Orukeet through managed Cloud sessions (#2231)

Nathan Roll67dee550db7a
diff --git a/docs/integrations/orukeet/benchmark-results.json b/docs/integrations/orukeet/benchmark-results.json
new file mode 100644
index 000000000..733cec8a9
--- /dev/null
+++ b/docs/integrations/orukeet/benchmark-results.json
@@ -0,0 +1,1644 @@
+{
+ "measuredDate": "2026-09-16",
+ "endpoint": "orukeet.gizmovoice.ai",
+ "metric": "Streaming PCM commit/stop to final transcript, after uploading during recording",
+ "fixtureSeconds": 10,
+ "sourceSummarySha256": "452f509dbba8303e93044693972db4341c148b30709d98c7f569c895a1de1dc7",
+ "fixtureSha256": "bfc3e8cf9e2aa3f7a585a650511d7500cadac481ade9ab365048fd8e4578d4d9",
+ "regions": {
+ "us-west1": {
+ "cloudflare-latency": {
+ "runs": 3,
+ "completed": 15,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 15,
+ "p50": 37.39811500418,
+ "p95": 88.65351490385365,
+ "min": 34.35369899671059,
+ "max": 88.70478499738965
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 15,
+ "p50": 15.276114994776435,
+ "p95": 15.773231702041812,
+ "min": 15.159067988861352,
+ "max": 16.10299400635995
+ },
+ "server_ms": {
+ "n": 15,
+ "p50": 16.950614997767843,
+ "p95": 17.570555403653998,
+ "min": 16.73667698923964,
+ "max": 17.92639199993573
+ },
+ "queue_ms": {
+ "n": 15,
+ "p50": 0.04797799920197576,
+ "p95": 0.08205189951695502,
+ "min": 0.044132000766694546,
+ "max": 0.08318800246343017
+ },
+ "connect_ready_ms": {
+ "n": 3,
+ "p50": 167.69088999717496,
+ "p95": 238.88416149566183,
+ "min": 146.82351199735422,
+ "max": 246.7945249954937
+ },
+ "throughput_per_run": [0.09939345511178033, 0.09827827554312317, 0.09939155972399391],
+ "throughput_median": 0.09939155972399391,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["us-west1"],
+ "cloudflare_colos": ["PDX", "SEA"]
+ },
+ "cloudflare-capacity": {
+ "runs": 3,
+ "completed": 2400,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 2400,
+ "p50": 88.95987099822378,
+ "p95": 136.0882603410573,
+ "min": 35.92747500806581,
+ "max": 243.29013300302904
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 2400,
+ "p50": 21.697413991205394,
+ "p95": 23.0595853048726,
+ "min": 13.906816995586269,
+ "max": 24.91190099681262
+ },
+ "server_ms": {
+ "n": 2400,
+ "p50": 49.52179400424939,
+ "p95": 70.86002785435994,
+ "min": 15.121917007490993,
+ "max": 77.73033299599774
+ },
+ "queue_ms": {
+ "n": 2400,
+ "p50": 25.396536497282796,
+ "p95": 46.58383109344868,
+ "min": 0.03370799822732806,
+ "max": 53.07964999519754
+ },
+ "connect_ready_ms": {
+ "n": 24,
+ "p50": 343.03431500302395,
+ "p95": 423.6987250522361,
+ "min": 307.0219020009972,
+ "max": 425.0976720068138
+ },
+ "throughput_per_run": [65.8849305674157, 62.777211413971074, 63.369972629500495],
+ "throughput_median": 63.369972629500495,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["us-west1"],
+ "cloudflare_colos": ["PDX", "SEA"]
+ },
+ "cloudflare-steady-capacity": {
+ "runs": 3,
+ "completed": 5257,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 5257,
+ "p50": 139.06356900406536,
+ "p95": 370.829886404681,
+ "min": 39.171791009721346,
+ "max": 1398.2839069940383
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 5257,
+ "p50": 22.2091400064528,
+ "p95": 23.858899003244005,
+ "min": 14.048659999389201,
+ "max": 26.547198998741806
+ },
+ "server_ms": {
+ "n": 5257,
+ "p50": 76.89273700816557,
+ "p95": 91.61225579446182,
+ "min": 16.33158398908563,
+ "max": 99.97175700846128
+ },
+ "queue_ms": {
+ "n": 5257,
+ "p50": 52.85092300618999,
+ "p95": 67.17252980452031,
+ "min": 0.03820299752987921,
+ "max": 74.49111799360253
+ },
+ "connect_ready_ms": {
+ "n": 48,
+ "p50": 597.4099515005946,
+ "p95": 826.7456596971897,
+ "min": 534.0082990005612,
+ "max": 1044.6568059996935
+ },
+ "throughput_per_run": [86.6, 86.8, 87.05],
+ "throughput_median": 86.8,
+ "total_capacity_retries": 2385,
+ "max_capacity_retries_for_one_utterance": 8,
+ "served_regions": ["us-west1"],
+ "cloudflare_colos": ["PDX", "SEA"]
+ },
+ "cloudflare-paced-load": {
+ "runs": 3,
+ "completed": 288,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 288,
+ "p50": 34.66434350411873,
+ "p95": 89.87392539274877,
+ "min": 30.439975002082065,
+ "max": 196.71407500572968
+ },
+ "capture_stop_to_final_ms": {
+ "n": 288,
+ "p50": 35.309218503243756,
+ "p95": 90.93446294791646,
+ "min": 30.890774985891767,
+ "max": 197.26837999769486
+ },
+ "inference_ms": {
+ "n": 288,
+ "p50": 15.490844001760706,
+ "p95": 16.29103334780666,
+ "min": 14.201917001628317,
+ "max": 16.78279199404642
+ },
+ "server_ms": {
+ "n": 288,
+ "p50": 17.233126003702637,
+ "p95": 18.30052670338773,
+ "min": 15.546914000879042,
+ "max": 34.70938799728174
+ },
+ "queue_ms": {
+ "n": 288,
+ "p50": 0.0480739981867373,
+ "p95": 0.08691265611560078,
+ "min": 0.03552999987732619,
+ "max": 16.626498007099144
+ },
+ "connect_ready_ms": {
+ "n": 96,
+ "p50": 1054.1702409973368,
+ "p95": 1149.532678504329,
+ "min": 1004.5032560010441,
+ "max": 1162.4567849939922
+ },
+ "throughput_per_run": [2.3735064769183123, 2.389934000276688, 2.391007786079151],
+ "throughput_median": 2.389934000276688,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["us-west1"],
+ "cloudflare_colos": ["PDX", "SEA"]
+ }
+ },
+ "europe-west4": {
+ "cloudflare-latency": {
+ "runs": 3,
+ "completed": 15,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 15,
+ "p50": 28.496206003183033,
+ "p95": 31.198537995078368,
+ "min": 27.581046997511294,
+ "max": 31.566758996632416
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 15,
+ "p50": 15.325889995438047,
+ "p95": 16.682437599956756,
+ "min": 15.190432000963483,
+ "max": 16.725307003071066
+ },
+ "server_ms": {
+ "n": 15,
+ "p50": 16.941488000156824,
+ "p95": 18.456098200840643,
+ "min": 16.784707993792836,
+ "max": 18.586314996355213
+ },
+ "queue_ms": {
+ "n": 15,
+ "p50": 0.04955600161338225,
+ "p95": 0.07745909751974978,
+ "min": 0.043467996874824166,
+ "max": 0.07942399679450318
+ },
+ "connect_ready_ms": {
+ "n": 3,
+ "p50": 116.39142499916488,
+ "p95": 135.09943970129825,
+ "min": 111.87697000423213,
+ "max": 137.1781080015353
+ },
+ "throughput_per_run": [0.09957181650715546, 0.09953240139457036, 0.09957360222439111],
+ "throughput_median": 0.09957181650715546,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["europe-west4"],
+ "cloudflare_colos": ["AMS"]
+ },
+ "cloudflare-capacity": {
+ "runs": 3,
+ "completed": 2400,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 2400,
+ "p50": 84.96778600238031,
+ "p95": 88.11109775015211,
+ "min": 38.611387004493736,
+ "max": 124.72904899914283
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 2400,
+ "p50": 20.854217502346728,
+ "p95": 21.774439456567052,
+ "min": 14.076924002438318,
+ "max": 22.612469001614954
+ },
+ "server_ms": {
+ "n": 2400,
+ "p50": 71.3542609992146,
+ "p95": 74.75498144885933,
+ "min": 21.572060002654325,
+ "max": 103.65517800528323
+ },
+ "queue_ms": {
+ "n": 2400,
+ "p50": 48.858554000617005,
+ "p95": 51.715754147517146,
+ "min": 0.0642140003037639,
+ "max": 79.793539000093
+ },
+ "connect_ready_ms": {
+ "n": 24,
+ "p50": 300.9320055025455,
+ "p95": 311.9738512526965,
+ "min": 275.61356599471765,
+ "max": 346.4899619939388
+ },
+ "throughput_per_run": [92.342972703996, 92.83519503637766, 92.4656425842433],
+ "throughput_median": 92.4656425842433,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["europe-west4"],
+ "cloudflare_colos": ["AMS"]
+ },
+ "cloudflare-steady-capacity": {
+ "runs": 3,
+ "completed": 5517,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 5517,
+ "p50": 88.04546699684579,
+ "p95": 543.9681823976571,
+ "min": 38.48152199498145,
+ "max": 1905.5146149985376
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 5517,
+ "p50": 21.360853002988733,
+ "p95": 22.574934201838914,
+ "min": 13.881232000130694,
+ "max": 23.74992799741449
+ },
+ "server_ms": {
+ "n": 5517,
+ "p50": 74.68627400521655,
+ "p95": 87.20658700331114,
+ "min": 15.404620004119352,
+ "max": 105.0813929978176
+ },
+ "queue_ms": {
+ "n": 5517,
+ "p50": 51.48413399729179,
+ "p95": 64.08300040056929,
+ "min": 0.03493000258458778,
+ "max": 81.7580029979581
+ },
+ "connect_ready_ms": {
+ "n": 48,
+ "p50": 541.8293780021486,
+ "p95": 555.8051784464624,
+ "min": 502.6445320036146,
+ "max": 575.3484009983367
+ },
+ "throughput_per_run": [91.15, 91.45, 90.85],
+ "throughput_median": 91.15,
+ "total_capacity_retries": 4118,
+ "max_capacity_retries_for_one_utterance": 16,
+ "served_regions": ["europe-west4"],
+ "cloudflare_colos": ["AMS"]
+ },
+ "cloudflare-paced-load": {
+ "runs": 3,
+ "completed": 288,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 288,
+ "p50": 28.54358299737214,
+ "p95": 30.39052444510162,
+ "min": 26.03060399997048,
+ "max": 49.49536200001603
+ },
+ "capture_stop_to_final_ms": {
+ "n": 288,
+ "p50": 29.156679000152508,
+ "p95": 31.24427459879371,
+ "min": 26.690724000218324,
+ "max": 49.61990300216712
+ },
+ "inference_ms": {
+ "n": 288,
+ "p50": 15.375995000795228,
+ "p95": 16.0796141019091,
+ "min": 14.279101000283845,
+ "max": 17.8862980028498
+ },
+ "server_ms": {
+ "n": 288,
+ "p50": 17.075132000172744,
+ "p95": 17.886656849077553,
+ "min": 15.547433999017812,
+ "max": 24.71397500630701
+ },
+ "queue_ms": {
+ "n": 288,
+ "p50": 0.047325000195996836,
+ "p95": 0.07856154988985509,
+ "min": 0.03450899384915829,
+ "max": 8.209888001147192
+ },
+ "connect_ready_ms": {
+ "n": 96,
+ "p50": 1040.475415000401,
+ "p95": 1057.383997251236,
+ "min": 1004.3532330018934,
+ "max": 1082.2008879986242
+ },
+ "throughput_per_run": [2.3928500498522447, 2.3925434322160215, 2.393655452198392],
+ "throughput_median": 2.3928500498522447,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["europe-west4"],
+ "cloudflare_colos": ["AMS"]
+ }
+ },
+ "asia-southeast1": {
+ "cloudflare-latency": {
+ "runs": 3,
+ "completed": 15,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 15,
+ "p50": 23.199657000077423,
+ "p95": 26.792576604202623,
+ "min": 21.75484100007452,
+ "max": 27.253346001089085
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 15,
+ "p50": 15.258936997270212,
+ "p95": 17.727760400885018,
+ "min": 15.154314998653717,
+ "max": 17.78070000000298
+ },
+ "server_ms": {
+ "n": 15,
+ "p50": 16.836927003168967,
+ "p95": 19.959851400199113,
+ "min": 16.719380997528788,
+ "max": 20.102684997254983
+ },
+ "queue_ms": {
+ "n": 15,
+ "p50": 0.04705500032287091,
+ "p95": 0.06893519821460359,
+ "min": 0.044911001168657094,
+ "max": 0.07168899901444092
+ },
+ "connect_ready_ms": {
+ "n": 3,
+ "p50": 100.40146100072889,
+ "p95": 111.56334110055468,
+ "min": 92.69537199725164,
+ "max": 112.80355000053532
+ },
+ "throughput_per_run": [0.0996728913184443, 0.09967344375757732, 0.09970702322407601],
+ "throughput_median": 0.09967344375757732,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["asia-southeast1"],
+ "cloudflare_colos": ["SIN"]
+ },
+ "cloudflare-capacity": {
+ "runs": 3,
+ "completed": 2400,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 2400,
+ "p50": 85.42219300215947,
+ "p95": 88.93836389870557,
+ "min": 32.96060899447184,
+ "max": 115.7482480048202
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 2400,
+ "p50": 20.940153000992723,
+ "p95": 22.177108003234025,
+ "min": 13.971345004392788,
+ "max": 23.369157999695744
+ },
+ "server_ms": {
+ "n": 2400,
+ "p50": 77.68924650008557,
+ "p95": 81.76296104575158,
+ "min": 23.07502799521899,
+ "max": 103.86272100004135
+ },
+ "queue_ms": {
+ "n": 2400,
+ "p50": 54.96105150086805,
+ "p95": 58.499097447202075,
+ "min": 0.06627300172112882,
+ "max": 80.69560099829687
+ },
+ "connect_ready_ms": {
+ "n": 24,
+ "p50": 281.89902649683063,
+ "p95": 293.7796431040624,
+ "min": 259.5967000015662,
+ "max": 300.89746299927356
+ },
+ "throughput_per_run": [91.44258943121791, 93.16471917095664, 93.09232229596887],
+ "throughput_median": 93.09232229596887,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["asia-southeast1"],
+ "cloudflare_colos": ["SIN"]
+ },
+ "cloudflare-steady-capacity": {
+ "runs": 3,
+ "completed": 5463,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 5463,
+ "p50": 90.45207400049549,
+ "p95": 511.28158350111323,
+ "min": 32.823041001392994,
+ "max": 2579.0176219961722
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 5463,
+ "p50": 21.573671001533512,
+ "p95": 22.9751570004737,
+ "min": 14.280791001510806,
+ "max": 25.305893999757245
+ },
+ "server_ms": {
+ "n": 5463,
+ "p50": 81.64321500225924,
+ "p95": 88.40585729994928,
+ "min": 15.725518002000172,
+ "max": 106.88002399547258
+ },
+ "queue_ms": {
+ "n": 5463,
+ "p50": 57.970540001406334,
+ "p95": 64.80719940082054,
+ "min": 0.03378799738129601,
+ "max": 80.8847340013017
+ },
+ "connect_ready_ms": {
+ "n": 48,
+ "p50": 520.995065497118,
+ "p95": 541.1208228983014,
+ "min": 500.1859850017354,
+ "max": 566.5393649978796
+ },
+ "throughput_per_run": [90.45, 89.45, 90.85],
+ "throughput_median": 90.45,
+ "total_capacity_retries": 4385,
+ "max_capacity_retries_for_one_utterance": 23,
+ "served_regions": ["asia-southeast1"],
+ "cloudflare_colos": ["SIN"]
+ },
+ "cloudflare-paced-load": {
+ "runs": 3,
+ "completed": 288,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 288,
+ "p50": 22.862000503664603,
+ "p95": 24.95292150197201,
+ "min": 19.81763300136663,
+ "max": 30.674941001052503
+ },
+ "capture_stop_to_final_ms": {
+ "n": 288,
+ "p50": 23.525642998720286,
+ "p95": 25.68866324654664,
+ "min": 20.22723900154233,
+ "max": 31.292591003875714
+ },
+ "inference_ms": {
+ "n": 288,
+ "p50": 15.265287001966499,
+ "p95": 16.13629304811184,
+ "min": 14.108852999925148,
+ "max": 17.823153000790626
+ },
+ "server_ms": {
+ "n": 288,
+ "p50": 16.874447999725817,
+ "p95": 17.901847350003663,
+ "min": 15.351269001257606,
+ "max": 23.432488000253215
+ },
+ "queue_ms": {
+ "n": 288,
+ "p50": 0.04677800097852014,
+ "p95": 0.07071080035530028,
+ "min": 0.03563499922165647,
+ "max": 7.698952002101578
+ },
+ "connect_ready_ms": {
+ "n": 96,
+ "p50": 1006.4408890029881,
+ "p95": 1036.4956009998423,
+ "min": 997.3075759990024,
+ "max": 1039.4030210009078
+ },
+ "throughput_per_run": [2.395512830349654, 2.3955011918684406, 2.395576356787422],
+ "throughput_median": 2.395512830349654,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["asia-southeast1"],
+ "cloudflare_colos": ["SIN"]
+ }
+ }
+ },
+ "mac": {
+ "runs": 1,
+ "completed": 15,
+ "errors": [],
+ "transcript_mismatches": 0,
+ "commit_to_final_ms": {
+ "n": 15,
+ "p50": 92.27562503656372,
+ "p95": 144.78671620017846,
+ "min": 70.19033399410546,
+ "max": 160.35862499848008
+ },
+ "capture_stop_to_final_ms": {
+ "n": 0
+ },
+ "inference_ms": {
+ "n": 15,
+ "p50": 15.320314007112756,
+ "p95": 15.579477700521238,
+ "min": 15.223711990984157,
+ "max": 15.748170000733808
+ },
+ "server_ms": {
+ "n": 15,
+ "p50": 17.036866003763862,
+ "p95": 17.359658896748442,
+ "min": 16.87808000133373,
+ "max": 17.569465009728447
+ },
+ "queue_ms": {
+ "n": 15,
+ "p50": 0.04826999793294817,
+ "p95": 0.0629658985417336,
+ "min": 0.04413900023791939,
+ "max": 0.0791729980846867
+ },
+ "connect_ready_ms": {
+ "n": 1,
+ "p50": 204.86245903884992,
+ "p95": 204.86245903884992,
+ "min": 204.86245903884992,
+ "max": 204.86245903884992
+ },
+ "throughput_per_run": [0.09810585801775057],
+ "throughput_median": 0.09810585801775057,
+ "total_capacity_retries": 0,
+ "max_capacity_retries_for_one_utterance": 0,
+ "served_regions": ["us-west1"],
+ "cloudflare_colos": ["SJC"]
+ },
+ "pacedPeakConnections": 96,
+ "pacedFinals": 864,
+ "totalNativeFinals": 24361,
+ "liveChecks": 189,
+ "nativeLatencySamples": [
+ {
+ "source": "cloudflare-latency-asia-southeast1-1.json",
+ "sourceSha256": "9b4c227036e8737c10355bea18a6b61981e19c3f8e544661a6d506a320021bd4",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 27.253346001089085,
+ "ping_ms": 6.092019000789151,
+ "recording_to_final_ms": 10028.075598995201,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 19.898637001460884,
+ "inference_ms": 17.705072001263034,
+ "queue_ms": 0.07168899901444092,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.76402899972163,
+ "ping_ms": 5.990957994072232,
+ "recording_to_final_ms": 10024.518033998902,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.7647050038795,
+ "inference_ms": 15.227137999318074,
+ "queue_ms": 0.04557499778456986,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.023262001515832,
+ "ping_ms": 6.39027199940756,
+ "recording_to_final_ms": 10023.282890004339,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.795151997939683,
+ "inference_ms": 15.19696199829923,
+ "queue_ms": 0.048380999942310154,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.316201004490722,
+ "ping_ms": 5.96768400282599,
+ "recording_to_final_ms": 10023.585499002365,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.72972800588468,
+ "inference_ms": 15.184959003818221,
+ "queue_ms": 0.04646500019589439,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.46991700323997,
+ "ping_ms": 6.988883003941737,
+ "recording_to_final_ms": 10023.754161004035,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.763710998930037,
+ "inference_ms": 15.238045001751743,
+ "queue_ms": 0.04759400326292962,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-asia-southeast1-2.json",
+ "sourceSha256": "b934389a9ce263ee953531513e80b8e9a3804fd5466dda5f220d3ece723eca9e",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 26.595104005536996,
+ "ping_ms": 8.50642199657159,
+ "recording_to_final_ms": 10027.424914005678,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 20.102684997254983,
+ "inference_ms": 17.78070000000298,
+ "queue_ms": 0.06775499787181616,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.18995499808807,
+ "ping_ms": 6.030534001183696,
+ "recording_to_final_ms": 10023.79671199742,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.90967600006843,
+ "inference_ms": 15.323642001021653,
+ "queue_ms": 0.04705500032287091,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.038530998746864,
+ "ping_ms": 5.709247998311184,
+ "recording_to_final_ms": 10024.083343996608,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.8264169988106,
+ "inference_ms": 15.251261000230443,
+ "queue_ms": 0.05604299803962931,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.22474300308386,
+ "ping_ms": 6.034694997651968,
+ "recording_to_final_ms": 10024.241322003945,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.88082899636356,
+ "inference_ms": 15.347312000812963,
+ "queue_ms": 0.045382003008853644,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.880839995399583,
+ "ping_ms": 6.318950996501371,
+ "recording_to_final_ms": 10024.491408999893,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.886153003724758,
+ "inference_ms": 15.306672001315746,
+ "queue_ms": 0.04785600322065875,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-asia-southeast1-3.json",
+ "sourceSha256": "fe84c2c8ed9a5f4e4f845bd70811995312c688f5df18d60f7319ca6b07982d5a",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 23.199657000077423,
+ "ping_ms": 5.189557996345684,
+ "recording_to_final_ms": 10024.04533799563,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 18.022110998572316,
+ "inference_ms": 16.299977993185166,
+ "queue_ms": 0.055222000810317695,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 21.79774399701273,
+ "ping_ms": 5.880354001419619,
+ "recording_to_final_ms": 10022.770158997446,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.836927003168967,
+ "inference_ms": 15.243453002767637,
+ "queue_ms": 0.044911001168657094,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 22.403533999749925,
+ "ping_ms": 4.9448499994468875,
+ "recording_to_final_ms": 10023.553259998152,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.20164099970134,
+ "inference_ms": 15.623853003489785,
+ "queue_ms": 0.04665899905376136,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 21.833202001289465,
+ "ping_ms": 4.926456000248436,
+ "recording_to_final_ms": 10022.24751799804,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.834413996548392,
+ "inference_ms": 15.258936997270212,
+ "queue_ms": 0.04665600135922432,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "asia-southeast1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 21.75484100007452,
+ "ping_ms": 4.771282001456711,
+ "recording_to_final_ms": 10022.313537003356,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.719380997528788,
+ "inference_ms": 15.154314998653717,
+ "queue_ms": 0.04535799962468445,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-california-mac.json",
+ "sourceSha256": "1a60711cbc3217407b939c1dff380bdc38090904d7ea2370520401b5bbdb7de9",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 94.92104197852314,
+ "ping_ms": 71.70474994927645,
+ "recording_to_final_ms": 10097.105459019076,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.269741991185583,
+ "inference_ms": 15.507181000430137,
+ "queue_ms": 0.05370400322135538,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 76.27862499793991,
+ "ping_ms": 74.1206249804236,
+ "recording_to_final_ms": 10077.863916987553,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.956976003712043,
+ "inference_ms": 15.282127991667949,
+ "queue_ms": 0.04413900023791939,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 92.27562503656372,
+ "ping_ms": 70.99366700276732,
+ "recording_to_final_ms": 10092.783666041214,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.00557500589639,
+ "inference_ms": 15.320314007112756,
+ "queue_ms": 0.0505780044477433,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 72.9330830508843,
+ "ping_ms": 58.68908402044326,
+ "recording_to_final_ms": 10073.56329105096,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.105342005379498,
+ "inference_ms": 15.290235009160824,
+ "queue_ms": 0.04609499592334032,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 160.35862499848008,
+ "ping_ms": 111.0183330019936,
+ "recording_to_final_ms": 10162.710791977588,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.109348002122715,
+ "inference_ms": 15.436589004821144,
+ "queue_ms": 0.0791729980846867,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 5,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 121.19625002378598,
+ "ping_ms": 59.437666030135006,
+ "recording_to_final_ms": 10123.124917037785,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.172599997138605,
+ "inference_ms": 15.3971390100196,
+ "queue_ms": 0.050085989641956985,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 6,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 81.66754199191928,
+ "ping_ms": 62.63591698370874,
+ "recording_to_final_ms": 10083.943458972499,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.036866003763862,
+ "inference_ms": 15.329606991144828,
+ "queue_ms": 0.05060799594502896,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 7,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 109.28629100089893,
+ "ping_ms": 74.07466595759615,
+ "recording_to_final_ms": 10109.800082980655,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.569465009728447,
+ "inference_ms": 15.748170000733808,
+ "queue_ms": 0.046828004997223616,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 8,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 134.4482090207748,
+ "ping_ms": 187.83400004031137,
+ "recording_to_final_ms": 10134.886375046335,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.948355987551622,
+ "inference_ms": 15.286397989257239,
+ "queue_ms": 0.04434499714989215,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 9,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 98.99687499273568,
+ "ping_ms": 56.05279200244695,
+ "recording_to_final_ms": 10099.82287499588,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.187208010000177,
+ "inference_ms": 15.42712798982393,
+ "queue_ms": 0.04826999793294817,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 10,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 90.44200001517311,
+ "ping_ms": 129.39550000010058,
+ "recording_to_final_ms": 10092.567540996242,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.036752004059963,
+ "inference_ms": 15.378936994238757,
+ "queue_ms": 0.04948599962517619,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 11,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 138.11304100090638,
+ "ping_ms": 117.64437501551583,
+ "recording_to_final_ms": 10140.24000003701,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.87808000133373,
+ "inference_ms": 15.235496000968851,
+ "queue_ms": 0.05601999873761088,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 12,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 70.19033399410546,
+ "ping_ms": 110.18174997298047,
+ "recording_to_final_ms": 10072.624499967787,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.904934993362986,
+ "inference_ms": 15.223711990984157,
+ "queue_ms": 0.04723100573755801,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 13,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 74.4675419991836,
+ "ping_ms": 86.33462496800348,
+ "recording_to_final_ms": 10076.586917042732,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.209184996318072,
+ "inference_ms": 15.296803001547232,
+ "queue_ms": 0.04728799103759229,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 14,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 75.45204198686406,
+ "ping_ms": 54.048457997851074,
+ "recording_to_final_ms": 10077.806999965105,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.917667002417147,
+ "inference_ms": 15.277985003194772,
+ "queue_ms": 0.04732799425255507,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-europe-west4-1.json",
+ "sourceSha256": "d896fe33301351fa13cdc0f4150ffd0385a089a7032fbf37588a8137830b22f6",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 29.565709999587853,
+ "ping_ms": 12.69584900001064,
+ "recording_to_final_ms": 10030.55203799886,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 18.40029100276297,
+ "inference_ms": 16.725307003071066,
+ "queue_ms": 0.05080499977339059,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 28.001408994896337,
+ "ping_ms": 10.607793999952264,
+ "recording_to_final_ms": 10028.474176993768,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.804154998681042,
+ "inference_ms": 15.252502998919226,
+ "queue_ms": 0.047537003410980105,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 27.602425005170517,
+ "ping_ms": 11.706391000188887,
+ "recording_to_final_ms": 10028.514790006739,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.904107993468642,
+ "inference_ms": 15.332292001403403,
+ "queue_ms": 0.04641900159185752,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 27.581046997511294,
+ "ping_ms": 13.470452999172267,
+ "recording_to_final_ms": 10027.91198399791,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.809549000754487,
+ "inference_ms": 15.220624001813121,
+ "queue_ms": 0.043467996874824166,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 27.830685998196714,
+ "ping_ms": 10.753574002592359,
+ "recording_to_final_ms": 10028.143080999143,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.062722996342927,
+ "inference_ms": 15.377879004518036,
+ "queue_ms": 0.06303199916146696,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-europe-west4-2.json",
+ "sourceSha256": "488bb845c3e40199e0a8956e1c71519dc905f43980f7fc00f17d6640f9369ab6",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 31.040728994412348,
+ "ping_ms": 12.969109004188795,
+ "recording_to_final_ms": 10032.122630997037,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 18.218665005406365,
+ "inference_ms": 16.474787997140083,
+ "queue_ms": 0.053689997002948076,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 31.566758996632416,
+ "ping_ms": 12.786624000000302,
+ "recording_to_final_ms": 10032.434269000078,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 18.586314996355213,
+ "inference_ms": 16.664064998622052,
+ "queue_ms": 0.07942399679450318,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 30.149989004712552,
+ "ping_ms": 12.849557999288663,
+ "recording_to_final_ms": 10030.452582999715,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.1338639993337,
+ "inference_ms": 15.494698003749363,
+ "queue_ms": 0.048916997911874205,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 29.76721100276336,
+ "ping_ms": 12.950071999512147,
+ "recording_to_final_ms": 10030.026831998839,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.82267199794296,
+ "inference_ms": 15.230584998789709,
+ "queue_ms": 0.07661699783056974,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 30.11018999677617,
+ "ping_ms": 12.786345003405586,
+ "recording_to_final_ms": 10031.178857003397,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.957334999460727,
+ "inference_ms": 15.307401998143177,
+ "queue_ms": 0.04569500015350059,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-europe-west4-3.json",
+ "sourceSha256": "85ac5175a054bdaa4fbf8b70424e3e7c2c89da9f3d8fd474005ec3870625e8d2",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 28.035914998326916,
+ "ping_ms": 11.416984001698438,
+ "recording_to_final_ms": 10028.472320002038,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.784707993792836,
+ "inference_ms": 15.190432000963483,
+ "queue_ms": 0.056361997849307954,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 28.132441999332514,
+ "ping_ms": 11.2176529946737,
+ "recording_to_final_ms": 10028.36213199771,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.85738300147932,
+ "inference_ms": 15.25849800236756,
+ "queue_ms": 0.045100998249836266,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 29.596079999464564,
+ "ping_ms": 11.441898001066875,
+ "recording_to_final_ms": 10030.207891999453,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 18.195270000433084,
+ "inference_ms": 16.47285600483883,
+ "queue_ms": 0.055686999985482544,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 28.48135700332932,
+ "ping_ms": 11.175854000612162,
+ "recording_to_final_ms": 10029.282038005476,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.941488000156824,
+ "inference_ms": 15.325889995438047,
+ "queue_ms": 0.04729699867311865,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "europe-west4",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 28.496206003183033,
+ "ping_ms": 11.256179001065902,
+ "recording_to_final_ms": 10028.842519001046,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.936877997068223,
+ "inference_ms": 15.249358002620284,
+ "queue_ms": 0.04955600161338225,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-us-west1-1.json",
+ "sourceSha256": "aa0f08bb6da78502cd73e17ff076711e8628ba0b70a1335edc62fe74644c1275",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 35.67308999481611,
+ "ping_ms": 17.020864004734904,
+ "recording_to_final_ms": 10036.774929001695,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.94970800599549,
+ "inference_ms": 15.276114994776435,
+ "queue_ms": 0.04797799920197576,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 37.22403799474705,
+ "ping_ms": 19.568098010495305,
+ "recording_to_final_ms": 10037.843964004423,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.114214002504013,
+ "inference_ms": 15.377778996480629,
+ "queue_ms": 0.08156499825417995,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 36.01301700109616,
+ "ping_ms": 18.96883400331717,
+ "recording_to_final_ms": 10036.790273006773,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.263378991628997,
+ "inference_ms": 15.506285999435931,
+ "queue_ms": 0.04845600051339716,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 37.39811500418,
+ "ping_ms": 24.32180699543096,
+ "recording_to_final_ms": 10038.443891011411,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.034493997925892,
+ "inference_ms": 15.306343004340306,
+ "queue_ms": 0.04723500751424581,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 34.35369899671059,
+ "ping_ms": 19.469557999400422,
+ "recording_to_final_ms": 10035.360191002837,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.950614997767843,
+ "inference_ms": 15.262152999639511,
+ "queue_ms": 0.046743007260374725,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-us-west1-2.json",
+ "sourceSha256": "12967a9fd7d2762fc39b4aee2dd3c40b5b391e2325f14e2331e9fdb87983bb6a",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 88.63154200662393,
+ "ping_ms": 71.11922900367063,
+ "recording_to_final_ms": 10089.019717997871,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.41805400524754,
+ "inference_ms": 15.631905000191182,
+ "queue_ms": 0.08318800246343017,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 88.27429699886125,
+ "ping_ms": 71.70858100289479,
+ "recording_to_final_ms": 10089.1180250037,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.8539040023461,
+ "inference_ms": 15.23607800481841,
+ "queue_ms": 0.05424299160949886,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 88.12064499943517,
+ "ping_ms": 71.77554600639269,
+ "recording_to_final_ms": 10088.505585998064,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.033846001140773,
+ "inference_ms": 15.362391000962816,
+ "queue_ms": 0.048107001930475235,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 88.70478499738965,
+ "ping_ms": 70.97861199872568,
+ "recording_to_final_ms": 10089.671809997526,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.20411199494265,
+ "inference_ms": 15.606571003445424,
+ "queue_ms": 0.04623900167644024,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 88.32295599859208,
+ "ping_ms": 72.71947601111606,
+ "recording_to_final_ms": 10088.789008994354,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.882354990229942,
+ "inference_ms": 15.251788005116396,
+ "queue_ms": 0.04455100861378014,
+ "batch_size": 1
+ }
+ ]
+ },
+ {
+ "source": "cloudflare-latency-us-west1-3.json",
+ "sourceSha256": "89788692c1a7068e515f7baed83abcf1c5a6babed14344c952507536dea303eb",
+ "rows": [
+ {
+ "worker": 0,
+ "iteration": 0,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 39.1337610053597,
+ "ping_ms": 19.552116995328106,
+ "recording_to_final_ms": 10039.883937002742,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.850162006448954,
+ "inference_ms": 15.218393004033715,
+ "queue_ms": 0.047622001147828996,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 1,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 38.05169400584418,
+ "ping_ms": 18.13544999458827,
+ "recording_to_final_ms": 10038.456110996776,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 17.92639199993573,
+ "inference_ms": 16.10299400635995,
+ "queue_ms": 0.04956799966748804,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 2,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 36.56148300797213,
+ "ping_ms": 18.890585997723974,
+ "recording_to_final_ms": 10037.297722999938,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.928887998801656,
+ "inference_ms": 15.224422997562215,
+ "queue_ms": 0.044132000766694546,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 3,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 35.89429199928418,
+ "ping_ms": 21.263932998408563,
+ "recording_to_final_ms": 10036.60851198947,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.867825004737824,
+ "inference_ms": 15.26373700471595,
+ "queue_ms": 0.04599599924404174,
+ "batch_size": 1
+ },
+ {
+ "worker": 0,
+ "iteration": 4,
+ "region": "us-west1",
+ "audio_seconds": 10.0,
+ "end_to_final_ms": 34.555600010207854,
+ "ping_ms": 17.887713998788968,
+ "recording_to_final_ms": 10034.9461529986,
+ "capacity_retries": 0,
+ "matches_baseline": true,
+ "server_ms": 16.73667698923964,
+ "inference_ms": 15.159067988861352,
+ "queue_ms": 0.05857899668626487,
+ "batch_size": 1
+ }
+ ]
+ }
+ ]
+}
diff --git a/docs/integrations/orukeet/issue-session.cjs b/docs/integrations/orukeet/issue-session.cjs
new file mode 100644
index 000000000..7934f953b
--- /dev/null
+++ b/docs/integrations/orukeet/issue-session.cjs
@@ -0,0 +1,72 @@
+"use strict";
+
+// Backend only. Call AFTER your existing user, entitlement and rate-limit checks.
+// Never import this module or its service key into the desktop distribution.
+const BASE_URL = "https://orukeet.gizmovoice.ai";
+
+async function issueSession({
+ serviceKey,
+ accountId,
+ socketRole = "warm",
+ fetchImpl = globalThis.fetch,
+} = {}) {
+ if (typeof serviceKey !== "string" || !serviceKey.trim()) {
+ throw new Error("ORUKEET_SERVICE_KEY is required on the backend");
+ }
+ // Derive this opaque ID from the authenticated backend user, never desktop input.
+ if (
+ accountId !== undefined &&
+ (typeof accountId !== "string" || !/^[A-Za-z0-9_-]{8,128}$/.test(accountId))
+ ) {
+ throw new Error("accountId must be an opaque 8–128 character identifier");
+ }
+ if (!["warm", "active"].includes(socketRole)) {
+ throw new Error("socketRole must be warm or active");
+ }
+ let response;
+ try {
+ response = await fetchImpl(`${BASE_URL}/v1/client-token`, {
+ method: "POST",
+ headers: { Authorization: `Bearer ${serviceKey}`, "Content-Type": "application/json" },
+ body: JSON.stringify(
+ accountId === undefined ? {} : { account_id: accountId, socket_role: socketRole }
+ ),
+ signal: AbortSignal.timeout(10000),
+ redirect: "error",
+ cache: "no-store",
+ });
+ } catch {
+ throw new Error("Orukeet session service is unavailable");
+ }
+ if (!response.ok) {
+ // Do not propagate upstream response bodies, request headers or tokens.
+ throw new Error(`Orukeet session request failed (HTTP ${response.status})`);
+ }
+ let data;
+ try {
+ data = await response.json();
+ } catch {
+ throw new Error("Invalid Orukeet session response");
+ }
+ if (
+ typeof data?.token !== "string" ||
+ !/^[A-Za-z0-9._-]{1,96}$/.test(data.token) ||
+ data.single_use !== true ||
+ data.expires_in !== 60 ||
+ data.protocol !== "orukeet.pcm.v1" ||
+ (accountId !== undefined && data.account_limits !== true)
+ ) {
+ throw new Error("Invalid Orukeet session response");
+ }
+ return {
+ baseUrl: BASE_URL,
+ websocketUrl: "wss://orukeet.gizmovoice.ai/v1/audio/transcriptions/stream",
+ clientToken: data.token,
+ protocol: data.protocol,
+ expiresIn: data.expires_in,
+ singleUse: true,
+ model: "orukeet-v0.1.0",
+ };
+}
+
+module.exports = { issueSession, BASE_URL };
diff --git a/docs/integrations/orukeet/live-adapter-results.json b/docs/integrations/orukeet/live-adapter-results.json
new file mode 100644
index 000000000..50cf752c9
--- /dev/null
+++ b/docs/integrations/orukeet/live-adapter-results.json
@@ -0,0 +1,46 @@
+{
+ "measuredAt": "2026-09-17T02:58:06.956Z",
+ "method": "Paced PCM16 using the PR adapter; commit-to-final excludes token/connection setup and recording",
+ "fixtureSha256": "bfc3e8cf9e2aa3f7a585a650511d7500cadac481ade9ab365048fd8e4578d4d9",
+ "results": [
+ {
+ "run": 1,
+ "region": "us-west1",
+ "tokenIssueMs": 358.778459,
+ "connectionReadyMs": 273.755834,
+ "audioSeconds": 10,
+ "commitToFinalMs": 78.86579200000051,
+ "inferenceMs": 16.448428999865428,
+ "serverMs": 18.341424001846462,
+ "queueMs": 0.05365100514609367,
+ "transcriptMatches": true,
+ "transcriptSha256": "d496d88ac77836b7f280c4611c2d790bd747e1876d8e858fb321b42586036aab"
+ },
+ {
+ "run": 2,
+ "region": "us-west1",
+ "tokenIssueMs": 194.43737499999952,
+ "connectionReadyMs": 228.62037500000042,
+ "audioSeconds": 10,
+ "commitToFinalMs": 84.90254099999947,
+ "inferenceMs": 15.746424993267283,
+ "serverMs": 17.63169700279832,
+ "queueMs": 0.0613899901509285,
+ "transcriptMatches": true,
+ "transcriptSha256": "d496d88ac77836b7f280c4611c2d790bd747e1876d8e858fb321b42586036aab"
+ },
+ {
+ "run": 3,
+ "region": "us-west1",
+ "tokenIssueMs": 150.63637500000186,
+ "connectionReadyMs": 210.51950000000215,
+ "audioSeconds": 10,
+ "commitToFinalMs": 83.63779200000135,
+ "inferenceMs": 15.235532002407126,
+ "serverMs": 17.01977899938356,
+ "queueMs": 0.05840000812895596,
+ "transcriptMatches": true,
+ "transcriptSha256": "d496d88ac77836b7f280c4611c2d790bd747e1876d8e858fb321b42586036aab"
+ }
+ ]
+}
diff --git a/docs/orukeet-benchmarks.md b/docs/orukeet-benchmarks.md
new file mode 100644
index 000000000..095a8d16d
--- /dev/null
+++ b/docs/orukeet-benchmarks.md
@@ -0,0 +1,67 @@
+# Orukeet streaming benchmarks
+
+Measured September 16, 2026 through `https://orukeet.gizmovoice.ai`, backed by three warm NVIDIA L4 GPUs in Oregon, the Netherlands and Singapore. Each GPU is in a GCP `g2-standard-8` instance. Model: `orukeet-v0.1.0`.
+
+## Stop to final latency
+
+Ten seconds of mono PCM16 audio at 16 kHz, uploaded during simulated real-time capture. Timing begins immediately before commit after the last audio frame, and ends on the full transcript. Recording duration, session/token setup, cleanup and paste are excluded. The endpoint does not return interim words.
+
+| Client | Median | p95 | Recordings |
+| -------------------- | ------: | -------: | ---------: |
+| California Mac | 92.3 ms | 144.8 ms | 15 |
+| Oregon cloud VM | 37.4 ms | 88.7 ms | 15 |
+| Netherlands cloud VM | 28.5 ms | 31.2 ms | 15 |
+| Singapore cloud VM | 23.2 ms | 26.8 ms | 15 |
+
+Median inference was approximately 15.3 ms; median server time was approximately 17 ms. Each cloud region used three five-recording runs, while the Mac used one fifteen-recording session. Colocated cloud clients are not representative of residential users in those countries.
+
+Three fresh token-authenticated sessions using the PR adapter separately measured **78.9, 84.9 and 83.6 ms** commit-to-final, 151–359 ms for token issuance, and 211–274 ms to reach WebSocket readiness. The [live adapter receipt](integrations/orukeet/live-adapter-results.json) retains each run and its transcript hash. Start connection setup during capture and buffer initial samples. Very short recordings can still pay setup time.
+
+## Concurrent recording clients
+
+32 paced connections per region overlapped for a measured fleet peak of 96. Three runs completed 864 recordings with no failed utterances, transcript mismatches or capacity retries.
+
+| Region | Median | p95 |
+| ----------- | ------: | ------: |
+| Oregon | 34.7 ms | 89.9 ms |
+| Netherlands | 28.5 ms | 30.4 ms |
+| Singapore | 22.9 ms | 25.0 ms |
+
+The configured socket ceiling is not a demonstrated user count. These results establish 96 concurrent recording connections under this workload, not the maximum fleet capacity.
+
+## Saturated streaming throughput
+
+Audio was sent without capture pacing over 16 reused WebSockets per GPU. Rates count finals inside fixed 20-second measurement windows and report the median of three runs per region.
+
+| Region | Ten-second utterances per second | p95 final latency |
+| ----------- | -------------------------------: | ----------------: |
+| Oregon | 86.80 | 370.8 ms |
+| Netherlands | 91.15 | 544.0 ms |
+| Singapore | 90.45 | 511.3 ms |
+
+Including responses drained after the windows, these runs completed 16,237 utterances without a failed utterance or mismatch. They generated 10,888 expected capacity responses; clients honored backoff and retried commit without reupload. The longest final was about 2.58 seconds. These are saturation rates, not a low-latency operating target or user count. Summing the medians is not an independently measured fleet throughput.
+
+An earlier fixed-workload test used eight sockets and 100 utterances each, repeated three times per region. It measured 63.4/s in Oregon, 92.5/s in the Netherlands and 93.1/s in Singapore. Slower Cloudflare paths in Oregon left slow sockets draining after faster ones completed. Both methods are retained in the [benchmark receipt](integrations/orukeet/benchmark-results.json).
+
+Oregon inference stayed near 15 ms while Cloudflare Seattle connections had roughly 17–19 ms application-ping round trips and Portland connections had roughly 70–71 ms. The slower run is retained in the p95. Before/after routes were measured at different times and should not be interpreted as a causal speed comparison.
+
+## Reliability and coverage
+
+The native latency and load campaigns completed 24,361 matching finals without failed utterances. This count includes expected saturation backpressure and is separate from the following checks:
+
+- 189 live API/authentication checks passed, including TLS, missing/invalid auth, token expiry, cross-region single-use consumption and replay rejection.
+- 11 recording-boundary checks passed at 31, 61 and 600 seconds and above the limit. Above-limit audio was rejected with WebSocket close code 1009.
+- During a controlled European readiness drain, the first alternate new socket appeared at 17.3 seconds; three consecutive alternate sockets were confirmed by 25.3 seconds. An existing socket with half a recording buffered survived and completed correctly. All three backends recovered. A hardware failure can still interrupt an active socket.
+- The country proxy audit reached 18 countries with 20 verified route pairs and 80 matching transcripts. The initial Australian exit failed on both routes; three fresh exits passed. These timings include California → Decodo residential exit → API → return and are not native-country latency estimates.
+
+The fixture tests serving performance and transcript parity, not general recognition accuracy. Measurements do not establish a worldwide SLA or native hotkey-to-paste latency. Signed desktop acceptance and private account/usage integration are separate [rollout requirements](orukeet-streaming.md).
+
+## Reproduce the adapter latency check
+
+Use Node 24 and a mono 16 kHz PCM16 WAV file. Inject `ORUKEET_SERVICE_KEY` through your operator secret manager; never commit it. Run:
+
+```sh
+node scripts/benchmark-orukeet.cjs /absolute/path/to/audio.wav
+```
+
+The optional second argument is a local JSON file with a `text` field for exact transcript comparison. `SMOKE_RUNS` defaults to three and accepts one through ten. Output includes the fixture hash, region, setup time, inference/server/queue time, commit-to-final latency and a transcript hash; it excludes transcript text and credentials. This operator tool combines backend token issuance and desktop transport for testing. It does not substitute for testing the private customer login/allowance route.
diff --git a/docs/orukeet-streaming-language.md b/docs/orukeet-streaming-language.md
new file mode 100644
index 000000000..f00cdb770
--- /dev/null
+++ b/docs/orukeet-streaming-language.md
@@ -0,0 +1,33 @@
+# Orukeet streaming language metadata
+
+Orukeet's optional audio-language detector runs independently while audio is arriving. It emits advisory `language` events after the first three seconds of audio and updates the estimate after six seconds. A `final` message carries the latest completed estimate:
+
+```json
+{
+ "type": "final",
+ "text": "Example transcript.",
+ "language": "en",
+ "language_confidence": 0.99,
+ "language_audio_seconds": 6,
+ "language_source": "audio_lid",
+ "language_status": "detected"
+}
+```
+
+The same language fields appear on early messages with `type: "language"`. This is a separate audio classifier, not an output of the ASR decoder. The score is a model confidence score between zero and one, not a calibrated probability of correctness. An early guess can change.
+
+The gateway does not wait for language detection before returning a transcript. Recordings shorter than three seconds, silent audio, detector overload/failure, or a result that is not ready at commit can return `language: null`, `language_confidence: null`, and `language_status: "unknown"`. Older gateways may omit these fields. Unknown must not be interpreted as English or as proof that the language is supported. This detector is not a voice-activity or code-switching detector.
+
+The desktop adapter preserves the optional final metadata as `language`, `languageConfidence`, and `languageAudioSeconds` in `dictationRealtimeFinalize()`. The renderer can subscribe to `onDictationRealtimeLanguage(callback)`; like other preload subscriptions, it returns an unsubscribe function. Hints never trigger a transcript or paste. The final estimate is authoritative for that recording. Routing policy remains with the caller; receiving metadata does not itself switch providers.
+
+Orukeet supports these 25 language codes:
+
+`bg cs da de el en es et fi fr hr hu it lt lv mt nl pl pt ro ru sk sl sv uk`
+
+Keep the original recording until routing is settled. Prefer the six-second estimate for automatic fallback, and apply a confidence threshold. Do not route from an early low-confidence guess. An explicit user language outside the supported set can use the existing provider directly.
+
+## Short-window evaluation
+
+On 330 human-read FLEURS clips across 33 languages (all 25 supported languages and eight unsupported languages), exact language accuracy was 172/330 (52.1%) at two seconds and 256/330 (77.6%) at three seconds. Among the 315 clips containing a full six seconds, it was 293/315 (93.0%). These are classifier results on read speech, not ASR word accuracy or production calibration.
+
+At a score threshold of 0.90, the two-second estimate caught 28/80 unsupported-language clips and incorrectly flagged 6/250 supported-language clips. At six seconds those counts were 69/75 and 1/240. The deployed first/update windows therefore remain three and six seconds. A two-second guess is too unreliable to recommend for automatic provider routing. Clips without a sufficiently confident result should retain the user's configured provider or language policy.
diff --git a/docs/orukeet-streaming.md b/docs/orukeet-streaming.md
new file mode 100644
index 000000000..d38a3b248
--- /dev/null
+++ b/docs/orukeet-streaming.md
@@ -0,0 +1,40 @@
+# Orukeet cloud dictation
+
+Orukeet uploads audio during recording and returns one final transcript on release. The desktop uses the existing cloud login, dictation controls, fallback recording, cleanup and paste pipeline. There are no interim words or new settings to configure for managed users.
+
+## Enable the managed route
+
+The desktop supports this server-controlled `/api/stt-config` response for dictation:
+
+```json
+{
+ "dictation": { "mode": "streaming" },
+ "streamingProvider": "orukeet"
+}
+```
+
+Keep the flag off until the private Cloud backend implements `POST /api/stt/orukeet/session`. That backend is maintained separately from this desktop repository. Before issuing a session, it must apply the existing account authentication, workspace policy, entitlement, allowance, rate and concurrency checks. Return the existing structured error format for denials; the desktop preserves auth refresh, policy and upgrade metadata.
+
+The backend-only [issue-session.cjs](integrations/orukeet/issue-session.cjs) calls the deployed token service and validates its response. Inject `ORUKEET_SERVICE_KEY` from the backend secret manager and return `await issueSession({ serviceKey, accountId: authenticatedUser.id })` with `Cache-Control: no-store`. Use the same opaque account ID across devices, derived from verified authentication, never a desktop-supplied ID. IDs must contain 8–128 letters, digits, underscores or hyphens; do not use an email address. The helper is outside the packaged Electron file allowlist. No service credential belongs in the app, renderer, repository, logs or response. No unauthenticated route is included here.
+
+The response contains `baseUrl`, `websocketUrl`, `clientToken`, `protocol`, `expiresIn`, `singleUse`, and `model`. The main process validates all fields, pins the destination to `https://orukeet.gizmovoice.ai`, and connects using `orukeet.pcm.v1` and `auth.<clientToken>` WebSocket subprotocols. A renderer-selected URL cannot redirect managed credentials. Token issuance and connection are bound to the current account; cancellation or credential changes cannot reopen a stale session.
+
+**Usage enforcement:** current GPU tokens are single-use connection credentials with a 60-second connection expiry, not per-user billing grants. An established socket can last longer. Token issuance checks alone do not enforce paid audio duration. Before a paid rollout, the private backend and gateway must provide trusted user/session metering or proxy sessions through an authenticated metered backend. Client duration telemetry is not a trusted billing receipt. Rebenchmark if a proxy hop is introduced.
+
+**Account concurrency:** account-bound sessions share one active recording and one idle/warm socket across the three regions. The default role is `warm`; receiving audio promotes it to `active`. A second concurrent recording is rejected before transcription, and the desktop retains its audio for the existing authorized fallback. Finishing or clearing returns the connection to `warm`; if another warm socket already exists, the completed connection closes after delivering its final result. A coordinator outage rejects new sessions and closes existing sessions after their lease expires. This bounds concurrency, not billable usage. Calls without `accountId` remain legacy-compatible and do not enforce a per-account cap. The private backend must supply the ID to enable this protection; the desktop PR alone cannot do that.
+
+## Recording lifecycle
+
+The main process creates the adapter before requesting the session so initial PCM is buffered. The existing AudioWorklet emits mono PCM16 at 16 kHz. On release it sends its final PCM and a flush acknowledgement; only then does the desktop commit. Final acknowledgement replaces fixed settling delays. Successful silence is accepted without a second transcription. A flush failure closes the incomplete stream and preserves the existing recording fallback.
+
+Successful recordings can reuse the established Orukeet socket. Each final resets audio and language state. An unused Orukeet connection closes after 60 seconds; recording startup cancels that timer. Cancellation closes without commit. Pending audio is bounded to 2 MiB; setup and final waits are bounded. Application heartbeats run every 15 seconds. The server allows at most 600 seconds of audio and uses overlapped windows above 60 seconds; an individual socket has a 20-minute lifetime.
+
+A `capacity` response means the server retained the audio: retry only the commit after `retry_after_ms`, within the original final deadline. Connection loss closes the adapter and uses the existing retained-audio fallback. Duplicate final responses are ignored. The fallback remains the existing authorized OpenWhispr Cloud path; this PR does not replace its model configuration.
+
+The rollout applies to dictation. Local Orukeet, meetings and existing BYOK providers retain their behavior. For an operator's custom endpoint, selecting `orukeet-v0.1.0` with a custom URL and key opts into the same PCM transport; other custom models retain their existing route.
+
+## Validation and rollout
+
+Automated tests cover real WebSocket transport, the registered Electron IPC handlers, startup buffering, token authentication, endpoint pinning, allowance and policy denials, account changes, cancellation, duplicate finals, silence, capture flush ordering, retry and timeout. [Streaming benchmark results](orukeet-benchmarks.md) report the deployed infrastructure measurements separately from desktop tests.
+
+Before enabling the flag, accept the private backend route and metering, then verify microphone, hotkey, cleanup and single-paste behavior on signed macOS, Windows and Linux release builds. Automated Electron-boundary tests do not claim native OS acceptance. Roll back by restoring the previous `streamingProvider`; let active recordings finish. Track setup, stop-to-final, release-to-paste, queue time and fallback rate separately.
diff --git a/preload.js b/preload.js
index 1a36bc1bc..79d43900e 100644
--- a/preload.js
+++ b/preload.js
@@ -954,6 +954,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
dictationRealtimeWarmup: (options) => ipcRenderer.invoke("dictation-realtime-warmup", options),
dictationRealtimeStart: (options) => ipcRenderer.invoke("dictation-realtime-start", options),
dictationRealtimeSend: (buffer) => ipcRenderer.send("dictation-realtime-send", buffer),
+ dictationRealtimeFinalize: () => ipcRenderer.invoke("dictation-realtime-finalize"),
dictationRealtimeStop: () => ipcRenderer.invoke("dictation-realtime-stop"),
onDictationRealtimePartial: registerListener(
"dictation-realtime-partial",
@@ -963,6 +964,10 @@ contextBridge.exposeInMainWorld("electronAPI", {
"dictation-realtime-final",
(callback) => (_event, data) => callback(data)
),
+ onDictationRealtimeLanguage: registerListener(
+ "dictation-realtime-language",
+ (callback) => (_event, data) => callback(data)
+ ),
onDictationRealtimeError: registerListener(
"dictation-realtime-error",
(callback) => (_event, data) => callback(data)
diff --git a/scripts/benchmark-orukeet.cjs b/scripts/benchmark-orukeet.cjs
new file mode 100644
index 000000000..52252c24f
--- /dev/null
+++ b/scripts/benchmark-orukeet.cjs
@@ -0,0 +1,118 @@
+"use strict";
+
+// Operator-only: this combines backend token issuance and desktop streaming.
+// The shipped desktop receives a session from OpenWhispr's authenticated backend.
+const fs = require("node:fs");
+const { createHash } = require("node:crypto");
+const { performance } = require("node:perf_hooks");
+const { setTimeout: sleep } = require("node:timers/promises");
+const { issueSession } = require("../docs/integrations/orukeet/issue-session.cjs");
+const { OrukeetStreaming } = require("../src/helpers/orukeetStreaming.js");
+
+function readPcmWav(file) {
+ const data = fs.readFileSync(file);
+ if (
+ data.length < 12 ||
+ data.toString("ascii", 0, 4) !== "RIFF" ||
+ data.toString("ascii", 8, 12) !== "WAVE"
+ )
+ throw new Error("Expected a WAV file");
+ let format, pcm;
+ for (let at = 12; at + 8 <= data.length;) {
+ const id = data.toString("ascii", at, at + 4);
+ const length = data.readUInt32LE(at + 4);
+ const start = at + 8;
+ if (start + length > data.length) throw new Error("Truncated WAV chunk");
+ if (id === "fmt " && length >= 16) {
+ format = [
+ data.readUInt16LE(start),
+ data.readUInt16LE(start + 2),
+ data.readUInt32LE(start + 4),
+ data.readUInt16LE(start + 14),
+ ];
+ }
+ if (id === "data") pcm = data.subarray(start, start + length);
+ at = start + length + (length % 2);
+ }
+ if (JSON.stringify(format) !== "[1,1,16000,16]" || !pcm?.length || pcm.length % 2) {
+ throw new Error("Expected nonempty mono 16 kHz signed PCM16 WAV");
+ }
+ return pcm;
+}
+
+async function main() {
+ if (!process.argv[2])
+ throw new Error("Usage: node scripts/benchmark-orukeet.cjs audio.wav [expected.json]");
+ const pcm = readPcmWav(process.argv[2]);
+ const expected = process.argv[3] ? JSON.parse(fs.readFileSync(process.argv[3])).text : null;
+ const runs = Number(process.env.SMOKE_RUNS || 3);
+ if (!Number.isInteger(runs) || runs < 1 || runs > 10) throw new Error("SMOKE_RUNS must be 1-10");
+ const results = [];
+ for (let run = 0; run < runs; run++) {
+ const client = new OrukeetStreaming();
+ const sessionStart = performance.now();
+ const session = await issueSession({ serviceKey: process.env.ORUKEET_SERVICE_KEY });
+ const tokenIssueMs = performance.now() - sessionStart;
+ let region;
+ try {
+ const connectStart = performance.now();
+ const connected = client.connect({
+ baseUrl: session.baseUrl,
+ clientToken: session.clientToken,
+ });
+ client.ws.on("upgrade", (response) => {
+ region = response.headers["x-orukeet-region"];
+ });
+ await connected;
+ const connectionReadyMs = performance.now() - connectStart;
+ const recordingStart = performance.now();
+ for (let at = 0; at < pcm.length; at += 3200) {
+ // Send each frame only when capture would have produced its last sample.
+ // The final PCM frame is therefore queued immediately before commit.
+ const target = recordingStart + Math.min(at + 3200, pcm.length) / 32;
+ await sleep(Math.max(0, target - performance.now()));
+ client.sendAudio(pcm.subarray(at, at + 3200));
+ }
+ const stop = performance.now();
+ const final = await client.finalize();
+ const commitToFinalMs = performance.now() - stop;
+ if (expected !== null && final.text !== expected)
+ throw new Error("Fixture transcript mismatch");
+ results.push({
+ run: run + 1,
+ region,
+ tokenIssueMs,
+ connectionReadyMs,
+ audioSeconds: pcm.length / 32000,
+ commitToFinalMs,
+ inferenceMs: final.inferenceMs,
+ serverMs: final.serverMs,
+ queueMs: final.queueMs,
+ transcriptMatches: expected === null ? null : true,
+ transcriptSha256: createHash("sha256").update(final.text).digest("hex"),
+ });
+ } finally {
+ await client.disconnect();
+ }
+ }
+ console.log(
+ JSON.stringify(
+ {
+ measuredAt: new Date().toISOString(),
+ method:
+ "Paced PCM16 using the PR adapter; commit-to-final excludes token/connection setup and recording",
+ fixtureSha256: createHash("sha256").update(fs.readFileSync(process.argv[2])).digest("hex"),
+ results,
+ },
+ null,
+ 2
+ )
+ );
+}
+
+if (require.main === module)
+ main().catch((error) => {
+ console.error(error.message);
+ process.exitCode = 1;
+ });
+module.exports = { readPcmWav };
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index a62ee7577..f5a81072c 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -77,10 +77,14 @@ import {
import { getTranscriptionApiKey } from "../services/fileTranscription";
import { shouldSkipTranscriptionApiKey } from "./transcriptionAuth";
import {
+ isOrukeetStreaming,
isSelfHostedTranscription,
resolveSelfHostedTranscriptionModel,
} from "./selfHostedTranscription";
-import { resolveStreamingFallbackTarget } from "./transcriptionFallback";
+import {
+ resolveStreamingFallbackTarget,
+ resolveStreamingStartFallback,
+} from "./transcriptionFallback";
import {
executeTranslationChain,
hasTextContent,
@@ -125,11 +129,15 @@ import {
import {
REALTIME_MODELS,
defaultStreamingProviderName,
+ resolveManagedOrukeetRoute,
resolveStreamingProviderName,
buildStreamingSessionOptions,
} from "./dictationStreamingRouting";
const REASONING_CACHE_TTL = 30000; // 30 seconds
+// A server-side rollout change (a provider switched on or rolled back) must
+// reach a long-running app without a restart.
+const STT_CONFIG_TTL_MS = 15 * 60 * 1000;
const RECORDING_TIMESLICE_MS = 250; // flush chunks periodically so short recordings still carry audio frames. See #871.
// Failure detector only: fires when the worklet or audio graph is dead and never flushes.
const PREVIEW_FLUSH_WATCHDOG_MS = 1000;
@@ -392,6 +400,11 @@ const STREAMING_PROVIDERS = {
onSessionEnd: (cb) => window.electronAPI.onAssemblyAiSessionEnd(cb),
},
"openai-realtime": makeDictationRealtimeProvider("openai-realtime"),
+ orukeet: {
+ ...makeDictationRealtimeProvider("orukeet"),
+ finalizeAcknowledged: true,
+ finalize: () => window.electronAPI.dictationRealtimeFinalize(),
+ },
gemini: {
// The final transcript lands ~500ms after audioStreamEnd (which finalize
// sends), ~2s at the p95 tail, so the stop sequence waits for it under a
@@ -619,6 +632,8 @@ class AudioManager {
this.screenContextPromise = null;
this.selectionCapturePromise = null;
this.sttConfig = null;
+ this.sttConfigFetchedAt = null;
+ this.streamingFallbackReason = null;
this.warmupFailureStreak = 0;
this.lastAudioBlob = null;
this.lastAudioMetadata = null;
@@ -968,6 +983,20 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
setSttConfig(config) {
this.sttConfig = config;
+ this.sttConfigFetchedAt = Date.now();
+ }
+
+ isSttConfigStale(now = Date.now()) {
+ return (
+ !this.sttConfig ||
+ !this.sttConfigFetchedAt ||
+ now - this.sttConfigFetchedAt > STT_CONFIG_TTL_MS
+ );
+ }
+
+ invalidateSttConfig() {
+ this.sttConfig = null;
+ this.sttConfigFetchedAt = null;
}
getStreamingProvider() {
@@ -977,10 +1006,12 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
getStreamingProviderName() {
// Every AudioManager instance records dictation; notes and meetings have
// their own routing, so the context is a literal here.
+ const settings = getSettings();
const name = resolveStreamingProviderName({
- settings: getSettings(),
+ settings,
context: "dictation",
sttConfig: this.sttConfig,
+ language: this.getEffectiveSttLanguage(settings),
});
// A server-driven sttConfig.streamingProvider we don't recognize must fall
// back to a provider we can run — and the reported name must match the
@@ -3328,15 +3359,16 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
const opts = {};
const analyticsOccurredAt = new Date(metadata.analyticsOccurredAt || Date.now());
if (language) opts.language = language;
+ const streamingFallbackReason =
+ metadata.streamingFallbackReason ?? this.consumeStreamingFallbackReason(settings);
+ if (streamingFallbackReason) opts.streamingFallbackReason = streamingFallbackReason;
if (analyticsSyncEnabled(settings)) {
opts.analyticsOccurredAt = analyticsOccurredAt.toISOString();
opts.localDate = localDateKey(analyticsOccurredAt);
}
const cleanupCloudMode = settings.cleanupCloudMode || "openwhispr";
- if (
- (settings.useCleanupModel && cleanupCloudMode === "openwhispr") ||
- (this.translationRequested && translationChainReachable(settings) && isCloudTranslationMode())
- ) {
+ // Only cloud cleanup writes a combined STT log; translation alone does not.
+ if (settings.useCleanupModel && cleanupCloudMode === "openwhispr") {
opts.sendLogs = "false";
}
@@ -3407,6 +3439,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
customPrompt: this.getCustomPrompt(),
language: this.getCleanupLanguage(settings),
locale: settings.uiLanguage || "en",
+ streamingFallbackReason,
sttProvider: result.sttProvider,
sttModel: result.sttModel,
sttProcessingMs: result.sttProcessingMs,
@@ -3450,6 +3483,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
? {
mode: "cloudReason",
meta: {
+ streamingFallbackReason,
sttProvider: result.sttProvider,
sttModel: result.sttModel,
sttProcessingMs: result.sttProcessingMs,
@@ -3660,7 +3694,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
formData.append("file", uploadAudio, `audio.${extension}`);
formData.append("model", model);
- if (language) {
+ if (language && model !== "orukeet-v0.1.0") {
formData.append("language", language);
}
@@ -3682,7 +3716,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
MAX_PROMPT_CHARS
);
const dictionaryPrompt = trimmedPrompt.prompt;
- if (dictionaryPrompt) {
+ if (dictionaryPrompt && model !== "orukeet-v0.1.0") {
if (trimmedPrompt.truncated) {
logger.debug(
"Custom dictionary prompt truncated",
@@ -4223,9 +4257,25 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
// setups; an error resolution must fail closed on the batch path too.
if (getManagedTranscriptionResolution()) return false;
+ if (isOrukeetStreaming(s)) return Boolean(s.customTranscriptionApiKey);
+
// Self-hosted transcription is batch HTTP to the user's server, never cloud realtime WS.
if (isSelfHostedTranscription(s)) return false;
+ if (
+ s.cloudTranscriptionMode === "openwhispr" &&
+ this.sttConfig?.streamingProvider === "orukeet"
+ ) {
+ // A language the model does not cover takes the batch path, which
+ // carries the language, instead of a socket that would ignore it.
+ const route = resolveManagedOrukeetRoute({
+ settings: s,
+ sttConfig: this.sttConfig,
+ language: this.getEffectiveSttLanguage(s),
+ });
+ return route === "orukeet" && Boolean(isSignedInOverride ?? s.isSignedIn);
+ }
+
// Corti (BYOK) streams over its own WSS — independent of OpenWhispr Cloud.
if (s.cloudTranscriptionProvider === "corti" && s.cloudTranscriptionMode === "byok") {
return !!(s.cortiClientId && s.cortiClientSecret);
@@ -4463,6 +4513,65 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
for (const resolve of this._streamingStartSettlementWaiters.splice(0)) resolve();
}
+ // Turns a failed dictation-realtime-start result into a batch fallback or
+ // the error the user must see.
+ classifyStreamingStartResult(res, { useLocalWhisper }) {
+ if (res.success) return res;
+ if (res.code === "NO_API") return { needsFallback: true };
+ if (res.code === "NETWORK_ERROR" && useLocalWhisper) {
+ this.onError?.({
+ code: "NETWORK_ERROR",
+ title: "streaming.errors.cloudUnreachable.title",
+ description: "Cloud unreachable — using local engine for this recording.",
+ messageKey: "streaming.errors.cloudUnreachable.fallback",
+ });
+ return { needsFallback: true };
+ }
+ const fallbackReason = resolveStreamingStartFallback({
+ providerName: this.getStreamingProviderName(),
+ cloudTranscriptionMode: getSettings().cloudTranscriptionMode,
+ result: res,
+ });
+ if (fallbackReason) {
+ // The cached config advertised a route the server no longer grants: drop
+ // it so the next recording refetches instead of retrying a denied route.
+ if (res.code === "FEATURE_NOT_ENABLED") this.invalidateSttConfig();
+ this.streamingFallbackReason = fallbackReason;
+ logger.warn(
+ "Managed Orukeet session unavailable, falling back to batch recording",
+ { code: res.code, status: res.status, reason: fallbackReason, error: res.error },
+ "streaming"
+ );
+ return { needsFallback: true };
+ }
+ if (res.code === "LIMIT_REACHED" && Number.isFinite(res.details?.wordsUsed)) {
+ // Same upgrade prompt a batch upload opens when it crosses the quota.
+ window.electronAPI?.notifyLimitReached?.({
+ wordsUsed: res.details.wordsUsed,
+ limit: Number.isFinite(res.details.limit) ? res.details.limit : 2000,
+ });
+ }
+ const err = new Error(res.error || "Failed to start streaming session");
+ err.code = res.code;
+ err.messageKey = res.messageKey;
+ err.networkCode = res.networkCode;
+ throw err;
+ }
+
+ // Why this cloud upload is batch instead of the managed Orukeet stream, for
+ // the rollout's fallback-rate metric. Cleared on read: it describes one recording.
+ consumeStreamingFallbackReason(settings) {
+ const reason = this.streamingFallbackReason;
+ this.streamingFallbackReason = null;
+ if (reason) return reason;
+ const route = resolveManagedOrukeetRoute({
+ settings,
+ sttConfig: this.sttConfig,
+ language: this.getEffectiveSttLanguage(settings),
+ });
+ return route === "language_unsupported" ? route : undefined;
+ }
+
async startStreamingRecording(forceDefaultMic = false) {
let acquiredStream = null;
let usedPreparedCapture = false;
@@ -4487,6 +4596,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
this.stopRequestedDuringStreamingStart = false;
sessionId = (this._streamingSessionGeneration || 0) + 1;
this._streamingSessionGeneration = sessionId;
+ this.streamingFallbackReason = null;
this._activeStreamingSessionId = sessionId;
const ownsSession = () => this._activeStreamingSessionId === sessionId;
const cancellationGeneration = this._streamingCancellationGeneration;
@@ -4556,7 +4666,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
// The worklet posts its remaining PCM followed by a "flushed" sentinel
// on stop; the sentinel must not be sent as audio (realtime backends
// reject the odd-length non-PCM bytes with "Invalid audio data").
- if (!ownsSession() || !this.isStreaming || event.data === "flushed") return;
+ if (!ownsSession() || !this.isStreaming) return;
+ if (event.data === "flushed") {
+ this._streamingFlushResolve?.();
+ return;
+ }
provider.send(event.data);
};
@@ -4651,26 +4765,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
})
);
- if (!res.success) {
- if (res.code === "NO_API") {
- return { needsFallback: true };
- }
- if (res.code === "NETWORK_ERROR" && useLocalWhisper) {
- this.onError?.({
- code: "NETWORK_ERROR",
- title: "streaming.errors.cloudUnreachable.title",
- description: "Cloud unreachable — using local engine for this recording.",
- messageKey: "streaming.errors.cloudUnreachable.fallback",
- });
- return { needsFallback: true };
- }
- const err = new Error(res.error || "Failed to start streaming session");
- err.code = res.code;
- err.messageKey = res.messageKey;
- err.networkCode = res.networkCode;
- throw err;
- }
- return res;
+ return this.classifyStreamingStartResult(res, { useLocalWhisper });
});
const tWs = performance.now();
this._settleStreamingStart();
@@ -4683,11 +4778,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
await this.cleanupStreaming();
if (ownsSession()) this._activeStreamingSessionId = null;
this.onStateChange?.({ isRecording: false, isProcessing: false, isStreaming: false });
- logger.debug(
- "Streaming API not configured, falling back to regular recording",
- {},
- "streaming"
- );
+ logger.debug("Streaming unavailable, falling back to regular recording", {}, "streaming");
return this.startRecording();
}
@@ -4764,6 +4855,9 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
} else if (error.code === "NETWORK_ERROR") {
errorTitle = "streaming.errors.cloudUnreachable.title";
errorDescription = error.messageKey || "streaming.errors.cloudUnreachable.generic";
+ } else if (error.code === "LIMIT_REACHED") {
+ // Titled by getRecordingErrorTitle, like the batch upload's limit error.
+ errorDescription = error.message;
} else if (error.name === "MicUnusableError") {
errorTitle = "Microphone Muted";
errorDescription =
@@ -4982,14 +5076,45 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
const t0 = performance.now();
let finalText = this.streamingFinalText || "";
- // 1. Stop the processor — it flushes its remaining buffer on "stop".
- // Keep isStreaming TRUE so the port.onmessage handler forwards the flush to WebSocket.
- if (this.streamingProcessor) {
+ const provider = this.getStreamingProvider();
+ let acknowledgedFinal = null;
+ let finalAcknowledged = false;
+ // The worklet emits PCM followed by "flushed" on the same message port.
+ // IPC sends and the finalize invoke preserve that order in the main process.
+ if (this.streamingProcessor && provider.finalizeAcknowledged) {
+ const processor = this.streamingProcessor;
+ let watchdog;
+ const flushed = new Promise((resolve, reject) => {
+ this._streamingFlushResolve = resolve;
+ watchdog = setTimeout(
+ () => reject(new Error("Audio worklet did not flush")),
+ PREVIEW_FLUSH_WATCHDOG_MS
+ );
+ });
+ processor.port.postMessage("stop");
+ try {
+ await flushed;
+ } catch (error) {
+ // Incomplete capture must use the retained recording, never commit a
+ // truncated stream. Keep cleanup running so the microphone is released.
+ acknowledgedFinal = Promise.resolve({ success: false, error: error.message });
+ } finally {
+ clearTimeout(watchdog);
+ this._streamingFlushResolve = null;
+ processor.disconnect();
+ this.streamingProcessor = null;
+ }
+ if (wasCancelled()) return abandonFinalization();
+ acknowledgedFinal ||= provider.finalize().catch((error) => ({
+ success: false,
+ error: error.message,
+ }));
+ } else if (this.streamingProcessor) {
try {
this.streamingProcessor.port.postMessage("stop");
this.streamingProcessor.disconnect();
- } catch (e) {
- // Ignore
+ } catch {
+ /* Capture is already stopped. */
}
this.streamingProcessor = null;
}
@@ -5035,18 +5160,27 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
// 2. Wait for flushed buffer to travel: port -> main thread -> IPC -> WebSocket -> server.
// Then mark streaming done so no further audio is forwarded.
- await new Promise((resolve) => setTimeout(resolve, 120));
+ if (!provider.finalizeAcknowledged) await new Promise((resolve) => setTimeout(resolve, 120));
if (wasCancelled()) return abandonFinalization();
this.isStreaming = false;
const tFlush = performance.now();
// 3. Finalize tells the provider to process any buffered audio and send final results.
// Wait for the transcript to settle before disconnecting.
- const provider = this.getStreamingProvider();
- provider.finalize?.();
- if (provider.awaitsFinalTranscript) {
+ if (provider.finalizeAcknowledged) {
+ const result = await (acknowledgedFinal || provider.finalize());
+ finalAcknowledged = result?.success === true;
+ if (finalAcknowledged && typeof result.text === "string") {
+ this.streamingFinalText = result.text;
+ }
+ if (!result?.success) {
+ logger.warn("Streaming finalization failed", { error: result?.error }, "streaming");
+ }
+ } else if (provider.awaitsFinalTranscript) {
+ provider.finalize?.();
await this.awaitStreamingTextSettled(provider.finalCeilingMs);
} else {
+ provider.finalize?.();
await new Promise((resolve) => setTimeout(resolve, 300));
}
if (wasCancelled()) return abandonFinalization();
@@ -5262,7 +5396,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
let usedBatchFallback = false;
let batchWarning = null;
let batchFallbackResult = null;
- if (!finalText && durationSeconds > 2 && fallbackBlob?.size > 0) {
+ if (!finalText && !finalAcknowledged && durationSeconds > 2 && fallbackBlob?.size > 0) {
const target = resolveStreamingFallbackTarget(getSettings());
if (target === "skip") {
logger.warn(
@@ -5285,6 +5419,11 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
{
durationSeconds,
analyticsOccurredAt: analyticsOccurredAt.toISOString(),
+ // The tag feeds the Orukeet rollout's fallback rate; other
+ // providers still fall back, just untagged.
+ ...(this.getStreamingProviderName() === "orukeet"
+ ? { streamingFallbackReason: "stream_no_final" }
+ : {}),
},
wasCancelled
)
@@ -5469,6 +5608,8 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);
}
cleanupStreamingAudio() {
+ this._streamingFlushResolve?.();
+ this._streamingFlushResolve = null;
if (this.streamingFallbackRecorder?.state === "recording") {
try {
this.streamingFallbackRecorder.stop();
diff --git a/src/helpers/cloudConfigRequest.js b/src/helpers/cloudConfigRequest.js
index 104a421a0..1b9e48f43 100644
--- a/src/helpers/cloudConfigRequest.js
+++ b/src/helpers/cloudConfigRequest.js
@@ -16,8 +16,12 @@ function createCloudConfigRequestHandler({
const authHeader = await getAuthHeader(event);
if (!Object.keys(authHeader).length) throw new Error("Not authenticated");
+ // The caller keeps its own freshness window; a Chromium-cached copy would
+ // re-serve a route the server already withdrew (e.g. after a refused
+ // Orukeet session invalidates the in-memory config).
const response = await proxyFetch(`${apiUrl}/api/${configPath}`, {
headers: withPolicyHeaders(authHeader),
+ cache: "no-store",
});
if (!response.ok) {
if (response.status === 401) {
diff --git a/src/helpers/dictationStreamingRouting.js b/src/helpers/dictationStreamingRouting.js
index 663075377..ee3216102 100644
--- a/src/helpers/dictationStreamingRouting.js
+++ b/src/helpers/dictationStreamingRouting.js
@@ -4,7 +4,14 @@
// call sites is what broke default dictation in 1.8.2 (#1624: the
// openai-realtime entry never sent `provider`, and the hardened main-process
// allowlist rejected undefined). Pure module, mirrors meetingTranscriptionRouting.
+import { isOrukeetStreaming } from "./selfHostedTranscription.js";
import { STREAMING_ONLY_PROVIDERS } from "./transcriptionRoute.ts";
+import modelRegistryData from "../models/modelRegistryData.json" with { type: "json" };
+
+export const ORUKEET_MODEL = "orukeet-v0.1.0";
+const ORUKEET_LANGUAGES = new Set(
+ modelRegistryData.parakeetModels[ORUKEET_MODEL].supportedLanguages
+);
export const REALTIME_MODELS = new Set(["gpt-4o-mini-transcribe", "gpt-4o-transcribe"]);
@@ -17,7 +24,33 @@ export function defaultStreamingProviderName(context) {
return context === "notes" ? "deepgram" : "openai-realtime";
}
-export function resolveStreamingProviderName({ settings, context, sttConfig }) {
+// The managed Orukeet route carries no language on the wire and the model
+// covers a fixed list, so an explicitly selected language outside it stays on
+// the batch path, the one route that honors the user's language end to end.
+// "auto" (the default) uses the model's own detection, as every other
+// streaming provider does.
+export function resolveManagedOrukeetRoute({ settings, sttConfig, language }) {
+ if (
+ settings.cloudTranscriptionMode !== "openwhispr" ||
+ sttConfig?.dictation?.mode !== "streaming" ||
+ sttConfig?.streamingProvider !== "orukeet"
+ ) {
+ return null;
+ }
+ if (!language || language === "auto") return "orukeet";
+ const base = language.split("-")[0].toLowerCase();
+ return ORUKEET_LANGUAGES.has(base) ? "orukeet" : "language_unsupported";
+}
+
+export function resolveStreamingProviderName({ settings, context, sttConfig, language }) {
+ // The managed rollout must outrank a stale personal model selection. Notes
+ // keep their separate provider contract; this endpoint is for dictation.
+ if (context === "dictation") {
+ const managedOrukeet = resolveManagedOrukeetRoute({ settings, sttConfig, language });
+ if (managedOrukeet === "orukeet") return "orukeet";
+ if (managedOrukeet === "language_unsupported") return defaultStreamingProviderName(context);
+ }
+ if (isOrukeetStreaming(settings)) return "orukeet";
if (settings.cloudTranscriptionProvider === "tinfoil") {
return "tinfoil-realtime";
}
@@ -71,5 +104,11 @@ export function buildStreamingSessionOptions({
if (providerName === "tinfoil-realtime" && !voiceAgentRequested) {
options.preview = true;
}
+ if (providerName === "orukeet") {
+ options.model = ORUKEET_MODEL;
+ if (options.mode === "byok") {
+ options.baseUrl = settings.remoteTranscriptionUrl || settings.cloudTranscriptionBaseUrl;
+ }
+ }
return options;
}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index ee5642050..6514afba0 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -1,3 +1,5 @@
+const { OrukeetStreaming } = require("./orukeetStreaming");
+const { connectManagedOrukeet } = require("./orukeetCloudSession");
const { ipcMain, app, shell, BrowserWindow, systemPreferences, net, session } = require("electron");
const path = require("path");
const fs = require("fs");
@@ -6241,6 +6243,7 @@ class IPCHandlers {
clientTranscriptionId,
localDate: opts.localDate,
analyticsOccurredAt: opts.analyticsOccurredAt,
+ streamingFallbackReason: opts.streamingFallbackReason,
};
debugLogger.debug("Cloud transcribe request", { audioSize: audioData.length }, "cloud-api");
@@ -8351,14 +8354,31 @@ class IPCHandlers {
};
const setupDictationCallbacks = (streaming, event) => {
+ const isOrukeet = streaming instanceof OrukeetStreaming;
+ const canNotify = () =>
+ !isOrukeet || (this._dictationStreaming === streaming && !event.sender.isDestroyed?.());
+ if (isOrukeet) {
+ const ownerGone = () => {
+ streaming.disconnect().catch(() => {});
+ if (this._dictationStreaming === streaming) this._dictationStreaming = null;
+ };
+ event.sender.once?.("destroyed", ownerGone);
+ streaming.onClose = () => event.sender.removeListener?.("destroyed", ownerGone);
+ }
streaming.onPartialTranscript = (text) => {
event.sender.send("dictation-realtime-partial", text);
if (this._dictationPreviewEnabled && text) {
this.windowManager.showTranscriptionPreview(text);
}
};
- streaming.onFinalTranscript = (text) => event.sender.send("dictation-realtime-final", text);
+ streaming.onFinalTranscript = (text) => {
+ if (canNotify()) event.sender.send("dictation-realtime-final", text);
+ };
+ streaming.onLanguage = (metadata) => {
+ if (canNotify()) event.sender.send("dictation-realtime-language", metadata);
+ };
streaming.onError = (err) => {
+ if (!canNotify()) return;
event.sender.send("dictation-realtime-error", err.message);
if (this._dictationPreviewEnabled) this.windowManager.hideTranscriptionPreview();
};
@@ -8369,6 +8389,7 @@ class IPCHandlers {
};
const DICTATION_IDLE_TIMEOUT_MS = 5 * 60 * 1000;
+ const ORUKEET_IDLE_TIMEOUT_MS = 60 * 1000;
const clearDictationIdleTimer = () => {
if (this._dictationIdleTimer) {
@@ -8379,15 +8400,29 @@ class IPCHandlers {
const startDictationIdleTimer = () => {
clearDictationIdleTimer();
+ const idleTimeoutMs =
+ this._dictationStreaming instanceof OrukeetStreaming
+ ? ORUKEET_IDLE_TIMEOUT_MS
+ : DICTATION_IDLE_TIMEOUT_MS;
this._dictationIdleTimer = setTimeout(() => {
if (this._dictationStreaming) {
debugLogger.debug("Closing idle dictation warmup connection");
this._dictationStreaming.disconnect().catch(() => {});
this._dictationStreaming = null;
}
- }, DICTATION_IDLE_TIMEOUT_MS);
+ }, idleTimeoutMs);
};
+ // What a dictation connection was opened for; a start or warmup reuses one
+ // only when nothing about the route changed.
+ const dictationConnectionKey = (options) =>
+ JSON.stringify([
+ options.provider || "openai-realtime",
+ options.mode,
+ options.model,
+ options.baseUrl,
+ ]);
+
const connectDictationStreaming = async (event, options) => {
// Older renderers did not label the OpenAI dictation adapter. Dictation
// realtime was OpenAI-only before Tinfoil support, so preserve that
@@ -8415,14 +8450,33 @@ class IPCHandlers {
// default lives here, at the boundary, so the token allowlist stays
// fail-closed for genuinely unknown providers (#1624).
const provider = options.provider ?? "openai-realtime";
- const streaming = new OpenAIRealtimeStreaming();
+ const streaming =
+ provider === "orukeet" ? new OrukeetStreaming() : new OpenAIRealtimeStreaming();
setupDictationCallbacks(streaming, event);
// Assign before the token fetch (a real network round trip) so
// dictation-realtime-send has a live instance to buffer into instead
// of silently dropping the start of the recording.
streaming.beginConnecting();
+ streaming.connectionKey = dictationConnectionKey(options);
this._dictationStreaming = streaming;
try {
+ if (provider === "orukeet") {
+ if (isCloud) {
+ await connectManagedOrukeet({
+ streaming,
+ getApiUrl,
+ proxyFetch,
+ tokenStore,
+ withPolicyHeaders,
+ });
+ } else {
+ await streaming.connect({
+ apiKey: this.environmentManager.getCustomTranscriptionKey(),
+ baseUrl: options.baseUrl,
+ });
+ }
+ return;
+ }
const apiKey = await fetchRealtimeToken(event, {
mode: options.mode,
provider,
@@ -8446,6 +8500,7 @@ class IPCHandlers {
});
}
} catch (err) {
+ if (provider === "orukeet") await streaming.disconnect().catch(() => {});
if (this._dictationStreaming === streaming) this._dictationStreaming = null;
throw err;
}
@@ -9087,21 +9142,48 @@ class IPCHandlers {
return result;
};
- ipcMain.handle("dictation-realtime-warmup", async (event, options = {}) => {
- try {
+ // Every managed Orukeet connection spends a single-use GPU token, and both
+ // post-dictation re-warm paths fire together. Warmups run one at a time so
+ // the second finds the first's fresh socket and reuses it rather than
+ // discarding it and minting another.
+ const isUnusedOrukeetConnection = (streaming, options) =>
+ streaming instanceof OrukeetStreaming &&
+ streaming.isConnected &&
+ !streaming.failure &&
+ !streaming.finalPromise &&
+ streaming.audioBytesSent === 0 &&
+ streaming.connectionKey === dictationConnectionKey(options);
+
+ const warmupDictationStreaming = async (event, options) => {
+ await this._dictationConnectPromise?.catch(() => {});
+ if (!isUnusedOrukeetConnection(this._dictationStreaming, options)) {
await connectDictationStreaming(event, options);
startDictationIdleTimer();
return { success: true };
- } catch (err) {
- return streamingStartFailure(err);
}
+ startDictationIdleTimer();
+ return { success: true, alreadyWarm: true };
+ };
+
+ let dictationWarmupQueue = Promise.resolve();
+ ipcMain.handle("dictation-realtime-warmup", (event, options = {}) => {
+ const warmup = dictationWarmupQueue
+ .then(() => warmupDictationStreaming(event, options))
+ .catch(streamingStartFailure);
+ dictationWarmupQueue = warmup;
+ return warmup;
});
ipcMain.handle("dictation-realtime-start", async (event, options = {}) => {
try {
clearDictationIdleTimer();
this._dictationPreviewEnabled = !!options.preview;
- if (!this._dictationStreaming?.isConnected) await connectDictationStreaming(event, options);
+ if (
+ !this._dictationStreaming?.isConnected ||
+ this._dictationStreaming.connectionKey !== dictationConnectionKey(options)
+ ) {
+ await connectDictationStreaming(event, options);
+ }
return { success: true };
} catch (err) {
return streamingStartFailure(err);
@@ -9112,6 +9194,17 @@ class IPCHandlers {
this._dictationStreaming?.sendAudio(Buffer.from(buffer));
});
+ ipcMain.handle("dictation-realtime-finalize", async () => {
+ if (!(this._dictationStreaming instanceof OrukeetStreaming)) {
+ return { success: false, error: "No Orukeet recording is active" };
+ }
+ try {
+ return { success: true, ...(await this._dictationStreaming.finalize()) };
+ } catch (error) {
+ return { success: false, error: error.message };
+ }
+ });
+
ipcMain.handle("dictation-realtime-stop", async () => {
clearDictationIdleTimer();
if (!this._dictationStreaming) {
@@ -9123,7 +9216,7 @@ class IPCHandlers {
this.windowManager.hideTranscriptionPreview();
this._dictationPreviewEnabled = false;
}
- return { success: true, text: result.text || "" };
+ return { success: true, ...result, text: result.text || "" };
});
ipcMain.handle(
@@ -9357,6 +9450,7 @@ class IPCHandlers {
clientType: "desktop",
appVersion: app.getVersion(),
clientVersion: app.getVersion(),
+ streamingFallbackReason: opts.streamingFallbackReason,
sttProvider: opts.sttProvider,
sttModel: opts.sttModel,
sttProcessingMs: opts.sttProcessingMs,
diff --git a/src/helpers/orukeetCloudSession.js b/src/helpers/orukeetCloudSession.js
new file mode 100644
index 000000000..60221cd3b
--- /dev/null
+++ b/src/helpers/orukeetCloudSession.js
@@ -0,0 +1,100 @@
+const { captureAuthFence } = require("./cloudApiRequest");
+const { createPolicyResponseError } = require("./policyResponseError");
+
+const ORUKEET_BASE_URL = "https://orukeet.gizmovoice.ai";
+const ORUKEET_SESSION_PATH = "/api/stt/orukeet/session";
+
+function validateSession(data) {
+ if (
+ data?.baseUrl !== ORUKEET_BASE_URL ||
+ data?.websocketUrl !==
+ `${ORUKEET_BASE_URL.replace("https:", "wss:")}/v1/audio/transcriptions/stream` ||
+ data?.protocol !== "orukeet.pcm.v1" ||
+ data?.model !== "orukeet-v0.1.0" ||
+ data?.singleUse !== true ||
+ data?.expiresIn !== 60 ||
+ typeof data?.clientToken !== "string" ||
+ !/^[A-Za-z0-9._-]{1,96}$/.test(data.clientToken)
+ ) {
+ throw new Error("Invalid Orukeet cloud session");
+ }
+ return { baseUrl: ORUKEET_BASE_URL, clientToken: data.clientToken };
+}
+
+// Main process only. The account bearer goes to the existing Cloud backend;
+// only its single-use session token goes to the fixed Orukeet endpoint.
+async function connectManagedOrukeet({
+ streaming,
+ getApiUrl,
+ proxyFetch,
+ tokenStore,
+ withPolicyHeaders,
+}) {
+ const apiUrl = getApiUrl();
+ if (!apiUrl) throw new Error("OpenWhispr API URL not configured");
+ const fence = captureAuthFence(tokenStore, tokenStore.getState().generation);
+ const controller = new AbortController();
+ const unsubscribe = tokenStore.subscribe(() => {
+ try {
+ fence.assertCurrent();
+ } catch (error) {
+ streaming.fail(error);
+ }
+ });
+ const onClose = streaming.onClose;
+ streaming.onClose = () => {
+ controller.abort();
+ unsubscribe();
+ onClose?.();
+ };
+ const assertActive = () => {
+ fence.assertCurrent();
+ if (streaming.intentionalClose || streaming.failure) {
+ throw streaming.failure || new Error("Orukeet recording cancelled");
+ }
+ };
+ try {
+ assertActive();
+ const response = await fence.awaitBound(() =>
+ proxyFetch(`${apiUrl}${ORUKEET_SESSION_PATH}`, {
+ method: "POST",
+ headers: withPolicyHeaders({ Authorization: fence.authorization }),
+ useSessionCookies: false,
+ redirect: "error",
+ cache: "no-store",
+ signal: AbortSignal.any([controller.signal, AbortSignal.timeout(10000)]),
+ })
+ );
+ assertActive();
+ if (response.status === 401) {
+ throw Object.assign(new Error("Session expired"), { code: "AUTH_EXPIRED", status: 401 });
+ }
+ if (!response.ok) {
+ const payload = await fence.awaitBound(() => response.json().catch(() => null));
+ // The weekly word quota, as opposed to the RATE_LIMITED mint cap: the
+ // same LIMIT_REACHED the batch upload raises, carrying the usage the
+ // upgrade prompt shows.
+ if (response.status === 429 && payload?.limitReached === true) {
+ throw Object.assign(new Error(payload.error || "Weekly word limit reached"), {
+ code: "LIMIT_REACHED",
+ status: 429,
+ details: { wordsUsed: payload.wordsUsed, limit: payload.limit },
+ });
+ }
+ throw createPolicyResponseError(
+ response.status,
+ payload,
+ `Orukeet session unavailable (${response.status})`
+ );
+ }
+ const data = await fence.awaitBound(() => response.json());
+ assertActive();
+ await streaming.connect(validateSession(data));
+ assertActive();
+ } catch (error) {
+ streaming.close();
+ throw error;
+ }
+}
+
+module.exports = { connectManagedOrukeet, validateSession, ORUKEET_BASE_URL, ORUKEET_SESSION_PATH };
diff --git a/src/helpers/orukeetStreaming.js b/src/helpers/orukeetStreaming.js
new file mode 100644
index 000000000..1d9c2864e
--- /dev/null
+++ b/src/helpers/orukeetStreaming.js
@@ -0,0 +1,296 @@
+const WebSocket = require("ws");
+
+const MAX_PENDING_BYTES = 2 * 1024 * 1024;
+
+function languageMetadata(message) {
+ const language = message.language;
+ const confidence = message.language_confidence;
+ if (
+ typeof language === "string" &&
+ /^[a-z]{2}$/.test(language) &&
+ Number.isFinite(confidence) &&
+ confidence >= 0 &&
+ confidence <= 1
+ ) {
+ return {
+ language,
+ languageConfidence: confidence,
+ ...(Number.isFinite(message.language_audio_seconds) && message.language_audio_seconds > 0
+ ? { languageAudioSeconds: message.language_audio_seconds }
+ : {}),
+ };
+ }
+ return { language: null, languageConfidence: null };
+}
+
+function capacityRetryDelay(requestedMs) {
+ if (!Number.isFinite(requestedMs)) return 100;
+ // Select a fixed local delay, rounding the server's hint up. Large hints
+ // wait for the final deadline instead of overflowing Node's timer to 1 ms.
+ for (const delay of [20, 50, 100, 250, 500, 1000, 2000, 5000, 10000, 30000]) {
+ if (requestedMs <= delay) return delay;
+ }
+ return 30000;
+}
+
+function streamingUrl(baseUrl) {
+ const url = new URL(baseUrl);
+ const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
+ if (url.username || url.password || url.search || url.hash) {
+ throw new Error("Use an Orukeet server URL without credentials or query parameters");
+ }
+ if (
+ !["https:", "wss:"].includes(url.protocol) &&
+ !(local && ["http:", "ws:"].includes(url.protocol))
+ ) {
+ throw new Error("Orukeet streaming requires HTTPS");
+ }
+ url.protocol = ["https:", "wss:"].includes(url.protocol) ? "wss:" : "ws:";
+ url.pathname =
+ url.pathname.replace(/\/$/, "").replace(/\/v1(?:\/audio\/transcriptions(?:\/stream)?)?$/, "") +
+ "/v1/audio/transcriptions/stream";
+ return url.toString();
+}
+
+// Upload PCM while recording; commit has an explicit final acknowledgement.
+// Credentials stay in the main process and are sent only to the selected host.
+class OrukeetStreaming {
+ constructor({
+ createSocket = (url, options, protocols) => new WebSocket(url, protocols, options),
+ timeoutMs = 30000,
+ } = {}) {
+ this.createSocket = createSocket;
+ this.timeoutMs = timeoutMs;
+ this.ws = null;
+ this.isConnected = false;
+ this.pendingAudio = [];
+ this.pendingBytes = 0;
+ this.audioBytesSent = 0;
+ this.currentModel = "orukeet-v0.1.0";
+ this.result = null;
+ this.finalPromise = null;
+ this.intentionalClose = false;
+ }
+
+ beginConnecting() {
+ this.connecting = true;
+ }
+
+ async connect({ baseUrl, apiKey, clientToken }) {
+ if (this.intentionalClose || this.failure || this.ws) {
+ throw new Error("Create a new Orukeet adapter for each recording");
+ }
+ if (Boolean(apiKey) === Boolean(clientToken)) {
+ throw new Error("Supply exactly one Orukeet service key or client token");
+ }
+ if (clientToken && !/^[A-Za-z0-9._-]{1,96}$/.test(clientToken)) {
+ throw new Error("Invalid Orukeet client token");
+ }
+ const url = streamingUrl(baseUrl);
+ this.beginConnecting();
+ this.ws = this.createSocket(
+ url,
+ {
+ headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
+ perMessageDeflate: false,
+ handshakeTimeout: this.timeoutMs,
+ maxPayload: MAX_PENDING_BYTES,
+ },
+ clientToken ? ["orukeet.pcm.v1", `auth.${clientToken}`] : undefined
+ );
+ return new Promise((resolve, reject) => {
+ const timer = setTimeout(
+ () => this.fail(new Error("Orukeet connection timed out")),
+ this.timeoutMs
+ );
+ this.connectResolve = () => {
+ clearTimeout(timer);
+ resolve();
+ };
+ this.connectReject = (error) => {
+ clearTimeout(timer);
+ reject(error);
+ };
+ this.ws.on("message", (data) => {
+ try {
+ this.handleMessage(JSON.parse(data.toString()));
+ } catch (error) {
+ this.fail(error);
+ }
+ });
+ this.ws.on("error", (error) => this.fail(error));
+ this.ws.on("close", () => {
+ if (!this.intentionalClose)
+ this.fail(new Error("Orukeet connection closed before completion"));
+ this.isConnected = false;
+ });
+ });
+ }
+
+ handleMessage(message) {
+ if (this.intentionalClose || this.failure) return;
+ if (message.type === "ready") {
+ if (this.isConnected) throw new Error("Duplicate Orukeet ready message");
+ if (
+ message.sample_rate !== 16000 ||
+ message.encoding !== "pcm_s16le" ||
+ message.channels !== 1 ||
+ !Number.isFinite(message.max_seconds) ||
+ message.max_seconds <= 0 ||
+ message.max_seconds > 600
+ ) {
+ throw new Error("Orukeet server does not support mono 16 kHz PCM");
+ }
+ this.maxAudioBytes = message.max_seconds * 32000;
+ this.isConnected = true;
+ this.connecting = false;
+ for (const data of this.pendingAudio) this.writeAudio(data);
+ this.pendingAudio = [];
+ this.pendingBytes = 0;
+ this.connectResolve?.();
+ this.connectResolve = this.connectReject = null;
+ this.keepAlive = setInterval(() => {
+ if (this.isConnected) this.sendControl({ type: "ping" });
+ }, 15000);
+ this.keepAlive.unref?.();
+ } else if (message.type === "language") {
+ // Advisory audio-language metadata never commits a transcript or triggers a paste.
+ // The final message remains authoritative for this recording.
+ if (!this.isConnected || this.result) return;
+ const metadata = languageMetadata(message);
+ if (metadata.language) this.onLanguage?.(metadata);
+ } else if (message.type === "final") {
+ // A duplicate or unsolicited final must never result in a second paste.
+ if (this.result) return;
+ if (!this.finalResolve || typeof message.text !== "string") {
+ throw new Error("Unexpected Orukeet final transcript");
+ }
+ this.result = {
+ text: message.text || "",
+ model: message.model || this.currentModel,
+ audioBytesSent: this.audioBytesSent,
+ inferenceMs: message.inference_ms,
+ serverMs: message.server_ms,
+ queueMs: message.queue_ms,
+ ...("language" in message ? languageMetadata(message) : {}),
+ };
+ this.onFinalTranscript?.(this.result.text);
+ this.finalResolve?.(this.result);
+ this.clearFinal();
+ } else if (message.type === "error") {
+ if (message.code === "capacity" && this.finalResolve) {
+ clearTimeout(this.retryTimer);
+ this.retryTimer = setTimeout(() => {
+ if (this.finalResolve) this.sendControl({ type: "commit" });
+ }, capacityRetryDelay(message.retry_after_ms));
+ } else {
+ this.fail(new Error(message.message || `Orukeet transcription failed: ${message.code}`));
+ }
+ }
+ }
+
+ sendAudio(data) {
+ if (this.intentionalClose || this.failure || this.finalPromise) return;
+ const buffer = Buffer.from(data);
+ if (buffer.length % 2) return this.fail(new Error("Orukeet requires complete PCM16 samples"));
+ if (this.isConnected) {
+ try {
+ this.writeAudio(buffer);
+ } catch (error) {
+ this.fail(error);
+ }
+ } else if (this.connecting && this.pendingBytes + buffer.length <= MAX_PENDING_BYTES) {
+ this.pendingAudio.push(buffer);
+ this.pendingBytes += buffer.length;
+ } else this.fail(new Error("Orukeet audio upload could not keep up"));
+ }
+
+ writeAudio(buffer) {
+ if (
+ this.ws.readyState !== WebSocket.OPEN ||
+ this.ws.bufferedAmount + buffer.length > MAX_PENDING_BYTES ||
+ this.audioBytesSent + buffer.length > this.maxAudioBytes
+ ) {
+ throw new Error("Orukeet recording exceeds the server or upload capacity");
+ }
+ this.ws.send(buffer);
+ this.audioBytesSent += buffer.length;
+ }
+
+ sendControl(message) {
+ try {
+ if (!this.isConnected || this.ws.readyState !== WebSocket.OPEN) {
+ throw new Error("Orukeet connection closed before completion");
+ }
+ this.ws.send(JSON.stringify(message));
+ } catch (error) {
+ this.fail(error);
+ }
+ }
+
+ finalize() {
+ if (this.failure) return Promise.reject(this.failure);
+ if (this.result) return Promise.resolve(this.result);
+ if (this.finalPromise) return this.finalPromise;
+ if (!this.isConnected) return Promise.reject(new Error("Orukeet connection is not ready"));
+ if (!this.audioBytesSent)
+ return Promise.resolve({ text: "", model: this.currentModel, audioBytesSent: 0 });
+ this.finalPromise = new Promise((resolve, reject) => {
+ this.finalResolve = resolve;
+ this.finalReject = reject;
+ this.finalTimer = setTimeout(
+ () => this.fail(new Error("Orukeet final transcript timed out")),
+ this.timeoutMs
+ );
+ this.sendControl({ type: "commit" });
+ });
+ return this.finalPromise;
+ }
+
+ clearFinal() {
+ clearTimeout(this.finalTimer);
+ clearTimeout(this.retryTimer);
+ this.finalResolve = this.finalReject = null;
+ }
+
+ fail(error) {
+ if (this.failure) return;
+ this.failure = error;
+ this.connectReject?.(error);
+ this.connectResolve = this.connectReject = null;
+ this.finalReject?.(error);
+ this.clearFinal();
+ this.close();
+ this.onError?.(error);
+ }
+
+ close() {
+ if (this.intentionalClose) return;
+ this.intentionalClose = true;
+ clearInterval(this.keepAlive);
+ this.isConnected = false;
+ this.connecting = false;
+ this.pendingAudio = [];
+ this.pendingBytes = 0;
+ this.ws?.close();
+ this.onClose?.();
+ }
+
+ async disconnect() {
+ // Stop is also used for cancellation and idle cleanup: only finalize()
+ // commits audio, so cancelled recordings never submit inference.
+ const result = this.result || {
+ text: "",
+ model: this.currentModel,
+ audioBytesSent: this.audioBytesSent,
+ };
+ this.connectReject?.(new Error("Orukeet connection cancelled"));
+ this.connectResolve = this.connectReject = null;
+ this.close();
+ if (this.finalReject) this.finalReject(new Error("Orukeet recording cancelled"));
+ this.clearFinal();
+ return result;
+ }
+}
+
+module.exports = { OrukeetStreaming, streamingUrl };
diff --git a/src/helpers/policyRequestHeaders.js b/src/helpers/policyRequestHeaders.js
index b5e8b9d61..a0b165193 100644
--- a/src/helpers/policyRequestHeaders.js
+++ b/src/helpers/policyRequestHeaders.js
@@ -1,6 +1,10 @@
const { isCanonicalAppVersion } = require("./appVersion");
const POLICY_CAPABILITY_VERSION = "1";
+// Features this build can actually run. The server gates Orukeet on this token,
+// not on the version alone, so an older build that passes the version gate is
+// never handed a route it would silently reroute.
+const CLIENT_CAPABILITIES = "orukeet";
function withPolicyRequestHeaders(headers, appVersion) {
if (!isCanonicalAppVersion(appVersion)) {
@@ -10,7 +14,8 @@ function withPolicyRequestHeaders(headers, appVersion) {
...headers,
"x-openwhispr-policy-version": POLICY_CAPABILITY_VERSION,
"x-openwhispr-version": appVersion,
+ "x-openwhispr-capabilities": CLIENT_CAPABILITIES,
};
}
-module.exports = { POLICY_CAPABILITY_VERSION, withPolicyRequestHeaders };
+module.exports = { CLIENT_CAPABILITIES, POLICY_CAPABILITY_VERSION, withPolicyRequestHeaders };
diff --git a/src/helpers/selfHostedTranscription.js b/src/helpers/selfHostedTranscription.js
index b6a05522f..55dce5124 100644
--- a/src/helpers/selfHostedTranscription.js
+++ b/src/helpers/selfHostedTranscription.js
@@ -16,3 +16,18 @@ export function resolveSelfHostedTranscriptionModel(settings) {
: "";
return model.length > 0 ? model : null;
}
+
+// The explicit model id opts compatible custom endpoints into Orukeet's PCM
+// protocol. Other self-hosted models retain their existing HTTP route.
+export function isOrukeetEndpoint(settings) {
+ return (
+ settings?.cloudTranscriptionProvider === "custom" &&
+ (settings?.remoteTranscriptionModel || settings?.cloudTranscriptionModel) ===
+ "orukeet-v0.1.0" &&
+ Boolean(settings?.remoteTranscriptionUrl || settings?.cloudTranscriptionBaseUrl)
+ );
+}
+
+export function isOrukeetStreaming(settings) {
+ return settings?.cloudTranscriptionMode === "byok" && isOrukeetEndpoint(settings);
+}
diff --git a/src/helpers/transcriptionAuth.js b/src/helpers/transcriptionAuth.js
index c15bded39..8faacc611 100644
--- a/src/helpers/transcriptionAuth.js
+++ b/src/helpers/transcriptionAuth.js
@@ -1,5 +1,5 @@
-import { isSelfHostedTranscription } from "./selfHostedTranscription.js";
+import { isOrukeetEndpoint, isSelfHostedTranscription } from "./selfHostedTranscription.js";
export function shouldSkipTranscriptionApiKey(settings) {
- return isSelfHostedTranscription(settings);
+ return isSelfHostedTranscription(settings) && !isOrukeetEndpoint(settings);
}
diff --git a/src/helpers/transcriptionFallback.js b/src/helpers/transcriptionFallback.js
index 75f3d0d23..c6dc582f4 100644
--- a/src/helpers/transcriptionFallback.js
+++ b/src/helpers/transcriptionFallback.js
@@ -9,3 +9,30 @@ export function resolveStreamingFallbackTarget({
if (isCloudMode) return isSignedIn ? "cloud" : "skip";
return "byok";
}
+
+// Denials the user has to act on, which batch could not absorb either. An
+// account switch mid-start is one too: the recording must not continue under
+// a different account.
+const USER_ACTIONABLE_START_FAILURES = new Set([
+ "AUTH_EXPIRED",
+ "AUTH_REQUIRED",
+ "AUTH_CONTEXT_CHANGED",
+ "ACCOUNT_REQUIRED",
+ "UPGRADE_REQUIRED",
+ "LIMIT_REACHED",
+]);
+
+// Every other managed Orukeet start failure goes to batch rather than losing
+// the dictation: the rollout was turned off for this account, its mint window
+// is exhausted, or the session service, the network, the WebSocket or the
+// session response failed. Scoped to the managed Orukeet route so no other
+// provider's start-failure behavior changes.
+export function resolveStreamingStartFallback({ providerName, cloudTranscriptionMode, result }) {
+ if (providerName !== "orukeet" || cloudTranscriptionMode !== "openwhispr") return null;
+ if (USER_ACTIONABLE_START_FAILURES.has(result.code) || result.code?.startsWith("POLICY_")) {
+ return null;
+ }
+ if (result.code === "FEATURE_NOT_ENABLED") return "feature_disabled";
+ if (result.code === "RATE_LIMITED") return "rate_limited";
+ return "session_unavailable";
+}
diff --git a/src/helpers/transcriptionRoute.ts b/src/helpers/transcriptionRoute.ts
index 5efc69a51..2f188436b 100644
--- a/src/helpers/transcriptionRoute.ts
+++ b/src/helpers/transcriptionRoute.ts
@@ -14,6 +14,7 @@ import {
buildAzureTranscriptionUrl,
} from "../utils/urlUtils.ts";
import {
+ isOrukeetEndpoint,
isSelfHostedTranscription,
resolveSelfHostedTranscriptionModel,
} from "./selfHostedTranscription.js";
@@ -312,7 +313,9 @@ export function resolveTranscriptionRoute({
provider: "self-hosted",
endpoint: buildBatchEndpoint(rawUrl, base, selfHostedModel),
model: selfHostedModel,
- auth: { scheme: "none", keyRef: null },
+ auth: isOrukeetEndpoint(s)
+ ? { scheme: "bearer", keyRef: "custom" }
+ : { scheme: "none", keyRef: null },
sizeCapBytes: null,
language,
};
diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.js
index 536d64e5a..ac5830b26 100644
--- a/src/hooks/useAudioRecording.js
+++ b/src/hooks/useAudioRecording.js
@@ -205,11 +205,15 @@ export const useAudioRecording = (toast, options = {}) => {
audioManagerRef.current.beginSelectionCapture();
}
- // Retry STT config fetch if it wasn't loaded on mount (e.g. auth wasn't ready).
- // Await it only when it can change the start decision (signed-in
- // OpenWhispr-cloud streaming); for local STT or a signed-out session the
- // fetch stalls on auth resolution and would delay the mic open (#1673).
- if (!audioManagerRef.current.sttConfig) {
+ // Retry STT config fetch if it wasn't loaded on mount (e.g. auth wasn't ready),
+ // and refresh a copy older than its TTL so a server-side rollout change
+ // reaches a long-running app. Await it only when it can change the start
+ // decision (no config yet, signed-in OpenWhispr-cloud streaming); for
+ // local STT or a signed-out session the fetch stalls on auth resolution
+ // and would delay the mic open (#1673). A stale-but-present copy is
+ // refreshed in the background and this recording keeps the old decision.
+ if (audioManagerRef.current.isSttConfigStale()) {
+ const hadConfig = Boolean(audioManagerRef.current.sttConfig);
const configFetch = (async () => {
const config = await window.electronAPI.getSttConfig?.();
if (config?.success) {
@@ -218,7 +222,7 @@ export const useAudioRecording = (toast, options = {}) => {
})().catch((error) => {
logger.warn("STT config fetch failed", { error: error?.message });
});
- if (needsSttConfigBeforeStart(getSettings())) {
+ if (!hadConfig && needsSttConfigBeforeStart(getSettings())) {
await configFetch;
}
}
diff --git a/src/types/electron.ts b/src/types/electron.ts
index dcd44df01..545d43fa6 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -72,6 +72,7 @@ export interface NoteRecordingProvider {
// renderers (#1624).
export interface DictationRealtimeSessionOptions {
provider: string;
+ baseUrl?: string;
model?: string;
mode?: "byok" | "openwhispr";
language?: string;
@@ -82,6 +83,12 @@ export interface DictationRealtimeSessionOptions {
preview?: boolean;
}
+export interface DictationLanguageMetadata {
+ language: string | null;
+ languageConfidence: number | null;
+ languageAudioSeconds?: number;
+}
+
export type NoteRecordingConfigFailure = { success: false } & PolicyFailureMetadata;
export type NoteRecordingConfigResult =
@@ -2355,6 +2362,8 @@ declare global {
diarization?: boolean;
localDate?: string;
analyticsOccurredAt?: string;
+ // Why a managed-streaming user's dictation went batch (rollout metric).
+ streamingFallbackReason?: string;
}
) => Promise<
{
@@ -2382,6 +2391,7 @@ declare global {
screenContext?: ScreenContextImage;
language?: string;
locale?: string;
+ streamingFallbackReason?: string;
}
) => Promise<{
success: boolean;
@@ -3095,9 +3105,19 @@ declare global {
options: DictationRealtimeSessionOptions
) => Promise<{ success: boolean } & PolicyFailureMetadata>;
dictationRealtimeSend?: (buffer: ArrayBuffer) => void;
+ dictationRealtimeFinalize?: () => Promise<
+ {
+ success: boolean;
+ text?: string;
+ error?: string;
+ } & Partial<DictationLanguageMetadata>
+ >;
dictationRealtimeStop?: () => Promise<{ success: boolean; text: string }>;
onDictationRealtimePartial?: (callback: (text: string) => void) => () => void;
onDictationRealtimeFinal?: (callback: (text: string) => void) => () => void;
+ onDictationRealtimeLanguage?: (
+ callback: (metadata: DictationLanguageMetadata) => void
+ ) => () => void;
onDictationRealtimeError?: (callback: (error: string) => void) => () => void;
onDictationRealtimeSessionEnd?: (callback: (data: { text: string }) => void) => () => void;
diff --git a/test/helpers/audioManagerStreamingFinalization.test.js b/test/helpers/audioManagerStreamingFinalization.test.js
index ff3f099b5..2ba7847db 100644
--- a/test/helpers/audioManagerStreamingFinalization.test.js
+++ b/test/helpers/audioManagerStreamingFinalization.test.js
@@ -391,3 +391,142 @@ test("an older streaming session cannot clean up the active session listeners",
assert.equal(manager.streamingFinalText, "current transcript");
assert.equal(manager.streamingPartialText, "current partial");
});
+
+test("Orukeet commits only after the worklet flush and skips settling sleeps", async (t) => {
+ const AudioManager = await loadManagerClass(t);
+ const { manager } = createFinalizingManager(AudioManager);
+ const order = [];
+ const delays = [];
+ const originalTimeout = globalThis.setTimeout;
+ t.mock.method(globalThis, "setTimeout", (callback, ms, ...args) => {
+ delays.push(ms);
+ return originalTimeout(callback, ms, ...args);
+ });
+ manager.streamingProcessor = {
+ port: {
+ postMessage(message) {
+ assert.equal(message, "stop");
+ queueMicrotask(() => {
+ order.push("last-pcm");
+ manager._streamingFlushResolve();
+ });
+ },
+ },
+ disconnect() {
+ order.push("capture-stopped");
+ },
+ };
+ manager.getStreamingProvider = () => ({
+ finalizeAcknowledged: true,
+ async finalize() {
+ order.push("commit");
+ return { success: true, text: "" };
+ },
+ async stop() {
+ order.push("socket-stopped");
+ return { success: true, text: "" };
+ },
+ });
+ manager.awaitStreamingTextSettled = () => {
+ throw new Error("Unexpected settling delay");
+ };
+ await manager.stopStreamingRecording();
+ assert.deepEqual(order, ["last-pcm", "capture-stopped", "commit", "socket-stopped"]);
+ assert.equal(delays.includes(120), false);
+ assert.equal(delays.includes(300), false);
+});
+
+test("acknowledged streaming silence does not trigger another transcription", async (t) => {
+ const AudioManager = await loadManagerClass(t);
+ const { manager } = createFinalizingManager(AudioManager);
+ manager.recordingStartTime = Date.now() - 5000;
+ manager.streamingFallbackChunks = [new Blob([new Uint8Array(100)])];
+ manager.finishStreamingFallbackSegment = async () => new Blob([new Uint8Array(100)]);
+ manager.mergeRecordedSegments = async () => new Blob([new Uint8Array(100)]);
+ let fallbackCalls = 0;
+ manager.processWithOpenAIAPI = async () => {
+ fallbackCalls += 1;
+ return { text: "unexpected" };
+ };
+ manager.getStreamingProvider = () => ({
+ finalizeAcknowledged: true,
+ finalize: async () => ({ success: true, text: "" }),
+ stop: async () => ({ success: true, text: "" }),
+ });
+ const completions = [];
+ manager.onTranscriptionComplete = (result) => completions.push(result);
+ assert.equal(await manager.stopStreamingRecording(), true);
+ assert.equal(completions.length, 1);
+ assert.equal(completions[0].text, "");
+ assert.equal(fallbackCalls, 0);
+});
+
+test("a stream without a final falls back to batch for every provider, tagged only for Orukeet", async (t) => {
+ const AudioManager = await loadManagerClass(t);
+ globalThis.__streamingFinalizationSettings = {
+ ...globalThis.__streamingFinalizationSettings,
+ cloudTranscriptionMode: "openwhispr",
+ isSignedIn: true,
+ };
+ const uploads = [];
+ for (const providerName of ["orukeet", "openai-realtime", "deepgram"]) {
+ const { manager } = createFinalizingManager(AudioManager);
+ manager.recordingStartTime = Date.now() - 5000;
+ manager.mergeRecordedSegments = async () => new Blob([new Uint8Array(100)]);
+ manager.getStreamingProviderName = () => providerName;
+ manager.processWithOpenWhisprCloud = async (_blob, metadata) => {
+ uploads.push([providerName, metadata.streamingFallbackReason]);
+ return { text: "" };
+ };
+ await manager.stopStreamingRecording();
+ }
+
+ assert.deepEqual(uploads, [
+ ["orukeet", "stream_no_final"],
+ ["openai-realtime", undefined],
+ ["deepgram", undefined],
+ ]);
+});
+
+test("Orukeet uses the acknowledged final even if the transcript event is delayed", async (t) => {
+ const AudioManager = await loadManagerClass(t);
+ const { manager } = createFinalizingManager(AudioManager);
+ manager.getStreamingProvider = () => ({
+ finalizeAcknowledged: true,
+ finalize: async () => ({ success: true, text: "Acknowledged final" }),
+ stop: async () => ({ success: true, text: "" }),
+ });
+ let usageReported;
+ const usage = new Promise((resolve) => {
+ usageReported = resolve;
+ });
+ globalThis.window.electronAPI.cloudStreamingUsage = async () => ({ success: true });
+ globalThis.window.dispatchEvent = () => usageReported();
+ const results = [];
+ manager.onTranscriptionComplete = (result) => results.push(result);
+ await manager.stopStreamingRecording();
+ await usage;
+ assert.equal(results[0].text, "Acknowledged final");
+});
+
+test("missing Orukeet capture flush never commits a partial recording", async (t) => {
+ const AudioManager = await loadManagerClass(t);
+ const { manager } = createFinalizingManager(AudioManager);
+ const originalTimeout = globalThis.setTimeout;
+ t.mock.method(globalThis, "setTimeout", (callback, ms, ...args) =>
+ originalTimeout(callback, Math.min(ms, 10), ...args)
+ );
+ let stopped = false;
+ manager.streamingProcessor = { port: { postMessage() {} }, disconnect() {} };
+ manager.getStreamingProvider = () => ({
+ finalizeAcknowledged: true,
+ finalize: async () => assert.fail("incomplete PCM must not be committed"),
+ stop: async () => {
+ stopped = true;
+ return { success: true, text: "" };
+ },
+ });
+ await manager.stopStreamingRecording();
+ assert.equal(stopped, true);
+ assert.equal(manager.streamingProcessor, null);
+});
diff --git a/test/helpers/audioManagerStreamingRouting.test.js b/test/helpers/audioManagerStreamingRouting.test.js
index 837b44c62..9e023a6da 100644
--- a/test/helpers/audioManagerStreamingRouting.test.js
+++ b/test/helpers/audioManagerStreamingRouting.test.js
@@ -156,3 +156,348 @@ test("managed OpenWhispr Cloud still respects its batch configuration", async (t
assert.equal(manager.shouldUseStreaming(), false);
});
+
+test("explicit Orukeet custom endpoint uses PCM streaming without cloud login", async (t) => {
+ const manager = await loadManager(t);
+ setSettings({
+ transcriptionMode: "self-hosted",
+ cloudTranscriptionProvider: "custom",
+ cloudTranscriptionModel: "orukeet-v0.1.0",
+ cloudTranscriptionBaseUrl: "https://example.com/v1",
+ customTranscriptionApiKey: "test-key",
+ isSignedIn: false,
+ });
+ assert.equal(manager.shouldUseStreaming(), true);
+ assert.equal(manager.getStreamingProviderName(), "orukeet");
+ assert.equal(manager.getStreamingProvider().finalizeAcknowledged, true);
+ setSettings({
+ transcriptionMode: "self-hosted",
+ cloudTranscriptionProvider: "custom",
+ cloudTranscriptionModel: "whisper-1",
+ remoteTranscriptionUrl: "https://example.com/v1",
+ });
+ assert.equal(manager.shouldUseStreaming(), false);
+});
+
+test("managed Orukeet rollout overrides stale personal provider and model without a key", async (t) => {
+ const manager = await loadManager(t);
+ manager.sttConfig = { dictation: { mode: "streaming" }, streamingProvider: "orukeet" };
+ setSettings({
+ cloudTranscriptionMode: "openwhispr",
+ cloudTranscriptionProvider: "gemini",
+ cloudTranscriptionModel: "gemini-3.5-transcribe",
+ });
+ assert.equal(manager.shouldUseStreaming(), true);
+ assert.equal(manager.getStreamingProviderName(), "orukeet");
+ const calls = [];
+ globalThis.window.electronAPI.dictationRealtimeWarmup = async (options) => {
+ calls.push(options);
+ return { success: true };
+ };
+ await manager.warmupStreamingConnection();
+ assert.equal(calls[0].mode, "openwhispr");
+ assert.equal(calls[0].provider, "orukeet");
+ assert.equal(calls[0].model, "orukeet-v0.1.0");
+ assert.equal(calls[0].baseUrl, undefined);
+ setSettings({ cloudTranscriptionMode: "openwhispr", isSignedIn: false });
+ assert.equal(manager.shouldUseStreaming(), false);
+ setSettings({ cloudTranscriptionMode: "openwhispr" });
+ manager.sttConfig.dictation.mode = "batch";
+ assert.equal(manager.shouldUseStreaming(), false);
+ setSettings({ cloudTranscriptionMode: "byok" });
+ assert.equal(manager.getStreamingProviderName(), "openai-realtime");
+});
+
+const orukeetConfig = { dictation: { mode: "streaming" }, streamingProvider: "orukeet" };
+const managedSettings = (overrides) =>
+ setSettings({ cloudTranscriptionMode: "openwhispr", isSignedIn: true, ...overrides });
+
+test("managed Orukeet only streams languages the model covers", async (t) => {
+ const manager = await loadManager(t);
+ manager.sttConfig = orukeetConfig;
+
+ managedSettings({ preferredLanguage: "fr" });
+ assert.equal(manager.shouldUseStreaming(), true);
+ assert.equal(manager.getStreamingProviderName(), "orukeet");
+
+ managedSettings({ preferredLanguage: "ja" });
+ assert.equal(manager.shouldUseStreaming(), false);
+
+ managedSettings({ preferredLanguage: "auto" });
+ assert.equal(manager.shouldUseStreaming(), true);
+
+ managedSettings({ preferredLanguage: "fr", isSignedIn: false });
+ assert.equal(manager.shouldUseStreaming(), false);
+});
+
+test("a refused managed Orukeet session starts a batch recording instead of failing", async (t) => {
+ const manager = await loadManager(t);
+ manager.sttConfig = orukeetConfig;
+ managedSettings({ preferredLanguage: "fr" });
+ const errors = [];
+ manager.onError = (error) => errors.push(error);
+ const classify = (result) =>
+ manager.classifyStreamingStartResult(result, { useLocalWhisper: false });
+
+ assert.deepEqual(classify({ success: false, code: "FEATURE_NOT_ENABLED", status: 403 }), {
+ needsFallback: true,
+ });
+ // The cached config advertised a route the server no longer grants: drop it
+ // so the next recording refetches instead of retrying a denied route.
+ assert.equal(manager.sttConfig, null);
+ assert.equal(manager.streamingFallbackReason, "feature_disabled");
+
+ manager.sttConfig = orukeetConfig;
+ assert.deepEqual(classify({ success: false, status: 503 }), { needsFallback: true });
+ assert.equal(manager.sttConfig, orukeetConfig);
+ assert.equal(manager.streamingFallbackReason, "session_unavailable");
+
+ assert.throws(() => classify({ success: false, code: "POLICY_MODE_BLOCKED", status: 403 }), {
+ code: "POLICY_MODE_BLOCKED",
+ });
+ assert.throws(() => classify({ success: false, code: "AUTH_EXPIRED", status: 401 }), {
+ code: "AUTH_EXPIRED",
+ });
+
+ // A network error, timeout or WebSocket failure has no status or code: batch
+ // takes the dictation instead of it being lost behind an error.
+ manager.streamingFallbackReason = null;
+ assert.deepEqual(classify({ success: false, code: "NETWORK_ERROR" }), { needsFallback: true });
+ assert.equal(manager.streamingFallbackReason, "session_unavailable");
+ manager.streamingFallbackReason = null;
+ assert.deepEqual(classify({ success: false, error: "Orukeet connection closed" }), {
+ needsFallback: true,
+ });
+ assert.equal(manager.streamingFallbackReason, "session_unavailable");
+ assert.equal(errors.length, 0);
+});
+
+test("the weekly word quota on a managed Orukeet start opens the upgrade prompt", async (t) => {
+ const { createManager, window } = await loadAudioManager(t, {
+ cachePrefix: "openwhispr-streaming-routing-test-",
+ settingsKey: "__streamingRoutingSettings",
+ });
+ const manager = createManager();
+ manager.sttConfig = orukeetConfig;
+ managedSettings({ preferredLanguage: "fr" });
+ const prompts = [];
+ window.electronAPI.notifyLimitReached = (data) => prompts.push(data);
+
+ assert.throws(
+ () =>
+ manager.classifyStreamingStartResult(
+ {
+ success: false,
+ code: "LIMIT_REACHED",
+ status: 429,
+ error: "Weekly word limit reached",
+ details: { wordsUsed: 2000, limit: 2000 },
+ },
+ { useLocalWhisper: false }
+ ),
+ { code: "LIMIT_REACHED", message: "Weekly word limit reached" }
+ );
+ assert.deepEqual(prompts, [{ wordsUsed: 2000, limit: 2000 }]);
+ // A quota denial is not a fallback: batch would be refused the same way.
+ assert.ok(!manager.streamingFallbackReason);
+});
+
+test("a missing streaming API still falls back to batch for every provider", async (t) => {
+ const manager = await loadManager(t);
+ setSettings();
+ assert.deepEqual(
+ manager.classifyStreamingStartResult(
+ { success: false, code: "NO_API" },
+ { useLocalWhisper: false }
+ ),
+ { needsFallback: true }
+ );
+ assert.equal(manager.streamingFallbackReason, undefined);
+});
+
+test("the STT config goes stale after fifteen minutes and immediately when invalidated", async (t) => {
+ const manager = await loadManager(t);
+ assert.equal(manager.isSttConfigStale(), true);
+
+ manager.setSttConfig({ success: true, dictation: { mode: "batch" } });
+ const fetchedAt = manager.sttConfigFetchedAt;
+ assert.equal(manager.isSttConfigStale(fetchedAt), false);
+ assert.equal(manager.isSttConfigStale(fetchedAt + 14 * 60 * 1000), false);
+ assert.equal(manager.isSttConfigStale(fetchedAt + 15 * 60 * 1000 + 1), true);
+
+ manager.invalidateSttConfig();
+ assert.equal(manager.sttConfig, null);
+ assert.equal(manager.isSttConfigStale(fetchedAt), true);
+});
+
+test("a cloud upload reports why it was batch instead of the managed Orukeet stream", async (t) => {
+ const manager = await loadManager(t);
+ const originalNavigator = globalThis.navigator;
+ Object.defineProperty(globalThis, "navigator", {
+ value: { ...originalNavigator, onLine: true },
+ configurable: true,
+ });
+ t.after(() => {
+ Object.defineProperty(globalThis, "navigator", {
+ value: originalNavigator,
+ configurable: true,
+ });
+ });
+ manager.sttConfig = orukeetConfig;
+ const captured = [];
+ globalThis.window.electronAPI.cloudTranscribe = async (_audio, opts) => {
+ captured.push(opts.streamingFallbackReason);
+ return { success: false, error: "stop here" };
+ };
+ const upload = () =>
+ manager
+ .processWithOpenWhisprCloud(new Blob([new Uint8Array(16)], { type: "audio/webm" }))
+ .catch((error) => {
+ if (error.message !== "stop here") throw error;
+ });
+
+ // The language gate declined the stream.
+ managedSettings({ preferredLanguage: "ja" });
+ await upload();
+ // A refused session start, consumed by the one recording it describes.
+ managedSettings({ preferredLanguage: "fr" });
+ manager.streamingFallbackReason = "feature_disabled";
+ await upload();
+ await upload();
+ // The stream came up but produced no final; the stop path names that itself.
+ await manager
+ .processWithOpenWhisprCloud(new Blob([new Uint8Array(16)]), {
+ streamingFallbackReason: "stream_no_final",
+ })
+ .catch((error) => {
+ if (error.message !== "stop here") throw error;
+ });
+ // Batch by design (server config is not Orukeet) carries nothing.
+ manager.sttConfig = { dictation: { mode: "batch" }, streamingProvider: "deepgram" };
+ await upload();
+
+ assert.deepEqual(captured, [
+ "language_unsupported",
+ "feature_disabled",
+ undefined,
+ "stream_no_final",
+ undefined,
+ ]);
+});
+
+for (const { name, translationRequested, useCleanupModel, cleanupCloudMode } of [
+ {
+ name: "cloud cleanup",
+ translationRequested: false,
+ useCleanupModel: true,
+ cleanupCloudMode: "openwhispr",
+ },
+ {
+ name: "cloud translation cleanup",
+ translationRequested: true,
+ useCleanupModel: true,
+ cleanupCloudMode: "openwhispr",
+ },
+ {
+ name: "cloud translation without cleanup",
+ translationRequested: true,
+ useCleanupModel: false,
+ cleanupCloudMode: "openwhispr",
+ },
+ {
+ name: "cloud translation with BYOK cleanup",
+ translationRequested: true,
+ useCleanupModel: true,
+ cleanupCloudMode: "byok",
+ },
+]) {
+ test(`batch fallback telemetry survives ${name}`, async (t) => {
+ const { createManager, window } = await loadAudioManager(t, {
+ cachePrefix: "openwhispr-fallback-cleanup-",
+ settingsKey: "__fallbackCleanupSettings",
+ settings: {
+ cloudTranscriptionMode: "openwhispr",
+ isSignedIn: true,
+ useCleanupModel,
+ cleanupCloudMode,
+ preferredLanguage: "en",
+ translationSourceLanguage: "en",
+ translationTargetLanguage: "es",
+ customPrompts: {},
+ },
+ mockModules: {
+ "/stores/settingsStore": `
+ export const getSettings = () => globalThis.__fallbackCleanupSettings;
+ export const getEffectiveCleanupModel = () => "cleanup-model";
+ export const selectResolvedLLMConfig = () => ({ model: "cleanup-model", provider: "openwhispr" });
+ export const isCloudCleanupMode = () => globalThis.__fallbackCleanupSettings.cleanupCloudMode === "openwhispr";
+ export const isCloudDictationAgentMode = () => false;
+ export const isCloudTranslationMode = () => true;
+ `,
+ "/config/prompts": `
+ export const resolvePrompt = () => "translation prompt";
+ export const appendScreenContextSuffix = (prompt) => prompt;
+ `,
+ "/dictationAgentInference": `
+ export const resolveDictationAgentInference = () => ({ reachable: false, config: {} });
+ export const resolveDictationAgentVisionInference = () => ({ active: false, config: {} });
+ `,
+ "/dictationTranslationInference": `
+ export const resolveDictationTranslationInference = () => ({
+ reachable: true, model: "translation-model", config: { provider: "openwhispr" }
+ });
+ `,
+ },
+ });
+ const originalNavigator = globalThis.navigator;
+ Object.defineProperty(globalThis, "navigator", {
+ value: { onLine: true },
+ configurable: true,
+ });
+ t.after(() =>
+ Object.defineProperty(globalThis, "navigator", {
+ value: originalNavigator,
+ configurable: true,
+ })
+ );
+ const manager = createManager({
+ translationRequested,
+ isDictionaryEcho: () => false,
+ getWhisperPrompt: () => null,
+ finalizeChineseScript: async (text) => text,
+ processWithReasoningModel: async () => "translated transcript",
+ });
+ const uploads = [];
+ const cleanupRequests = [];
+ window.electronAPI.cloudTranscribe = async (_audio, opts) => {
+ uploads.push(opts);
+ return { success: true, text: "raw transcript", sttProvider: "groq", sttModel: "whisper" };
+ };
+ window.electronAPI.cloudReason = async (_text, opts) => {
+ cleanupRequests.push(opts);
+ return { success: true, text: "clean transcript" };
+ };
+ const combinedLog = useCleanupModel && cleanupCloudMode === "openwhispr";
+ for (const reason of [
+ "feature_disabled",
+ "rate_limited",
+ "session_unavailable",
+ "language_unsupported",
+ "stream_no_final",
+ undefined,
+ ]) {
+ const result = await manager.processWithOpenWhisprCloud(new Blob([new Uint8Array(16)]), {
+ streamingFallbackReason: reason,
+ });
+ assert.equal(
+ result.text,
+ translationRequested ? "translated transcript" : "clean transcript"
+ );
+ assert.equal(uploads.at(-1).sendLogs, combinedLog ? "false" : undefined);
+ assert.equal(uploads.at(-1).streamingFallbackReason, reason);
+ if (combinedLog) assert.equal(cleanupRequests.at(-1).streamingFallbackReason, reason);
+ }
+ assert.equal(uploads.length, 6);
+ assert.equal(cleanupRequests.length, combinedLog ? 6 : 0);
+ });
+}
diff --git a/test/helpers/cloudConfigRequest.test.js b/test/helpers/cloudConfigRequest.test.js
index 3a4f80e81..76f62e327 100644
--- a/test/helpers/cloudConfigRequest.test.js
+++ b/test/helpers/cloudConfigRequest.test.js
@@ -2,6 +2,7 @@ const test = require("node:test");
const assert = require("node:assert/strict");
const { createCloudConfigRequestHandler } = require("../../src/helpers/cloudConfigRequest");
+const { withPolicyRequestHeaders } = require("../../src/helpers/policyRequestHeaders");
test("the config handler preserves policy and upgrade response metadata", async () => {
const handler = createCloudConfigRequestHandler({
@@ -98,3 +99,29 @@ test("the note-recording-config handler returns a structured policy failure inst
assert.equal(result.status, 403);
assert.equal(result.error, "Blocked by workspace policy");
});
+
+test("every config refetch bypasses the HTTP cache and declares the client capabilities", async () => {
+ const requests = [];
+ for (const configPath of ["stt-config", "note-recording-config"]) {
+ const handler = createCloudConfigRequestHandler({
+ getApiUrl: () => "https://api.openwhispr.test",
+ getAuthHeader: async () => ({ Authorization: "Bearer token-a" }),
+ proxyFetch: async (url, options) => {
+ requests.push({ url, cache: options.cache, headers: options.headers });
+ return new Response("{}", { status: 200 });
+ },
+ withPolicyHeaders: (headers) => withPolicyRequestHeaders(headers, "1.8.1"),
+ logger: { error() {} },
+ configPath,
+ });
+ await handler({ sender: {} });
+ }
+
+ assert.deepEqual(
+ requests.map(({ url, cache, headers }) => [url, cache, headers["x-openwhispr-capabilities"]]),
+ [
+ ["https://api.openwhispr.test/api/stt-config", "no-store", "orukeet"],
+ ["https://api.openwhispr.test/api/note-recording-config", "no-store", "orukeet"],
+ ]
+ );
+});
diff --git a/test/helpers/orukeetCloudSession.test.js b/test/helpers/orukeetCloudSession.test.js
new file mode 100644
index 000000000..8ddd55d9b
--- /dev/null
+++ b/test/helpers/orukeetCloudSession.test.js
@@ -0,0 +1,213 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { once } = require("node:events");
+const { WebSocket, WebSocketServer } = require("ws");
+const { OrukeetStreaming } = require("../../src/helpers/orukeetStreaming");
+const {
+ connectManagedOrukeet,
+ ORUKEET_BASE_URL,
+ validateSession,
+} = require("../../src/helpers/orukeetCloudSession");
+const { withPolicyRequestHeaders } = require("../../src/helpers/policyRequestHeaders");
+
+const session = () => ({
+ baseUrl: ORUKEET_BASE_URL,
+ websocketUrl: "wss://orukeet.gizmovoice.ai/v1/audio/transcriptions/stream",
+ clientToken: "test.single-use.token",
+ protocol: "orukeet.pcm.v1",
+ model: "orukeet-v0.1.0",
+ singleUse: true,
+ expiresIn: 60,
+});
+
+function authStore() {
+ let state = { token: "account-a", generation: 1 };
+ const listeners = new Set();
+ return {
+ getState: () => ({ ...state }),
+ subscribe: (fn) => {
+ listeners.add(fn);
+ return () => listeners.delete(fn);
+ },
+ change(token) {
+ state = { token, generation: state.generation + 1 };
+ for (const fn of listeners) fn(state);
+ },
+ count: () => listeners.size,
+ };
+}
+
+async function fixture(t, fetchImpl) {
+ const server = new WebSocketServer({ host: "127.0.0.1", port: 0 });
+ await once(server, "listening");
+ const seen = [];
+ const sockets = [];
+ server.on("connection", (socket, req) => {
+ assert.equal(req.headers.authorization, undefined);
+ assert.equal(
+ req.headers["sec-websocket-protocol"],
+ "orukeet.pcm.v1,auth.test.single-use.token"
+ );
+ socket.send(
+ JSON.stringify({
+ type: "ready",
+ channels: 1,
+ sample_rate: 16000,
+ encoding: "pcm_s16le",
+ max_seconds: 600,
+ })
+ );
+ socket.on("message", (data, binary) => {
+ const event = binary ? Buffer.from(data) : JSON.parse(data);
+ seen.push(event);
+ if (event.type === "commit")
+ socket.send(JSON.stringify({ type: "final", text: "Full recording." }));
+ });
+ });
+ const streaming = new OrukeetStreaming({
+ timeoutMs: 500,
+ createSocket(url, options, protocols) {
+ sockets.push(url);
+ assert.equal(url, session().websocketUrl);
+ return new WebSocket(`ws://127.0.0.1:${server.address().port}`, protocols, options);
+ },
+ });
+ streaming.beginConnecting();
+ const tokenStore = authStore();
+ const options = {
+ streaming,
+ tokenStore,
+ getApiUrl: () => "https://api.openwhispr.test",
+ withPolicyHeaders: (headers) => withPolicyRequestHeaders(headers, "1.8.1"),
+ proxyFetch:
+ fetchImpl ||
+ (async (url, options) => {
+ assert.equal(url, "https://api.openwhispr.test/api/stt/orukeet/session");
+ assert.equal(options.headers.Authorization, "Bearer account-a");
+ assert.equal(options.headers["x-openwhispr-policy-version"], "1");
+ // The server mints only for builds that declare they can run Orukeet.
+ assert.equal(options.headers["x-openwhispr-capabilities"], "orukeet");
+ assert.equal(options.useSessionCookies, false);
+ assert.equal(options.redirect, "error");
+ return Response.json(session());
+ }),
+ };
+ t.after(async () => {
+ await streaming.disconnect();
+ for (const client of server.clients) client.terminate();
+ await new Promise((resolve) => server.close(resolve));
+ assert.equal(tokenStore.count(), 0);
+ });
+ return { options, streaming, seen, sockets, tokenStore };
+}
+
+test("managed auth and token handshake preserve PCM captured during session setup", async (t) => {
+ const f = await fixture(t);
+ f.streaming.sendAudio(Buffer.from([1, 0]));
+ await connectManagedOrukeet(f.options);
+ f.streaming.sendAudio(Buffer.from([2, 0]));
+ assert.equal((await f.streaming.finalize()).text, "Full recording.");
+ assert.deepEqual(f.seen, [Buffer.from([1, 0]), Buffer.from([2, 0]), { type: "commit" }]);
+});
+
+test("signed out users never request a session or open a socket", async (t) => {
+ let calls = 0;
+ const f = await fixture(t, async () => {
+ calls++;
+ });
+ f.tokenStore.change(null);
+ await assert.rejects(connectManagedOrukeet(f.options), { code: "AUTH_CONTEXT_UNVALIDATED" });
+ assert.equal(calls, 0);
+ assert.equal(f.sockets.length, 0);
+});
+
+for (const [status, code] of [
+ [401, "AUTH_EXPIRED"],
+ [403, "POLICY_RESTRICTED"],
+ [402, "LIMIT_EXCEEDED"],
+ [429, "RATE_LIMITED"],
+ [426, "UPGRADE_REQUIRED"],
+]) {
+ test(`cloud denial ${status} preserves policy metadata and never connects`, async (t) => {
+ const f = await fixture(t, async () =>
+ Response.json({ error: "Denied", code, data: { minAppVersion: "2.0.0" } }, { status })
+ );
+ await assert.rejects(connectManagedOrukeet(f.options), { code, status });
+ assert.equal(f.sockets.length, 0);
+ });
+}
+
+test("the weekly word quota surfaces as LIMIT_REACHED with its usage, not the mint cap", async (t) => {
+ const f = await fixture(t, async () =>
+ Response.json(
+ { error: "Weekly word limit reached", limitReached: true, wordsUsed: 2000, limit: 2000 },
+ { status: 429 }
+ )
+ );
+ await assert.rejects(connectManagedOrukeet(f.options), {
+ code: "LIMIT_REACHED",
+ status: 429,
+ message: "Weekly word limit reached",
+ details: { wordsUsed: 2000, limit: 2000 },
+ });
+ assert.equal(f.sockets.length, 0);
+});
+
+for (const cancellation of ["logout", "cancel"]) {
+ test(`${cancellation} while a token request is pending cannot reopen a session`, async (t) => {
+ let release;
+ const f = await fixture(
+ t,
+ () =>
+ new Promise((resolve) => {
+ release = resolve;
+ })
+ );
+ const pending = connectManagedOrukeet(f.options);
+ const rejected = assert.rejects(pending, /context changed|cancelled/i);
+ if (cancellation === "logout") f.tokenStore.change(null);
+ else await f.streaming.disconnect();
+ release(Response.json(session()));
+ await rejected;
+ assert.equal(f.sockets.length, 0);
+ });
+}
+
+test("account switch closes an established managed socket without commit", async (t) => {
+ const f = await fixture(t);
+ await connectManagedOrukeet(f.options);
+ f.streaming.sendAudio(Buffer.alloc(640));
+ f.tokenStore.change("account-b");
+ await assert.rejects(f.streaming.finalize(), { code: "AUTH_CONTEXT_CHANGED" });
+ assert.equal(f.streaming.isConnected, false);
+ assert.equal(
+ f.seen.some((v) => v.type === "commit"),
+ false
+ );
+});
+
+test("session schema pins destination and rejects malformed or reusable credentials", () => {
+ for (const update of [
+ { baseUrl: "https://attacker.test" },
+ { websocketUrl: "wss://attacker.test" },
+ { clientToken: "token with spaces" },
+ { singleUse: false },
+ { expiresIn: 3600 },
+ { protocol: "other" },
+ { model: "other" },
+ { clientToken: null },
+ ])
+ assert.throws(() => validateSession({ ...session(), ...update }), /Invalid/);
+ assert.deepEqual(validateSession(session()), {
+ baseUrl: ORUKEET_BASE_URL,
+ clientToken: session().clientToken,
+ });
+});
+
+test("invalid backend destination is rejected before any WebSocket is constructed", async (t) => {
+ const f = await fixture(t, async () =>
+ Response.json({ ...session(), baseUrl: "https://attacker.test" })
+ );
+ await assert.rejects(connectManagedOrukeet(f.options), /Invalid Orukeet cloud session/);
+ assert.equal(f.sockets.length, 0);
+});
diff --git a/test/helpers/orukeetDictationIpc.test.js b/test/helpers/orukeetDictationIpc.test.js
new file mode 100644
index 000000000..c798439f1
--- /dev/null
+++ b/test/helpers/orukeetDictationIpc.test.js
@@ -0,0 +1,343 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const fs = require("node:fs");
+const os = require("node:os");
+const path = require("node:path");
+const Module = require("node:module");
+
+const handlersModulePath = require.resolve("../../src/helpers/ipcHandlers");
+const originalLoad = Module._load;
+
+// Runs the registered Electron handlers with a real local WebSocket server.
+// Only Electron, account state and the remote authorization response are stubbed.
+const handlers = new Map();
+const broadcasts = [];
+const userDataDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "orukeet-dictation-ipc-"));
+let tokenState = { token: "account-a", generation: 1 };
+const tokenListeners = new Set();
+let backendResponse = async () => Response.json(cloudSession);
+const cloudSession = {
+ baseUrl: "https://orukeet.gizmovoice.ai",
+ websocketUrl: "wss://orukeet.gizmovoice.ai/v1/audio/transcriptions/stream",
+ clientToken: "test.token.signature",
+ protocol: "orukeet.pcm.v1",
+ model: "orukeet-v0.1.0",
+ expiresIn: 60,
+ singleUse: true,
+};
+const { once, EventEmitter } = require("node:events");
+const { WebSocket, WebSocketServer } = require("ws");
+const { OrukeetStreaming } = require("../../src/helpers/orukeetStreaming");
+let server,
+ target,
+ opened = 0;
+const messages = [];
+const event = { sender: new EventEmitter() };
+event.sender.send = (channel, text) => messages.push([channel, text]);
+const managedOptions = {
+ provider: "orukeet",
+ mode: "openwhispr",
+ model: "orukeet-v0.1.0",
+ baseUrl: "https://untrusted-renderer.test",
+};
+
+const electronStub = {
+ app: {
+ getPath: () => userDataDirectory,
+ getName: () => "test",
+ getVersion: () => "0.0.0",
+ isPackaged: false,
+ on: () => {},
+ requestSingleInstanceLock: () => true,
+ },
+ ipcMain: {
+ handle: (channel, fn) => handlers.set(channel, fn),
+ on: (channel, fn) => handlers.set(channel, fn),
+ removeHandler: () => {},
+ },
+ net: {
+ fetch: async (url, options) => {
+ assert.ok(
+ [
+ "https://api.openwhispr.test/api/stt/orukeet/session",
+ "https://api.openwhispr.test/api/reason",
+ ].includes(url)
+ );
+ assert.equal(options.headers.Authorization, "Bearer account-a");
+ return backendResponse(url, options);
+ },
+ },
+ BrowserWindow: class BrowserWindow {
+ static getAllWindows() {
+ return [];
+ }
+ static fromWebContents() {
+ return null;
+ }
+ },
+ shell: {},
+ dialog: {},
+ screen: { getPrimaryDisplay: () => ({ workAreaSize: { width: 0, height: 0 } }) },
+ systemPreferences: { getMediaAccessStatus: () => "granted" },
+ session: { fromPartition: () => ({}) },
+ clipboard: {},
+ nativeImage: {},
+ globalShortcut: {},
+ utilityProcess: {},
+ MessageChannelMain: class {},
+};
+
+Module._load = function loadWithMocks(request, parent, isMain) {
+ if (request === "electron") return electronStub;
+ if (parent?.filename === handlersModulePath) {
+ if (request === "./orukeetStreaming")
+ return {
+ OrukeetStreaming: class extends OrukeetStreaming {
+ constructor() {
+ super({
+ createSocket: (url, options, protocols) => {
+ assert.equal(url, cloudSession.websocketUrl);
+ assert.equal(options.headers.Authorization, undefined);
+ opened++;
+ return new WebSocket(`ws://127.0.0.1:${server.address().port}`, protocols, options);
+ },
+ });
+ }
+ },
+ };
+ if (request === "./tokenStore") {
+ return {
+ get: () => tokenState.token,
+ getState: () => ({ ...tokenState }),
+ subscribe: (fn) => {
+ tokenListeners.add(fn);
+ return () => tokenListeners.delete(fn);
+ },
+ };
+ }
+ if (request === "./windowBroadcast") {
+ return { broadcastToWindows: (channel, data) => broadcasts.push([channel, data]) };
+ }
+ }
+ return originalLoad.call(this, request, parent, isMain);
+};
+
+function anything() {
+ return new Proxy(function () {}, {
+ get: (target, property) => {
+ if (property === Symbol.toPrimitive || property === "toString") return () => "";
+ if (property === "then") return undefined;
+ return anything();
+ },
+ apply: () => anything(),
+ });
+}
+
+function buildFakeThis() {
+ const target = {
+ sessionId: "test-session",
+ _dictationStreaming: null,
+ _dictationConnectPromise: null,
+ _dictationIdleTimer: null,
+ };
+ return new Proxy(target, {
+ get: (value, property) => (property in value ? value[property] : anything()),
+ });
+}
+
+test.before(async () => {
+ process.env.OPENWHISPR_API_URL = "https://api.openwhispr.test";
+ server = new WebSocketServer({ host: "127.0.0.1", port: 0 });
+ await once(server, "listening");
+ server.on("connection", (socket) => {
+ socket.send(
+ JSON.stringify({
+ type: "ready",
+ channels: 1,
+ sample_rate: 16000,
+ encoding: "pcm_s16le",
+ max_seconds: 600,
+ })
+ );
+ let bytes = 0;
+ socket.on("message", (data, binary) => {
+ if (binary) bytes += data.length;
+ else if (JSON.parse(data).type === "commit") {
+ socket.send(
+ JSON.stringify({ type: "language", language: "en", language_confidence: 0.99 })
+ );
+ socket.send(
+ JSON.stringify({
+ type: "final",
+ text: `Recorded ${bytes} bytes`,
+ model: "orukeet-v0.1.0",
+ language: "en",
+ language_confidence: 0.99,
+ language_audio_seconds: 6,
+ })
+ );
+ }
+ });
+ });
+ delete require.cache[handlersModulePath];
+ const IPCHandlers = require(handlersModulePath);
+ const Ctor = IPCHandlers.default || IPCHandlers;
+ target = buildFakeThis();
+ Ctor.prototype.setupHandlers.call(target);
+});
+
+test.after(async () => {
+ await handlers.get("dictation-realtime-stop")();
+ for (const client of server.clients) client.terminate();
+ await new Promise((resolve) => server.close(resolve));
+ Module._load = originalLoad;
+ fs.rmSync(userDataDirectory, { recursive: true, force: true });
+});
+
+test("registered managed IPC streams startup audio and returns exactly one complete final", async () => {
+ const start = handlers.get("dictation-realtime-start")(event, managedOptions);
+ handlers.get("dictation-realtime-send")(event, Buffer.alloc(640));
+ assert.equal((await start).success, true);
+ handlers.get("dictation-realtime-send")(event, Buffer.alloc(640));
+ const final = await handlers.get("dictation-realtime-finalize")();
+ assert.equal(final.success, true);
+ assert.equal(final.text, "Recorded 1280 bytes");
+ assert.equal(final.language, "en");
+ assert.equal(final.languageConfidence, 0.99);
+ assert.equal(final.languageAudioSeconds, 6);
+ assert.deepEqual(messages.find(([channel]) => channel === "dictation-realtime-language")?.[1], {
+ language: "en",
+ languageConfidence: 0.99,
+ });
+ assert.equal(messages.filter(([channel]) => channel === "dictation-realtime-final").length, 1);
+ assert.equal((await handlers.get("dictation-realtime-stop")()).text, final.text);
+ assert.equal(tokenListeners.size, 0);
+});
+
+test("stop during token fetch cancels the real main-process connection", async () => {
+ let resolve;
+ backendResponse = () =>
+ new Promise((r) => {
+ resolve = r;
+ });
+ const before = opened;
+ const start = handlers.get("dictation-realtime-start")(event, managedOptions);
+ await handlers.get("dictation-realtime-stop")();
+ resolve(Response.json(cloudSession));
+ assert.equal((await start).success, false);
+ assert.equal(opened, before);
+ assert.equal(target._dictationStreaming, null);
+});
+
+test("main-process quota denial retains metadata and opens no socket", async () => {
+ backendResponse = async () =>
+ Response.json({ error: "Allowance exhausted", code: "LIMIT_EXCEEDED" }, { status: 402 });
+ const before = opened;
+ const result = await handlers.get("dictation-realtime-start")(event, managedOptions);
+ assert.equal(result.code, "LIMIT_EXCEEDED");
+ assert.equal(result.status, 402);
+ assert.equal(opened, before);
+});
+
+test("closing the owning window releases the managed socket and auth subscription", async () => {
+ backendResponse = async () => Response.json(cloudSession);
+ await handlers.get("dictation-realtime-start")(event, managedOptions);
+ const streaming = target._dictationStreaming;
+ event.sender.emit("destroyed");
+ assert.equal(streaming.isConnected, false);
+ assert.equal(target._dictationStreaming, null);
+ assert.equal(tokenListeners.size, 0);
+ assert.equal(event.sender.listenerCount("destroyed"), 0);
+});
+
+test("cloud cleanup forwards fallback telemetry to its combined log request", async () => {
+ const requests = [];
+ backendResponse = async (url, options) => {
+ assert.equal(url, "https://api.openwhispr.test/api/reason");
+ requests.push(JSON.parse(options.body));
+ return Response.json({ text: "clean transcript" });
+ };
+ for (const reason of ["rate_limited", undefined]) {
+ const result = await handlers.get("cloud-reason")(event, "raw transcript", {
+ purpose: "cleanup",
+ sttProvider: "groq",
+ streamingFallbackReason: reason,
+ });
+ assert.equal(result.success, true);
+ assert.equal(requests.at(-1).streamingFallbackReason, reason);
+ assert.equal(requests.at(-1).sttProvider, "groq");
+ }
+ assert.equal(requests.length, 2);
+ assert.equal(Object.hasOwn(requests[1], "streamingFallbackReason"), false);
+});
+
+test("warmups landing together mint one session and share its unused socket", async () => {
+ await handlers.get("dictation-realtime-stop")();
+ let mints = 0;
+ backendResponse = async () => {
+ mints += 1;
+ return Response.json(cloudSession);
+ };
+ const socketsBefore = opened;
+
+ // Both post-dictation re-warm paths fire at once.
+ const [first, second] = await Promise.all([
+ handlers.get("dictation-realtime-warmup")(event, managedOptions),
+ handlers.get("dictation-realtime-warmup")(event, managedOptions),
+ ]);
+ assert.equal(first.success, true);
+ assert.deepEqual(second, { success: true, alreadyWarm: true });
+ assert.equal(mints, 1);
+ assert.equal(opened, socketsBefore + 1);
+
+ // The dictation itself rides the warm socket.
+ assert.equal(
+ (await handlers.get("dictation-realtime-start")(event, managedOptions)).success,
+ true
+ );
+ assert.equal(mints, 1);
+ handlers.get("dictation-realtime-send")(event, Buffer.alloc(640));
+ assert.equal((await handlers.get("dictation-realtime-finalize")()).success, true);
+ await handlers.get("dictation-realtime-stop")();
+});
+
+test("a warmup never reuses a socket that has already carried audio", async () => {
+ await handlers.get("dictation-realtime-stop")();
+ let mints = 0;
+ backendResponse = async () => {
+ mints += 1;
+ return Response.json(cloudSession);
+ };
+
+ await handlers.get("dictation-realtime-start")(event, managedOptions);
+ handlers.get("dictation-realtime-send")(event, Buffer.alloc(640));
+ const used = target._dictationStreaming;
+ const warmup = await handlers.get("dictation-realtime-warmup")(event, managedOptions);
+
+ assert.equal(warmup.success, true);
+ assert.equal(warmup.alreadyWarm, undefined);
+ assert.equal(mints, 2);
+ assert.notEqual(target._dictationStreaming, used);
+ await handlers.get("dictation-realtime-stop")();
+});
+
+test("an idle Orukeet warm socket closes after 60 seconds and start cancels expiry", async () => {
+ await handlers.get("dictation-realtime-stop")();
+ backendResponse = async () => Response.json(cloudSession);
+ await handlers.get("dictation-realtime-warmup")(event, managedOptions);
+ const first = target._dictationStreaming;
+ assert.equal(target._dictationIdleTimer._idleTimeout, 60000);
+
+ // Exercise the registered expiry callback without advancing WebSocket timers.
+ const expire = target._dictationIdleTimer._onTimeout;
+ clearTimeout(target._dictationIdleTimer);
+ expire();
+ assert.equal(first.isConnected, false);
+ assert.equal(target._dictationStreaming, null);
+ await handlers.get("dictation-realtime-warmup")(event, managedOptions);
+ assert.ok(target._dictationIdleTimer);
+ await handlers.get("dictation-realtime-start")(event, managedOptions);
+ assert.equal(target._dictationIdleTimer, null);
+ assert.equal(target._dictationStreaming.isConnected, true);
+ await handlers.get("dictation-realtime-stop")();
+});
diff --git a/test/helpers/orukeetManagedRouting.test.js b/test/helpers/orukeetManagedRouting.test.js
new file mode 100644
index 000000000..012234652
--- /dev/null
+++ b/test/helpers/orukeetManagedRouting.test.js
@@ -0,0 +1,104 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const registry = require("../../src/models/modelRegistryData.json");
+
+// The managed Orukeet route has no language on the wire and the model covers
+// a fixed list; every other language must stay on the batch path, which
+// honors the user's language end to end.
+const loadRouting = () => import("../../src/helpers/dictationStreamingRouting.js");
+
+const managedSettings = {
+ cloudTranscriptionMode: "openwhispr",
+ cloudTranscriptionProvider: "openai",
+ cloudTranscriptionModel: "gpt-4o-mini-transcribe",
+};
+const orukeetConfig = { dictation: { mode: "streaming" }, streamingProvider: "orukeet" };
+const supportedLanguages = registry.parakeetModels["orukeet-v0.1.0"].supportedLanguages;
+
+test("managed Orukeet streams every language in the model's registry list", async () => {
+ const { resolveManagedOrukeetRoute, resolveStreamingProviderName } = await loadRouting();
+ for (const language of supportedLanguages) {
+ const input = { settings: managedSettings, sttConfig: orukeetConfig, language };
+ assert.equal(resolveManagedOrukeetRoute(input), "orukeet", language);
+ assert.equal(
+ resolveStreamingProviderName({ ...input, context: "dictation" }),
+ "orukeet",
+ language
+ );
+ }
+});
+
+test("a regional tag routes on its base language", async () => {
+ const { resolveManagedOrukeetRoute } = await loadRouting();
+ assert.equal(
+ resolveManagedOrukeetRoute({
+ settings: managedSettings,
+ sttConfig: orukeetConfig,
+ language: "pt-BR",
+ }),
+ "orukeet"
+ );
+});
+
+test("a language outside the model's list stays on the batch path", async () => {
+ const { resolveManagedOrukeetRoute, resolveStreamingProviderName } = await loadRouting();
+ for (const language of ["ja", "zh-CN", "ko", "ar", "hi", "tr"]) {
+ const input = { settings: managedSettings, sttConfig: orukeetConfig, language };
+ assert.equal(resolveManagedOrukeetRoute(input), "language_unsupported", language);
+ assert.equal(
+ resolveStreamingProviderName({ ...input, context: "dictation" }),
+ "openai-realtime",
+ language
+ );
+ }
+});
+
+test("automatic language detection is left to the model, like every other streaming provider", async () => {
+ const { resolveManagedOrukeetRoute } = await loadRouting();
+ for (const language of ["auto", undefined, ""]) {
+ assert.equal(
+ resolveManagedOrukeetRoute({ settings: managedSettings, sttConfig: orukeetConfig, language }),
+ "orukeet",
+ String(language)
+ );
+ }
+});
+
+test("the route is absent when the server has not enabled Orukeet", async () => {
+ const { resolveManagedOrukeetRoute } = await loadRouting();
+ const cases = [
+ { sttConfig: { dictation: { mode: "batch" }, streamingProvider: "orukeet" } },
+ { sttConfig: { dictation: { mode: "streaming" }, streamingProvider: "deepgram" } },
+ { sttConfig: null },
+ { settings: { ...managedSettings, cloudTranscriptionMode: "byok" }, sttConfig: orukeetConfig },
+ ];
+ for (const overrides of cases) {
+ assert.equal(
+ resolveManagedOrukeetRoute({
+ settings: managedSettings,
+ sttConfig: orukeetConfig,
+ language: "fr",
+ ...overrides,
+ }),
+ null
+ );
+ }
+});
+
+test("a BYOK custom Orukeet endpoint is not language gated", async () => {
+ const { resolveStreamingProviderName } = await loadRouting();
+ assert.equal(
+ resolveStreamingProviderName({
+ settings: {
+ cloudTranscriptionMode: "byok",
+ cloudTranscriptionProvider: "custom",
+ cloudTranscriptionModel: "orukeet-v0.1.0",
+ cloudTranscriptionBaseUrl: "https://orukeet.example.test",
+ },
+ context: "dictation",
+ sttConfig: null,
+ language: "ja",
+ }),
+ "orukeet"
+ );
+});
diff --git a/test/helpers/orukeetSessionIssuer.test.js b/test/helpers/orukeetSessionIssuer.test.js
new file mode 100644
index 000000000..8d0416ab8
--- /dev/null
+++ b/test/helpers/orukeetSessionIssuer.test.js
@@ -0,0 +1,110 @@
+const { test } = require("node:test");
+const assert = require("node:assert/strict");
+const { issueSession, BASE_URL } = require("../../docs/integrations/orukeet/issue-session.cjs");
+const token = "us-west1.test-one-use-token.signature";
+const payload = { token, expires_in: 60, single_use: true, protocol: "orukeet.pcm.v1" };
+
+test("backend uses fixed TLS destination and returns only desktop-safe fields", async () => {
+ const session = await issueSession({
+ serviceKey: "test-service-key",
+ fetchImpl: async (url, options) => {
+ assert.equal(url, BASE_URL + "/v1/client-token");
+ assert.equal(options.headers.Authorization, "Bearer test-service-key");
+ assert.equal(options.method, "POST");
+ assert.equal(options.redirect, "error");
+ assert.equal(options.cache, "no-store");
+ return { ok: true, json: async () => ({ ...payload, extra: "private" }) };
+ },
+ });
+ assert.equal(session.clientToken, token);
+ assert.equal(session.singleUse, true);
+ assert.ok(!JSON.stringify(session).includes("test-service-key"));
+ assert.ok(!("extra" in session));
+});
+
+test("missing backend credential fails before any network call", async () => {
+ await assert.rejects(
+ issueSession({ fetchImpl: () => assert.fail("network called") }),
+ /required/
+ );
+});
+
+test("backend binds an opaque account and requires gateway acknowledgement", async () => {
+ const session = await issueSession({
+ serviceKey: "private",
+ accountId: "opaque-user-1234",
+ fetchImpl: async (_url, options) => {
+ assert.deepEqual(JSON.parse(options.body), {
+ account_id: "opaque-user-1234",
+ socket_role: "warm",
+ });
+ return { ok: true, json: async () => ({ ...payload, account_limits: true }) };
+ },
+ });
+ assert.ok(!JSON.stringify(session).includes("opaque-user-1234"));
+ await assert.rejects(
+ issueSession({
+ serviceKey: "private",
+ accountId: "opaque-user-1234",
+ fetchImpl: async () => ({ ok: true, json: async () => payload }),
+ }),
+ /Invalid Orukeet session response/
+ );
+});
+
+test("invalid account claims fail before network access", async () => {
+ for (const accountId of ["[email protected]", "short", null, 123]) {
+ await assert.rejects(
+ issueSession({
+ serviceKey: "private",
+ accountId,
+ fetchImpl: () => assert.fail("network called"),
+ }),
+ /accountId must/
+ );
+ }
+});
+
+test("upstream errors do not disclose credentials or response bodies", async () => {
+ await assert.rejects(
+ issueSession({
+ serviceKey: "private",
+ fetchImpl: async () => {
+ throw new Error("private request");
+ },
+ }),
+ /^Error: Orukeet session service is unavailable$/
+ );
+ await assert.rejects(
+ issueSession({
+ serviceKey: "private",
+ fetchImpl: async () => ({
+ ok: false,
+ status: 429,
+ json: () => assert.fail("should not read body"),
+ }),
+ }),
+ /HTTP 429/
+ );
+});
+
+for (const invalid of [
+ null,
+ { ...payload, token: "bad,token" },
+ { ...payload, single_use: false },
+ { ...payload, expires_in: 0 },
+ { ...payload, protocol: "other" },
+]) {
+ test(`reject invalid session contract ${JSON.stringify(invalid)}`, async () => {
+ await assert.rejects(
+ issueSession({
+ serviceKey: "private",
+ fetchImpl: async () => ({
+ ok: true,
+ json: async () => invalid,
+ }),
+ }),
+ /Invalid Orukeet session response/
+ );
+ });
+}
diff --git a/test/helpers/orukeetStreaming.test.js b/test/helpers/orukeetStreaming.test.js
new file mode 100644
index 000000000..1086d8a35
--- /dev/null
+++ b/test/helpers/orukeetStreaming.test.js
@@ -0,0 +1,236 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const { once } = require("node:events");
+const { WebSocketServer } = require("ws");
+const { OrukeetStreaming, streamingUrl } = require("../../src/helpers/orukeetStreaming");
+
+async function fixture(t, onMessage) {
+ const server = new WebSocketServer({ port: 0, host: "127.0.0.1" });
+ await once(server, "listening");
+ const seen = [];
+ server.on("connection", (socket, request) => {
+ assert.equal(request.headers.authorization, "Bearer test-key");
+ assert.equal(request.url, "/v1/audio/transcriptions/stream");
+ socket.send(
+ JSON.stringify({
+ type: "ready",
+ sample_rate: 16000,
+ channels: 1,
+ encoding: "pcm_s16le",
+ max_seconds: 60,
+ })
+ );
+ socket.on("message", (data, binary) => {
+ const event = binary ? Buffer.from(data) : JSON.parse(data.toString());
+ seen.push(event);
+ onMessage?.(socket, event, seen);
+ });
+ });
+ const adapter = new OrukeetStreaming({ timeoutMs: 300 });
+ t.after(async () => {
+ await adapter.disconnect();
+ for (const socket of server.clients) socket.terminate();
+ await new Promise((resolve) => server.close(resolve));
+ });
+ return {
+ adapter,
+ seen,
+ options: { baseUrl: `http://127.0.0.1:${server.address().port}/v1`, apiKey: "test-key" },
+ };
+}
+
+test("PCM including pre-connect audio precedes commit, and finalization waits for final", async (t) => {
+ const { adapter, seen, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit")
+ setTimeout(
+ () =>
+ socket.send(
+ JSON.stringify({
+ type: "final",
+ text: "Full recording.",
+ inference_ms: 12,
+ server_ms: 14,
+ })
+ ),
+ 10
+ );
+ });
+ adapter.beginConnecting();
+ adapter.sendAudio(Buffer.from([1, 0]));
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.from([2, 0]));
+ const pending = adapter.finalize();
+ assert.equal(adapter.finalize(), pending);
+ const result = await pending;
+ assert.equal(result.text, "Full recording.");
+ assert.equal(result.audioBytesSent, 4);
+ assert.equal(result.inferenceMs, 12);
+ assert.deepEqual(seen, [Buffer.from([1, 0]), Buffer.from([2, 0]), { type: "commit" }]);
+});
+
+test("capacity retry commits retained audio without uploading it twice", async (t) => {
+ let commits = 0;
+ const { adapter, seen, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit")
+ socket.send(
+ JSON.stringify(
+ ++commits === 1
+ ? { type: "error", code: "capacity", retry_after_ms: 20 }
+ : { type: "final", text: "Retried." }
+ )
+ );
+ });
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ assert.equal((await adapter.finalize()).text, "Retried.");
+ assert.equal(seen.filter(Buffer.isBuffer).length, 1);
+ assert.equal(commits, 2);
+});
+
+test("language hints are advisory and the final language is passed through", async (t) => {
+ const { adapter, options } = await fixture(t, (socket, event) => {
+ if (Buffer.isBuffer(event)) {
+ socket.send(JSON.stringify({ type: "language", language: "ar", language_confidence: 0.8 }));
+ } else if (event.type === "commit") {
+ socket.send(
+ JSON.stringify({
+ type: "final",
+ text: "Transcript",
+ language: "hi",
+ language_confidence: 0.97,
+ language_audio_seconds: 6,
+ })
+ );
+ }
+ });
+ const hints = [];
+ let finals = 0;
+ adapter.onLanguage = (value) => hints.push(value);
+ adapter.onFinalTranscript = () => finals++;
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ const result = await adapter.finalize();
+ assert.deepEqual(hints, [{ language: "ar", languageConfidence: 0.8 }]);
+ assert.equal(result.language, "hi");
+ assert.equal(result.languageConfidence, 0.97);
+ assert.equal(result.languageAudioSeconds, 6);
+ assert.equal(finals, 1);
+});
+
+for (const metadata of [
+ { language: null, language_confidence: null },
+ { language: "english", language_confidence: 0.9 },
+ { language: "en", language_confidence: "0.9" },
+ { language: "en", language_confidence: 1.1 },
+ { language: "en", language_confidence: -0.1 },
+]) {
+ test(`invalid or unknown language does not fail transcription: ${JSON.stringify(metadata)}`, async (t) => {
+ const { adapter, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit") {
+ socket.send(JSON.stringify({ type: "language", ...metadata }));
+ socket.send(JSON.stringify({ type: "final", text: "Still works", ...metadata }));
+ }
+ });
+ adapter.onLanguage = () => assert.fail("Invalid hint must not reach consumers");
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ const result = await adapter.finalize();
+ assert.equal(result.text, "Still works");
+ assert.equal(result.language, null);
+ assert.equal(result.languageConfidence, null);
+ });
+}
+
+test("cancellation closes without committing audio", async (t) => {
+ const { adapter, seen, options } = await fixture(t);
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ await adapter.disconnect();
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ assert.equal(
+ seen.some((event) => event.type === "commit"),
+ false
+ );
+});
+
+test("server errors reject finalization instead of returning partial success", async (t) => {
+ const { adapter, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit")
+ socket.send(JSON.stringify({ type: "error", code: "unavailable" }));
+ });
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ await assert.rejects(adapter.finalize(), /unavailable/);
+});
+
+test("missing final acknowledgement has a bounded timeout", async (t) => {
+ const { adapter, options } = await fixture(t);
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ await assert.rejects(adapter.finalize(), /timed out/);
+});
+
+test("URL normalization retains the selected server and refuses unsafe credential URLs", () => {
+ assert.equal(
+ streamingUrl("https://example.com/v1/audio/transcriptions"),
+ "wss://example.com/v1/audio/transcriptions/stream"
+ );
+ assert.equal(
+ streamingUrl("https://example.com/asr/v1/"),
+ "wss://example.com/asr/v1/audio/transcriptions/stream"
+ );
+ for (const url of [
+ "http://example.com",
+ "https://[email protected]",
+ "https://example.com?key=secret",
+ ]) {
+ assert.throws(() => streamingUrl(url));
+ }
+});
+
+test("duplicate finals are delivered exactly once", async (t) => {
+ const { adapter, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit") {
+ socket.send(JSON.stringify({ type: "final", text: "Once." }));
+ socket.send(JSON.stringify({ type: "final", text: "Once." }));
+ }
+ });
+ let finals = 0;
+ adapter.onFinalTranscript = () => finals++;
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ await adapter.finalize();
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ assert.equal(finals, 1);
+});
+
+test("cancelled adapters cannot reconnect", async (t) => {
+ const { adapter, options } = await fixture(t);
+ adapter.beginConnecting();
+ await adapter.disconnect();
+ await assert.rejects(adapter.connect(options), /new Orukeet adapter/);
+});
+
+test("early finalization cannot discard queued startup audio", async (t) => {
+ const { adapter } = await fixture(t);
+ adapter.beginConnecting();
+ adapter.sendAudio(Buffer.alloc(640));
+ await assert.rejects(adapter.finalize(), /not ready/);
+ assert.equal(adapter.pendingBytes, 640);
+});
+
+test("oversized capacity backoff cannot overflow the timer into a retry loop", async (t) => {
+ let commits = 0;
+ const { adapter, options } = await fixture(t, (socket, event) => {
+ if (event.type === "commit") {
+ commits++;
+ socket.send(
+ JSON.stringify({ type: "error", code: "capacity", retry_after_ms: Number.MAX_SAFE_INTEGER })
+ );
+ }
+ });
+ await adapter.connect(options);
+ adapter.sendAudio(Buffer.alloc(640));
+ await assert.rejects(adapter.finalize(), /timed out/);
+ assert.equal(commits, 1);
+});
diff --git a/test/helpers/policyRequestHeaders.test.js b/test/helpers/policyRequestHeaders.test.js
index c5472d218..14068cd2b 100644
--- a/test/helpers/policyRequestHeaders.test.js
+++ b/test/helpers/policyRequestHeaders.test.js
@@ -2,16 +2,19 @@ const test = require("node:test");
const assert = require("node:assert/strict");
const {
+ CLIENT_CAPABILITIES,
POLICY_CAPABILITY_VERSION,
withPolicyRequestHeaders,
} = require("../../src/helpers/policyRequestHeaders");
-test("adds the exact policy capability and canonical app version headers", () => {
+test("adds the exact policy capability, canonical app version and client capability headers", () => {
assert.equal(POLICY_CAPABILITY_VERSION, "1");
+ assert.equal(CLIENT_CAPABILITIES, "orukeet");
assert.deepEqual(withPolicyRequestHeaders({ Authorization: "Bearer token" }, "1.8.1"), {
Authorization: "Bearer token",
"x-openwhispr-policy-version": "1",
"x-openwhispr-version": "1.8.1",
+ "x-openwhispr-capabilities": "orukeet",
});
});
@@ -21,12 +24,14 @@ test("does not allow callers to override desktop policy capability headers", ()
{
"x-openwhispr-policy-version": "2",
"x-openwhispr-version": "0.0.1",
+ "x-openwhispr-capabilities": "",
},
"1.8.1"
),
{
"x-openwhispr-policy-version": "1",
"x-openwhispr-version": "1.8.1",
+ "x-openwhispr-capabilities": "orukeet",
}
);
});
diff --git a/test/helpers/transcriptionAuth.test.js b/test/helpers/transcriptionAuth.test.js
index cd0d18bcd..5f558e4f8 100644
--- a/test/helpers/transcriptionAuth.test.js
+++ b/test/helpers/transcriptionAuth.test.js
@@ -61,3 +61,16 @@ test("returns false for non-self-hosted mode even with URL configured", async ()
false
);
});
+
+test("custom Orukeet keeps its API key in the self-hosted fallback", async () => {
+ const { shouldSkipTranscriptionApiKey } = await import("../../src/helpers/transcriptionAuth.js");
+ assert.equal(
+ shouldSkipTranscriptionApiKey({
+ transcriptionMode: "self-hosted",
+ remoteTranscriptionUrl: "https://orukeet.gizmovoice.ai/v1",
+ remoteTranscriptionModel: "orukeet-v0.1.0",
+ cloudTranscriptionProvider: "custom",
+ }),
+ false
+ );
+});
diff --git a/test/helpers/transcriptionFallback.test.js b/test/helpers/transcriptionFallback.test.js
index 7b1014105..3b4e2c7dd 100644
--- a/test/helpers/transcriptionFallback.test.js
+++ b/test/helpers/transcriptionFallback.test.js
@@ -38,3 +38,91 @@ test("BYOK mode falls back to the user's own provider", async () => {
"byok"
);
});
+
+// A managed Orukeet session that the backend cannot or will not issue must
+// start a batch recording instead of failing the dictation; denials the user
+// has to act on keep surfacing.
+const orukeetStart = (result) =>
+ import("../../src/helpers/transcriptionFallback.js").then(({ resolveStreamingStartFallback }) =>
+ resolveStreamingStartFallback({
+ providerName: "orukeet",
+ cloudTranscriptionMode: "openwhispr",
+ result,
+ })
+ );
+
+test("a disabled Orukeet rollout falls back to batch as feature_disabled", async () => {
+ assert.equal(
+ await orukeetStart({ success: false, code: "FEATURE_NOT_ENABLED", status: 403 }),
+ "feature_disabled"
+ );
+});
+
+test("an exhausted session mint window falls back to batch as rate_limited", async () => {
+ assert.equal(
+ await orukeetStart({ success: false, code: "RATE_LIMITED", status: 429 }),
+ "rate_limited"
+ );
+});
+
+test("an unavailable session service falls back to batch as session_unavailable", async () => {
+ for (const status of [500, 502, 503, 504]) {
+ assert.equal(await orukeetStart({ success: false, status }), "session_unavailable", status);
+ }
+});
+
+test("a start that fails without a denial to act on falls back instead of losing the dictation", async () => {
+ const failures = [
+ // Network error or the 10 s session request timeout.
+ { success: false, code: "NETWORK_ERROR" },
+ { success: false, error: "The operation was aborted due to timeout" },
+ // WebSocket handshake failure or a rejected session body.
+ { success: false, error: "Orukeet connection closed before completion" },
+ { success: false, error: "Invalid Orukeet cloud session" },
+ // A cookie-only session with no bearer for the managed route.
+ { success: false, code: "AUTH_CONTEXT_UNVALIDATED", status: 0 },
+ { success: false, status: 429 },
+ { success: false },
+ ];
+ for (const result of failures) {
+ assert.equal(await orukeetStart(result), "session_unavailable", JSON.stringify(result));
+ }
+});
+
+test("denials the user must act on do not fall back", async () => {
+ const denials = [
+ { success: false, code: "AUTH_EXPIRED", status: 401 },
+ { success: false, code: "AUTH_REQUIRED" },
+ { success: false, code: "AUTH_CONTEXT_CHANGED", status: 0 },
+ { success: false, code: "POLICY_MODE_BLOCKED", status: 403 },
+ { success: false, code: "POLICY_UNRESOLVABLE", status: 403 },
+ { success: false, code: "ACCOUNT_REQUIRED", status: 403 },
+ { success: false, code: "UPGRADE_REQUIRED", status: 426, minAppVersion: "2.0.0" },
+ { success: false, code: "LIMIT_REACHED", status: 429 },
+ ];
+ for (const result of denials) {
+ assert.equal(await orukeetStart(result), null, JSON.stringify(result));
+ }
+});
+
+test("only the managed Orukeet route falls back on session failures", async () => {
+ const { resolveStreamingStartFallback } =
+ await import("../../src/helpers/transcriptionFallback.js");
+ const result = { success: false, status: 503 };
+ assert.equal(
+ resolveStreamingStartFallback({
+ providerName: "orukeet",
+ cloudTranscriptionMode: "byok",
+ result,
+ }),
+ null
+ );
+ assert.equal(
+ resolveStreamingStartFallback({
+ providerName: "deepgram",
+ cloudTranscriptionMode: "openwhispr",
+ result,
+ }),
+ null
+ );
+});
diff --git a/test/helpers/transcriptionRoute.test.js b/test/helpers/transcriptionRoute.test.js
index 3d0b92027..a83bf75c2 100644
--- a/test/helpers/transcriptionRoute.test.js
+++ b/test/helpers/transcriptionRoute.test.js
@@ -445,3 +445,14 @@ test("an enterprise transcription mode WITH a managed resolution takes the manag
assert.equal(route.provider, "azure");
assert.equal(route.deployment, "gpt-4o-transcribe");
});
+
+test("Orukeet fallback preserves the custom Bearer key", async () => {
+ const route = await resolve({
+ transcriptionMode: "self-hosted",
+ remoteTranscriptionUrl: "https://orukeet.gizmovoice.ai/v1",
+ remoteTranscriptionModel: "orukeet-v0.1.0",
+ cloudTranscriptionProvider: "custom",
+ });
+ assert.equal(route.endpoint, "https://orukeet.gizmovoice.ai/v1/audio/transcriptions");
+ assert.deepEqual(route.auth, { scheme: "bearer", keyRef: "custom" });
+});
diff --git a/test/helpers/useAudioRecordingForceStop.test.js b/test/helpers/useAudioRecordingForceStop.test.js
index 95d42d87d..091ad92c4 100644
--- a/test/helpers/useAudioRecordingForceStop.test.js
+++ b/test/helpers/useAudioRecordingForceStop.test.js
@@ -41,6 +41,9 @@ export default class FakeAudioManager {
shouldUseStreaming() {
return false;
}
+ isSttConfigStale() {
+ return false;
+ }
cleanup() {}
}
`;
diff --git a/test/helpers/useAudioRecordingPreparingReset.test.js b/test/helpers/useAudioRecordingPreparingReset.test.js
index 9a088a10c..1e8119374 100644
--- a/test/helpers/useAudioRecordingPreparingReset.test.js
+++ b/test/helpers/useAudioRecordingPreparingReset.test.js
@@ -35,6 +35,9 @@ export default class FakeAudioManager {
shouldUseStreaming() {
return false;
}
+ isSttConfigStale() {
+ return false;
+ }
prepareMicCapture() {}
cancelPreparedMicCapture() {}
cleanup() {}
diff --git a/test/helpers/useAudioRecordingSttConfigRefresh.test.js b/test/helpers/useAudioRecordingSttConfigRefresh.test.js
new file mode 100644
index 000000000..63c9d7f2a
--- /dev/null
+++ b/test/helpers/useAudioRecordingSttConfigRefresh.test.js
@@ -0,0 +1,125 @@
+const test = require("node:test");
+const assert = require("node:assert/strict");
+const React = require("react");
+const { createRoot } = require("react-dom/client");
+const {
+ createRendererServer,
+ installBrowserGlobals,
+ installHookDom,
+} = require("../lib/rendererTestHarness");
+
+// The STT config lives in the AudioManager for the life of the window; without
+// a refresh, a server-side rollout change (Orukeet switched on, or rolled
+// back) never reaches a long-running app.
+const FAKE_AUDIO_MANAGER_SOURCE = `
+export default class FakeAudioManager {
+ constructor() {
+ this.voiceAgentRequested = false;
+ this.translationRequested = false;
+ this.sttConfig = null;
+ globalThis.__sttRefreshManager = this;
+ }
+ setCallbacks(callbacks) { this.callbacks = callbacks; }
+ getState() { return { isRecording: false, isProcessing: false, isStreaming: false }; }
+ isSttConfigStale() { return globalThis.__sttRefreshStale; }
+ setSttConfig(config) { this.sttConfig = config; }
+ shouldUseStreaming() { return false; }
+ prepareMicCapture() {}
+ setVoiceAgentRequested() {}
+ setAssistantSelectionContext() {}
+ setTranslationRequested() {}
+ async startRecording() { globalThis.__sttRefreshStarts.push(globalThis.__sttRefreshFetches); return true; }
+ cleanup() {}
+}
+`;
+
+test("a recording start refreshes a stale STT config in the background", async (t) => {
+ let root = null;
+ let start = null;
+ globalThis.__sttRefreshFetches = 0;
+ globalThis.__sttRefreshStarts = [];
+ t.after(async () => {
+ if (root) await React.act(async () => root.unmount());
+ delete globalThis.__sttRefreshManager;
+ delete globalThis.__sttRefreshStale;
+ delete globalThis.__sttRefreshFetches;
+ delete globalThis.__sttRefreshStarts;
+ });
+
+ const noopDispose = () => () => {};
+ installBrowserGlobals(t, {
+ window: {
+ electronAPI: {
+ onToggleDictation: noopDispose,
+ onToggleVoiceAgent: noopDispose,
+ onToggleTranslation: noopDispose,
+ // The start handler skips toggle semantics, so the hook's own
+ // recording state from the previous start does not turn it into a stop.
+ onStartDictation: (handler) => {
+ start = handler;
+ return () => {};
+ },
+ onPrepareDictation: noopDispose,
+ onCancelDictationPreparation: noopDispose,
+ onStopDictation: noopDispose,
+ getSttConfig: async () => {
+ globalThis.__sttRefreshFetches += 1;
+ return {
+ success: true,
+ dictation: { mode: "batch" },
+ fetch: globalThis.__sttRefreshFetches,
+ };
+ },
+ captureDictationTarget: async () => {},
+ completeDictationPreview: async () => {},
+ hideDictationPreview: async () => {},
+ dictationLifecycleStateChanged: () => {},
+ },
+ },
+ });
+ const container = installHookDom(t);
+ const vite = await createRendererServer(t, {
+ cachePrefix: "openwhispr-stt-config-refresh-hook-",
+ mockModules: {
+ "/helpers/audioManager": FAKE_AUDIO_MANAGER_SOURCE,
+ "/utils/logger": "export default { debug() {}, info() {}, warn() {}, error() {} };",
+ },
+ });
+ const { useAudioRecording } = await vite.ssrLoadModule("/hooks/useAudioRecording.js");
+
+ function Harness() {
+ useAudioRecording(() => {}, { onDemoEvent: () => {} });
+ return null;
+ }
+
+ globalThis.__sttRefreshStale = true;
+ root = createRoot(container);
+ await React.act(async () => root.render(React.createElement(Harness)));
+ // The hook re-creates its AudioManager when its effect re-runs, so the fake
+ // records starts on globalThis and the config is read from the live instance.
+ const manager = () => globalThis.__sttRefreshManager;
+ assert.ok(manager().sttConfig, "the mount fetch populated the config");
+
+ // The hook's mount effect can re-run on later renders, so the assertions
+ // below count fetches issued on the start path itself: before startRecording.
+ const startRecording = async () => {
+ const fetchesBefore = globalThis.__sttRefreshFetches;
+ await React.act(async () => {
+ start();
+ // Two bounded visual-frame waits precede the mic open in the start path.
+ await new Promise((resolve) => setTimeout(resolve, 700));
+ });
+ return globalThis.__sttRefreshStarts.at(-1) - fetchesBefore;
+ };
+
+ // A fresh config is not refetched on every hotkey press.
+ globalThis.__sttRefreshStale = false;
+ assert.equal(await startRecording(), 0);
+
+ // A stale one is refreshed in the background, and the recording still starts.
+ globalThis.__sttRefreshStale = true;
+ const configBefore = manager().sttConfig;
+ assert.equal(await startRecording(), 1);
+ assert.equal(globalThis.__sttRefreshStarts.length, 2);
+ assert.notEqual(manager().sttConfig, configBefore);
+});