import { createContext, useContext } from "react"; import type { RefObject } from "react"; import type { TextToAudioPipeline } from "@huggingface/transformers"; export interface TTSContextType { pipelineReady: boolean; downloadProgress: number; tts: RefObject; speakerEmbeddings: RefObject | null>; } export const TTSContext = createContext(undefined); export const useTTS = () => { const context = useContext(TTSContext); if (context === undefined) { throw new Error("useTTS must be used within a TTSProvider"); } return context; };