{"record":{"id":"9b9c16dd85ebc575","repo":"Hmbown/CodeWhale","slug":"unsupported-voice-clone-sample-extension-other","errorCode":null,"errorMessage":"unsupported voice clone sample extension '{other}'. Use .mp3 or .wav.","messagePattern":"unsupported voice clone sample extension '(.+?)'\\. Use \\.mp3 or \\.wav\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/speech.rs","lineNumber":445,"sourceCode":"fn voice_clone_data_uri_from_bytes(path: &Path, bytes: &[u8]) -> anyhow::Result<String> {\n    let base64_audio = general_purpose::STANDARD.encode(bytes);\n    if base64_audio.len() > VOICE_CLONE_BASE64_MAX_BYTES {\n        anyhow::bail!(\n            \"voice clone sample is too large after base64 encoding ({} bytes > 10 MB)\",\n            base64_audio.len()\n        );\n    }\n\n    let extension = path\n        .extension()\n        .and_then(|value| value.to_str())\n        .unwrap_or_default()\n        .to_ascii_lowercase();\n    let mime = match extension.as_str() {\n        \"mp3\" => \"audio/mpeg\",\n        \"wav\" => \"audio/wav\",\n        other => {\n            anyhow::bail!(\"unsupported voice clone sample extension '{other}'. Use .mp3 or .wav.\");\n        }\n    };\n\n    Ok(format!(\"data:{mime};base64,{base64_audio}\"))\n}\n\npub(crate) fn describe_speech_voice(voice: &str) -> String {\n    if voice.starts_with(\"data:\") {\n        \"embedded voice clone sample\".to_string()\n    } else {\n        voice.to_string()\n    }\n}\n\nfn openai_compatible_base_url(base_url: &str) -> String {\n    let trimmed = base_url.trim_end_matches('/');\n    if trimmed.ends_with(\"/v1\") || trimmed.ends_with(\"/beta\") {\n        trimmed.to_string()","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/speech.rs#L427-L463","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nencode_voice_clone_data_uri(\"sample.m4a\")?\n// after\n// ffmpeg -i sample.m4a sample.mp3\nencode_voice_clone_data_uri(\"sample.mp3\")?","handlingStrategy":"validation","validationCode":"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\")); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only feed .mp3 or .wav files","Transcode with ffmpeg before upload","Do not merely rename containers — actually convert","Handle extension-less temp files explicitly"],"tags":["audio","file-extension","voice-clone","unsupported-format"],"backgroundTag":"unsupported-operation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}