100% Full API Reference
Exhaustive specification for all public functions, classes, and types.
Factory Function: create_engine()
def create_engine(
engine: str = "whisper",
*,
model: Optional[str] = None,
lang: str = "ko",
num_speakers: int = 0,
threads: Optional[int] = None,
vad: bool = True,
vad_threshold: float = 0.5,
quantization: str = "q5_1",
custom_model_path: Optional[str] = None,
**kwargs
) -> Engine
Class: Engine (Abstract Base Class)
transcribe(audio_path: str, **kwargs) -> TranscriptResultstream_mic(duration: Optional[float] = None) -> Iterator[Segment]stream_file(audio_path: str, chunk_sec: float = 5.0) -> Iterator[Segment]diarize(audio_path: str, num_speakers: int = 2) -> DiarizedResultget_info() -> Dict[str, Any]
Data Classes: TranscriptResult & Segment
@dataclass
class Segment:
start: float # Start time in seconds
end: float # End time in seconds
text: str # Transcribed text
speaker: Optional[str] = None # e.g. "Speaker_0"
confidence: Optional[float] = None # 0.0 - 1.0
@dataclass
class TranscriptResult:
text: str
segments: List[Segment]
language: Optional[str] = None
duration: Optional[float] = None
def to_json(self) -> str: ...
def to_srt(self) -> str: ...
def to_vtt(self) -> str: ...
def to_rttm(self, file_id: str = "audio") -> str: ...
@dataclass
class DiarizedResult(TranscriptResult):
speakers: List[str] = field(default_factory=list)
Clustering: KMeans & cosine_similarity
# Pure Python Math - Zero ML dependencies
from termux_stt.diarization.clustering import KMeans, cosine_similarity, euclidean_distance
sim = cosine_similarity(vec_a, vec_b)
kmeans = KMeans(n_clusters=2, seed=42)
kmeans.fit(vectors_128d)
labels = kmeans.predict(vectors_128d)