conductor-oss/conductor · error · RuntimeException
Gemini generateAudio failed
Error message
Gemini generateAudio failed
What it means
GeminiVertex.generateAudio() catches any checked Exception (not RuntimeException) during the TTS audio generation flow — which includes the generateContent call with AUDIO response modality and the Base64 decode of returned audio data — and wraps it with this message. The original exception is preserved as the cause. RuntimeExceptions (like a failed Base64 decode from java.util.Base64 which throws IllegalArgumentException, a RuntimeException) propagate unchanged via the first catch.
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/providers/gemini/GeminiVertex.java:251
if (c.content() == null || c.content().parts() == null) continue;
for (GeminiApi.Part p : c.content().parts()) {
if (p.inlineData() != null && p.inlineData().data() != null) {
byte[] bytes =
java.util.Base64.getDecoder().decode(p.inlineData().data());
media.add(
Media.builder()
.data(bytes)
.mimeType("audio/" + request.getResponseFormat())
.build());
}
}
}
}
return LLMResponse.builder().media(media).build();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Gemini generateAudio failed", e);
}
}
}
View on GitHub (pinned to cf7c3e4a8a)
Solutions
- Inspect getCause() for the specific checked exception detail.
- Verify the model supports audio output (e.g. 'gemini-2.5-flash-preview-tts' or a model with TTS capability).
- Verify the voice name is one of Google's prebuilt voices (Charon, Fenrir, Aoede, etc.).
- Check the API key / Vertex AI credentials have access to TTS models.
- Verify network connectivity to the Gemini endpoint.
Example fix
// before
String model = "gemini-2.5-flash"; // no TTS support
AudioGenRequest req = AudioGenRequest.builder().model(model).voice("Unknown").build();
// after
String model = "gemini-2.5-flash-preview-tts";
AudioGenRequest req = AudioGenRequest.builder().model(model).voice("Charon").build(); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate TTS request before calling
private static final Set<String> GEMINI_TTS_MODELS =
Set.of("gemini-2.5-flash-preview-tts", "gemini-2.5-pro-preview-tts");
private static final Set<String> VALID_VOICES =
Set.of("Charon", "Fenrir", "Aoede", "Leda", "Orus", "Puck", "Zephyr");
void validateAudioRequest(AudioGenRequest req) {
if (!GEMINI_TTS_MODELS.contains(req.getModel())) {
throw new IllegalArgumentException(
"Use a TTS-capable model (gemini-2.5-flash-preview-tts). Got: " + req.getModel());
}
if (req.getVoice() != null && !VALID_VOICES.contains(req.getVoice())) {
throw new IllegalArgumentException(
"Invalid voice. Valid: " + VALID_VOICES);
}
} Try / catch
try {
return vertex.generateAudio(request);
} catch (RuntimeException e) {
if (e.getMessage().equals("Gemini generateAudio failed")) {
throw new RuntimeException(
"Gemini audio generation failed — verify TTS model name and voice. "
+ "Cause: " + e.getCause().getMessage(), e);
}
throw e;
} Prevention
- Use a TTS-specific model name (gemini-2.5-flash-preview-tts) — regular chat models don't output audio.
- Verify the voice name is one of Google's prebuilt voices.
- Confirm the API key / Vertex AI credentials have TTS model access.
- Log the cause exception to distinguish model errors from network failures.
When it happens
Trigger: IOException from the generateContent HTTP call with responseModalities=[AUDIO], or a checked exception during response parsing. This fires when the Gemini API call for TTS fails at the transport layer or the response cannot be processed.
Common situations: Model doesn't support audio output (e.g. using a non-TTS model name). Invalid voice name in PrebuiltVoiceConfig. API key lacks TTS permissions. Network failure to the Gemini endpoint. API version mismatch where the speechConfig field is not recognised.
Related errors
- Gemini generateContent failed: {message}
- Gemini generateImages failed: {message}
- Gemini embedContent failed
- Failed to download from {url}
- Failed to download image from {url}
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/9c38fcd69e136dbb.
Report an issue: GitHub.