cjpais/Handy · error · anyhow::Error

Moonshine transcription failed: {}

Error message

Moonshine transcription failed: {}

What it means

MoonshineModel::transcribe failed during ONNX inference with default TranscribeOptions. transcribe-rs surfaces an ONNX Runtime error — session run failure, execution-provider problem, invalid input length (Moonshine has minimum chunk requirements), or damaged model files. Only this call fails; the engine is put back into the slot, so the model stays loaded for the next attempt.

Source

Thrown at src-tauri/src/managers/transcription.rs:1342

                            })
                            .map_err(|e| {
                                anyhow::anyhow!("transcribe-cpp transcription failed: {}", e)
                            })
                    }
                    LoadedEngine::Parakeet(parakeet_engine) => {
                        let params = ParakeetParams {
                            timestamp_granularity: Some(TimestampGranularity::Segment),
                            ..Default::default()
                        };
                        parakeet_engine
                            .transcribe_with(&audio, &params)
                            .map(|r| r.text)
                            .map_err(|e| anyhow::anyhow!("Parakeet transcription failed: {}", e))
                    }
                    LoadedEngine::Moonshine(moonshine_engine) => moonshine_engine
                        .transcribe(&audio, &TranscribeOptions::default())
                        .map(|r| r.text)
                        .map_err(|e| anyhow::anyhow!("Moonshine transcription failed: {}", e)),
                    LoadedEngine::MoonshineStreaming(streaming_engine) => streaming_engine
                        .transcribe(&audio, &TranscribeOptions::default())
                        .map(|r| r.text)
                        .map_err(|e| {
                            anyhow::anyhow!("Moonshine streaming transcription failed: {}", e)
                        }),
                    LoadedEngine::SenseVoice(sense_voice_engine) => {
                        let language = match normalize_cjk_language(&validated_language) {
                            "zh" => Some("zh".to_string()),
                            "en" => Some("en".to_string()),
                            "ja" => Some("ja".to_string()),
                            "ko" => Some("ko".to_string()),
                            "yue" => Some("yue".to_string()),
                            _ => None,
                        };
                        applied_language_hint = language.clone();
                        let params = SenseVoiceParams {
                            language,

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Retry with a longer recording so the audio meets Moonshine's minimum input length
  2. Re-download the Moonshine model if every attempt fails
  3. Free memory / close GPU-heavy applications and retry
  4. Try another engine to determine whether the fault is Moonshine-specific
  5. Update Handy for ort/transcribe-rs fixes

Example fix

// before
let r = moonshine_engine.transcribe(&audio, &TranscribeOptions::default())?;

// after — pad short audio to Moonshine's minimum chunk before transcribing
let audio = if audio.len() < MIN_MOONSHINE_SAMPLES { pad_to(audio, MIN_MOONSHINE_SAMPLES) } else { audio };
let r = moonshine_engine.transcribe(&audio, &TranscribeOptions::default())?;
Defensive patterns

Strategy: try-catch

Validate before calling

// Moonshine needs a minimum chunk; pad or reject before the engine call
const MIN_MOONSHINE_SAMPLES: usize = 16_000; // ~1s @ 16kHz
anyhow::ensure!(audio.len() >= MIN_MOONSHINE_SAMPLES || pad_ok, "clip too short for Moonshine");

Try / catch

match tm.transcribe(audio.clone()) {
    Err(e) if e.to_string().contains("Moonshine transcription failed") => {
        let padded = pad_to_min(audio, MIN_MOONSHINE_SAMPLES);
        tm.transcribe(padded)
    }
    other => other,
}

Prevention

When it happens

Trigger: moonshine_engine.transcribe(&audio, &TranscribeOptions::default()) errors: audio shorter than Moonshine's minimum chunk after VAD trimming; OrtError from a failing GPU execution provider; corrupted/missing .onnx artifacts at inference time; OOM during decode.

Common situations: Brief clicks/short utterances reduced to tiny audio by VAD; partial model deletion on disk; ort version/provider mismatch after update; low-memory machines; other GPU processes contending.

Related errors


AI-assisted analysis of cjpais/Handy@98a4d80cce (2026-08-16). Data as JSON: /api/errors/bf05cfe29d082972. Report an issue: GitHub.