tonhowtf/omniget · error

resposta vazia

Error message

resposta vazia

What it means

After a successful HTTP status, wav_from reads the response bytes and rejects any body smaller than 100 bytes as 'resposta vazia' (empty response), since valid WAV audio is always larger. This catches servers that return 200 with an empty or trivially small body instead of real audio.

Solutions

  1. Inspect the actual response body (<100 bytes) to see whether it's empty, HTML, or a JSON error message.
  2. Verify the request produced real work server-side (check VoiceStudio logs for the synthesis job).
  3. Confirm the endpoint URL is the audio-producing route and not a status/metadata route.
  4. Retry the request; transient gateway issues can produce empty 200 responses.
  5. If the server legitimately returns short payloads (e.g. tiny valid files), lower or parameterize the 100-byte threshold.
Defensive patterns

Strategy: validation

Validate before calling

// After any VoiceStudio call that should return audio, verify size before saving
if let Ok(meta) = std::fs::metadata(&output_path) {
    if meta.len() < 100 {
        return Err("VoiceStudio returned no audio data".into());
    }
}

Type guard

fn is_plausible_wav(bytes: &[u8]) -> bool {
    bytes.len() >= 100 && bytes.starts_with(b"RIFF") && bytes.len() >= 12 && &bytes[8..12] == b"WAVE"
}

Try / catch

match wav_result {
    Err(e) if e.to_string() == "resposta vazia" => {
        // retry once, then fall back to an alternate endpoint or report no-audio
    }
    other => other?,
}

Prevention

When it happens

Trigger: VoiceStudio returns HTTP 200 but the body is empty, an HTML error page, or a stub/placeholder smaller than 100 bytes during clone_speak, design_speak, or isolate.

Common situations: A proxy or gateway returning a 200 with an empty body after a timeout, misconfigured VoiceStudio endpoint returning JSON instead of WAV, or silent synthesis failure where the server acknowledges but produces no audio.

Related errors


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

Appendix: source

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

    } else {
        crate::core::process::command(&app).spawn()?;
    }
    Ok(())
}

async fn wav_from(resp: reqwest::Response, output: &Path) -> anyhow::Result<PathBuf> {
    let status = resp.status();
    if !status.is_success() {
        let text = resp.text().await.unwrap_or_default();
        return Err(anyhow!(
            "VoiceStudio HTTP {}: {}",
            status.as_u16(),
            text.chars().take(300).collect::<String>()
        ));
    }
    let bytes = resp.bytes().await?;
    if bytes.len() < 100 {
        return Err(anyhow!("resposta vazia"));
    }
    if let Some(parent) = output.parent() {
        std::fs::create_dir_all(parent)?;
    }
    std::fs::write(output, &bytes)?;
    Ok(output.to_path_buf())
}

fn stamp() -> String {
    chrono::Local::now().format("%Y%m%d-%H%M%S").to_string()
}

fn out_path(output_dir: &str, name: &str) -> PathBuf {
    let dir = if output_dir.trim().is_empty() {
        dirs::audio_dir()
            .or_else(dirs::home_dir)
            .unwrap_or_default()
            .join("OmniGet")

View on GitHub (pinned to 8600b91f42)