tonhowtf/omniget · error

amostra

Error message

amostra: {}

What it means

clone_speak reads the local voice sample file with std::fs::read before building the multipart profile-creation form, and wraps any I/O failure as 'amostra: {}' (sample: {}), including the OS error. It means the sample audio file could not be read from disk.

Solutions

  1. Check the error's inner OS message: NotFound means fix the path; PermissionDenied means fix file permissions.
  2. Verify opts.sample exists and is a regular file before calling clone_speak (std::path::Path::is_file).
  3. Correct the sample path passed by the caller/UI.
  4. Ensure the sample file was fully written (not still being recorded) before invoking clone_speak.

Example fix

// before
let sample = std::fs::read(&opts.sample).map_err(|e| anyhow!("amostra: {}", e))?;
// after
let sample_path = Path::new(&opts.sample);
if !sample_path.is_file() {
    anyhow::bail!("amostra: arquivo nao encontrado: {}", opts.sample);
}
let sample = std::fs::read(sample_path).map_err(|e| anyhow!("amostra: {}", e))?;
Defensive patterns

Strategy: validation

Validate before calling

fn validate_sample(path: &str) -> Result<(), String> {
    let p = std::path::Path::new(path);
    if !p.is_file() { return Err(format!("sample not a file: {path}")); }
    match std::fs::metadata(p) {
        Ok(m) if m.len() > 0 => Ok(()),
        Ok(_) => Err("sample file is empty".into()),
        Err(e) => Err(format!("sample unreadable: {e}")),
    }
}

Try / catch

match std::fs::read(&opts.sample) {
    Ok(bytes) => { /* build multipart form */ }
    Err(e) if e.kind() == std::io::ErrorKind::NotFound => eprintln!("amostra nao encontrada: {}", opts.sample),
    Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => eprintln!("sem permissao: {}", opts.sample),
    Err(e) => eprintln!("amostra: {e}"),
}

Prevention

When it happens

Trigger: opts.sample points to a path that does not exist, is a directory, or the process lacks read permission when creating a cloned voice profile.

Common situations: User typed a wrong path in the UI, the sample was recorded to a temp dir that was cleaned up, or the file is on an unmounted network drive.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/0fb81f12bd95e4ca. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/voicestudio.rs:284

    progress: super::ProgressFn,
) -> anyhow::Result<SpeechResult> {
    let b = base(&opts.base_url);
    let c = client(900)?;
    let mut profile_id = if opts.profile_id.trim().is_empty() {
        None
    } else {
        Some(opts.profile_id.trim().to_string())
    };
    if profile_id.is_none() && !opts.save_as.trim().is_empty() {
        super::report(
            &progress,
            "voicestudio",
            "profile",
            0,
            None,
            Some(opts.save_as.clone()),
        );
        let sample = std::fs::read(&opts.sample).map_err(|e| anyhow!("amostra: {}", e))?;
        let file_name = Path::new(&opts.sample)
            .file_name()
            .map(|s| s.to_string_lossy().to_string())
            .unwrap_or_else(|| "sample.wav".into());
        let form = reqwest::multipart::Form::new()
            .text("name", opts.save_as.trim().to_string())
            .text("kind", "clone")
            .text("ref_text", opts.sample_text.clone())
            .text(
                "language",
                if opts.language.is_empty() {
                    "Auto".to_string()
                } else {
                    opts.language.clone()
                },
            )
            .part(
                "ref_audio",

View on GitHub (pinned to 8600b91f42)