Files
orca/src/shared/speech-recognizer-package.ts
T
Kelvin Amoaba d291670a01 refactor(speech): remove sherpa-onnx (#39473)
transcribe-cpp is now the only on-device engine on every platform, so
the sherpa-onnx packages, their packaging (extraResources, the darwin
libonnxruntime prune, the native-variant assert and the Linux libstdc++
exemption), the sherpa recognizer in the speech process and the
per-model engine choice all go. Hotwords are written as plain terms.
2026-11-09 18:59:10 +00:00

26 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { existsSync } from 'node:fs'
import { join } from 'node:path'
import transcribeCppPackages from './transcribe-cpp-packages.json'
/** Desktop and orca serve share the app’s speech engine packages; orcad slots omit them. */
/** Set by `orca serve` for orcad: the app's node_modules directory holding the speech engine packages. */
export const SPEECH_RECOGNIZER_DIR_ENV = 'ORCA_SPEECH_RECOGNIZER_DIR'
// Packaging reads the same table. Intel Macs run transcribe-cpp on the CPU (its x64 build has no GPU backend).
const TRANSCRIBE_CPP_PACKAGES: Record<string, string> = transcribeCppPackages
/** Whether `nodeModulesDir` holds transcribe-cpp and this host's native package for it. */
export function hasSpeechEnginePackage(
nodeModulesDir: string,
platform: string = process.platform,
arch: string = process.arch
): boolean {
const native = TRANSCRIBE_CPP_PACKAGES[`${platform}-${arch}`]
return (
native !== undefined &&
existsSync(join(nodeModulesDir, 'transcribe-cpp', 'package.json')) &&
existsSync(join(nodeModulesDir, ...native.split('/'), 'contract.json'))
)
}