File size: 638 Bytes
4a5024e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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;
}
|