Skip to content

API Reference parrot.voice.transcriber.moonshine_backend

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.voice.transcriber.moonshine_backend

View source

Moonshine STT Backend.

Opt-in sub-second speech-to-text backend built on the Moonshine ONNX models. Implements :class:AbstractTranscriberBackend so the :class:VoiceTranscriber service can select it interchangeably with the default FasterWhisper backend.

Mirrors the structure of :class:FasterWhisperBackend: the model is loaded lazily on first transcription and the CPU/GPU-bound inference runs off the event loop via asyncio.to_thread.

Opt-in only — FasterWhisper remains the default STT backend (VoiceTranscriberConfig.backend == TranscriberBackend.FASTER_WHISPER). The Moonshine runtime ships behind the ai-parrot-integrations[voice-moonshine] extra; when it is missing the backend raises ImportError / RuntimeError.

Added by FEAT-231 (AgentTalk Voice Support).

Alias AbstractTranscriberBackend

Re-exported from parrot.voice.transcriber.backend.AbstractTranscriberBackend.

Class MoonshineSTTBackend

Sub-second speech-to-text backend using the Moonshine ONNX models.

The model is loaded lazily on first transcribe call to keep construction cheap (so VoiceTranscriber._get_backend can build the backend without paying the model-load cost). Inference runs in a worker thread via asyncio.to_thread so the event loop is never blocked.

Example::

backend = MoonshineSTTBackend(model_name="moonshine/base")
try:
    result = await backend.transcribe(Path("/path/to/audio.wav"))
    print(result.text)
finally:
    await backend.close()
Parameter Type Default Description
model_name str _DEFAULT_MODEL Moonshine model identifier ("moonshine/base" default or "moonshine/tiny").
**kwargs {} Extra keyword arguments are accepted and ignored to allow forward-compatible construction.

Method MoonshineSTTBackend.transcribe

Transcribe an audio file to text using Moonshine.

transcribe(audio_path: Path, language: Optional[str] = None) -> TranscriptionResult

Parameter Type Default Description
audio_path Path Path to the audio file to transcribe.
language Optional[str] None Optional language hint. Moonshine base/tiny models are English-only; the hint is recorded but not used to switch models. None defaults the recorded language to "en".

Returns: TranscriptionResult — TranscriptionResult with the transcribed text, language, audio duration, and processing time.

Raises:

  • FileNotFoundError — If audio_path does not exist.
  • ImportError — If the voice-moonshine extra is not installed.
  • RuntimeError — If transcription fails.

Method MoonshineSTTBackend.close

Release the Moonshine runtime reference.

Clears the internal transcribe-callable reference to allow garbage collection of any loaded model state.

close() -> None

Alias TranscriptionResult

Re-exported from parrot.voice.transcriber.models.TranscriptionResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally