Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Mic: stop retrying when the speech service is out of reach

Youssef44061e85eee5
diff --git a/src/components/guide/hooks.ts b/src/components/guide/hooks.ts
index 068c9d1..6538890 100644
--- a/src/components/guide/hooks.ts
+++ b/src/components/guide/hooks.ts
@@ -121,6 +121,10 @@ export function useListener(enabled: boolean, onPhrase: (text: string, final: bo
if (e.error === "not-allowed" || e.error === "service-not-allowed" || (e.error === "audio-capture" && fails >= 4)) {
stop = true;
setMic("denied");
+ } else if (e.error === "network" && fails >= 2) {
+ // the speech service is out of reach (no signal, or a browser without one): stop, and say to tap instead
+ stop = true;
+ setMic("unsupported");
} else if (e.error !== "no-speech" && e.error !== "aborted") fails++;
};
try {