Cohere-Transcribe-WebGPU / src /transcriberContext.ts
julianmack's picture
Upload demo files (#1)
4a5024e
raw
history blame contribute delete
638 Bytes
import { createContext, useContext } from "react";
export interface TranscriberState {
status: "idle" | "loading" | "ready" | "error";
error: string | null;
progress: number;
statusText: string;
load: () => Promise<void>;
transcribe: (
audio: Float32Array,
language?: string,
onToken?: (token: string) => void,
) => Promise<string>;
}
export const TranscriberContext = createContext<TranscriberState | null>(null);
export function useTranscriber() {
const ctx = useContext(TranscriberContext);
if (!ctx) {
throw new Error("useTranscriber must be used within TranscriberProvider");
}
return ctx;
}