Hmbown/CodeWhale · error
unsupported voice clone sample extension
Error message
unsupported voice clone sample extension '{other}'. Use .mp3 or .wav. What it means
After size validation the function maps the file extension to a MIME type; only .mp3 (audio/mpeg) and .wav (audio/wav) are supported for voice-clone samples. Any other extension bails with this message naming the offending extension.
Solutions
- Convert the audio to MP3: `ffmpeg -i input.flac output.mp3`
- Or convert to WAV: `ffmpeg -i input.ogg output.wav` (mind the 10 MB base64 limit)
- Rename only if the container genuinely matches — do not rename .ogg to .mp3; actually transcode
Example fix
// before
encode_voice_clone_data_uri("sample.m4a")?
// after
// ffmpeg -i sample.m4a sample.mp3
encode_voice_clone_data_uri("sample.mp3")? Defensive patterns
Strategy: validation
Validate before calling
let ext = path.extension().and_then(|e| e.to_str()).map(|e| e.to_ascii_lowercase()).unwrap_or_default(); if !matches!(ext.as_str(), "mp3" | "wav") { return Err(format!("transcode {ext} to mp3/wav first")); } Prevention
- Only feed .mp3 or .wav files
- Transcode with ffmpeg before upload
- Do not merely rename containers — actually convert
- Handle extension-less temp files explicitly
When it happens
Trigger: Calling encode_voice_clone_data_uri / encode_voice_clone_sample_data_uri with a file whose lowercased extension is not `mp3` or `wav` — e.g. .flac, .ogg, .m4a, .aac, .MP4, or a file with no extension.
Common situations: Passing an OGG or FLAC recording from a voice recorder; downloading a sample as .m4a from a chat app; files without extensions from temp directories; case handled (to_ascii_lowercase) so .WAV is fine but .mp4 is not.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- voice clone sample is too large after base64 encoding
- initialized audio cursor
- Invalid pet PCM range.
- Invalid pet PCM range.
- Invalid pet PCM range.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/9b9c16dd85ebc575.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/speech.rs:445
fn voice_clone_data_uri_from_bytes(path: &Path, bytes: &[u8]) -> anyhow::Result<String> {
let base64_audio = general_purpose::STANDARD.encode(bytes);
if base64_audio.len() > VOICE_CLONE_BASE64_MAX_BYTES {
anyhow::bail!(
"voice clone sample is too large after base64 encoding ({} bytes > 10 MB)",
base64_audio.len()
);
}
let extension = path
.extension()
.and_then(|value| value.to_str())
.unwrap_or_default()
.to_ascii_lowercase();
let mime = match extension.as_str() {
"mp3" => "audio/mpeg",
"wav" => "audio/wav",
other => {
anyhow::bail!("unsupported voice clone sample extension '{other}'. Use .mp3 or .wav.");
}
};
Ok(format!("data:{mime};base64,{base64_audio}"))
}
pub(crate) fn describe_speech_voice(voice: &str) -> String {
if voice.starts_with("data:") {
"embedded voice clone sample".to_string()
} else {
voice.to_string()
}
}
fn openai_compatible_base_url(base_url: &str) -> String {
let trimmed = base_url.trim_end_matches('/');
if trimmed.ends_with("/v1") || trimmed.ends_with("/beta") {
trimmed.to_string()View on GitHub (pinned to 73e0f67d83)