Add text-to-speech (TTS) support
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3572951. -->
Reported by: [jibla](https://www.drupal.org/user/1013184)
Related to !31
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>New - TTS via dedicated Gemini TTS models<br>
<strong>Check-in Date: </strong>02/11/2026<br>
<strong>Additional Collaborators: </strong><br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Gemini now offers dedicated TTS models (<code>gemini-2.5-flash-preview-tts</code>, <code>gemini-2.5-pro-preview-tts</code>) supporting 30+ prebuilt voices and 100+ languages. The <code>google-gemini-php/client</code> library has supported TTS since v2.3.0 (our composer requirement of <code>^2.5</code> already covers this).</p>
<p>The OpenAI provider already implements <code>TextToSpeechInterface</code>. We should reach parity.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Implement <code>TextToSpeechInterface</code> in GeminiProvider</li>
<li>Add <code>text_to_speech</code> to <code>getSupportedOperationTypes()</code></li>
<li>Use <code>generateContent</code> with <code>responseModalities: ["AUDIO"]</code> and <code>SpeechConfig</code> for voice selection</li>
<li>Map Gemini's PCM audio output (24kHz) to AI module's <code>AudioFile</code> objects in <code>TextToSpeechOutput</code></li>
<li>Add TTS configuration section to <code>definitions/api_defaults.yml</code> (voice selection)</li>
<li>Add model filtering in <code>getConfiguredModels()</code> for TTS models</li>
<li>Update <code>ai_provider_info.yml</code> with <code>text_to_speech</code></li>
<li>Add tests</li>
</ul>
<p><strong>References:</strong></p>
<ul>
<li><a href="https://ai.google.dev/gemini-api/docs/speech-generation">Gemini TTS documentation</a></li>
<li><a href="https://github.com/google-gemini-php/client">google-gemini-php/client</a> (TTS since v2.3.0)</li>
</ul>
<h3 id="summary-remaining-tasks">Target date or deadline</h3>
<p>Before stable release.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Implement <code>TextToSpeechInterface</code></li>
<li>Add voice configuration to api_defaults.yml</li>
<li>Handle PCM to WAV/MP3 conversion if needed by AI module</li>
<li>Add model filtering for TTS operation type</li>
<li>Write tests</li>
<li>phpcs clean</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[ ] AI Assisted Code</p>
<p>[ ] AI Generated Code</p>
<p>[ ] Vibe Coded</p>
issue