Spaces:
Running
Running
Download src/services/capabilities.ts from aut4rk/private-voice-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/aut4rk/private-voice-agent/resolve/4e3468620e7861b7df10fffa5abe4552da16ba09/src/services/capabilities.ts
- Command line
-
hf download hf://spaces/aut4rk/private-voice-agent@4e3468620e7861b7df10fffa5abe4552da16ba09/src/services/capabilities.ts
-
curl -L -o capabilities.ts https://huggingface.co/spaces/aut4rk/private-voice-agent/resolve/4e3468620e7861b7df10fffa5abe4552da16ba09/src/services/capabilities.ts
1.52 kB
| import type { | |
| AppCapability, | |
| CapabilitiesService, | |
| CapabilitySnapshot, | |
| } from "../app/types"; | |
| export const evaluateCapabilitySnapshot = ( | |
| snapshot: CapabilitySnapshot, | |
| ): AppCapability => { | |
| if (!snapshot.hasMediaDevices) { | |
| return { | |
| ...snapshot, | |
| canRunDemo: false, | |
| failureReason: "This browser does not expose microphone capture APIs.", | |
| }; | |
| } | |
| if (!snapshot.hasWebGPU) { | |
| return { | |
| ...snapshot, | |
| canRunDemo: false, | |
| failureReason: "WebGPU is unavailable, so local model execution cannot start.", | |
| }; | |
| } | |
| if (!snapshot.hasAudioWorklet) { | |
| return { | |
| ...snapshot, | |
| canRunDemo: false, | |
| failureReason: "AudioWorklet support is unavailable, so live capture is unreliable.", | |
| }; | |
| } | |
| return { | |
| ...snapshot, | |
| canRunDemo: true, | |
| failureReason: null, | |
| }; | |
| }; | |
| export class BrowserCapabilitiesService implements CapabilitiesService { | |
| async detect(): Promise<AppCapability> { | |
| const snapshot: CapabilitySnapshot = { | |
| hasWebGPU: typeof navigator !== "undefined" && "gpu" in navigator, | |
| hasMediaDevices: | |
| typeof navigator !== "undefined" && | |
| typeof navigator.mediaDevices?.getUserMedia === "function", | |
| hasAudioWorklet: | |
| typeof window !== "undefined" && | |
| typeof window.AudioWorkletNode !== "undefined", | |
| hasCrossOriginIsolation: | |
| typeof globalThis !== "undefined" && | |
| globalThis.crossOriginIsolated === true, | |
| }; | |
| return evaluateCapabilitySnapshot(snapshot); | |
| } | |
| } | |