SpeechRecognizer
classin packageklyn.genai.stt
public class SpeechRecognizer implements AutoClosable
SpeechRecognizer
All Implemented Interfaces: AutoClosable

Resident speech-to-text engine, implemented in Klyn/C++ without an external inference library or process. Supports Whisper HF Safetensors and Qwen3-ASR Safetensors/paired GGUF checkpoints; formats never substitute one architecture for another. Projections and encoder attention use CPU/NVIDIA; DSP and decoder attention use synchronized CPU storage. Auto chooses GPU when available; an explicit GPU never silently falls back. NPU is not available yet. Single owner: finish/close its stream before other recognition calls.

Example

try speech = SpeechRecognizer.load("openai/whisper-base"): print(speech.transcribe(AudioClip.load(FilePath("recording.wav")), language="fr").text)

Properties
Modifier and Type Member Description
public readonly property device
device as Device
Concrete execution device.
Constructors
Modifier and Type Member Description
public SpeechRecognizer
SpeechRecognizer(notnull folder as FolderPath, notnull device as Device = Device.auto, verbose as Boolean = false)
Opens a local HF snapshot with config/tokenizer/generation_config and Safetensors shards.
public SpeechRecognizer
SpeechRecognizer(notnull path as FilePath, notnull projector as FilePath, notnull device as Device = Device.auto, verbose as Boolean = false)
Opens a GGUF speech decoder with its matching audio projector.
Methods
Modifier and Type Member Description
public override close
close() as Void
Cancels/joins active recognition before releasing model storage.
public static load
load(notnull repository as String, quantization as ModelQuantization = ModelQuantization.AUTO, notnull device as Device = Device.auto, revision as String = "main", offline as Boolean = false, verbose as Boolean = false, token as String = "", format as ModelFormat = ModelFormat.AUTO) as SpeechRecognizer
Downloads a verified GGUF pair or original Safetensors checkpoint.
public stream
stream(notnull microphone as Microphone, notnull language as String = "auto", minimumSpeechLevel as Double = 0.0003, partialResults as Boolean = true) as TranscriptionStream
Starts one bounded, cancellable live transcription worker.
public transcribe
transcribe(notnull audio as AudioClip, notnull language as String = "auto") as Transcription
Transcribes finite PCM, downmixing/resampling to mono 16 kHz.
public transcribe
transcribe(notnull path as FilePath, notnull language as String = "auto") as Transcription
Transcribes a WAV file without playback.
Inherited Methods
methodInherited Methods from AutoClosable: close