summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/utils/speech.ts
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-06 10:02:31 -0600
committerGitHub <[email protected]>2026-02-06 10:02:31 -0600
commit2c58dd6203df7806f57ef6b29672091cb764e871 (patch)
tree10fca96d3098465b497f78e29de8d0a585c4dac3 /packages/app/src/utils/speech.ts
parenta4bc883595df9ea0f752079519081bc602408553 (diff)
downloadopencode-2c58dd6203df7806f57ef6b29672091cb764e871.tar.gz
opencode-2c58dd6203df7806f57ef6b29672091cb764e871.zip
chore: refactoring and tests, splitting up files (#12495)
Diffstat (limited to 'packages/app/src/utils/speech.ts')
-rw-r--r--packages/app/src/utils/speech.ts12
1 files changed, 5 insertions, 7 deletions
diff --git a/packages/app/src/utils/speech.ts b/packages/app/src/utils/speech.ts
index 201c1261b..52fc46b69 100644
--- a/packages/app/src/utils/speech.ts
+++ b/packages/app/src/utils/speech.ts
@@ -1,5 +1,6 @@
import { onCleanup } from "solid-js"
import { createStore } from "solid-js/store"
+import { getSpeechRecognitionCtor } from "@/utils/runtime-adapters"
// Minimal types to avoid relying on non-standard DOM typings
type RecognitionResult = {
@@ -56,9 +57,8 @@ export function createSpeechRecognition(opts?: {
onFinal?: (text: string) => void
onInterim?: (text: string) => void
}) {
- const hasSupport =
- typeof window !== "undefined" &&
- Boolean((window as any).webkitSpeechRecognition || (window as any).SpeechRecognition)
+ const ctor = getSpeechRecognitionCtor<Recognition>(typeof window === "undefined" ? undefined : window)
+ const hasSupport = Boolean(ctor)
const [store, setStore] = createStore({
isRecording: false,
@@ -155,10 +155,8 @@ export function createSpeechRecognition(opts?: {
}, COMMIT_DELAY)
}
- if (hasSupport) {
- const Ctor: new () => Recognition = (window as any).webkitSpeechRecognition || (window as any).SpeechRecognition
-
- recognition = new Ctor()
+ if (ctor) {
+ recognition = new ctor()
recognition.continuous = false
recognition.interimResults = true
recognition.lang = opts?.lang || (typeof navigator !== "undefined" ? navigator.language : "en-US")