mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-28 17:07:16 +00:00
Add Gemini TTS provider and integrate client/docs (#2889)
Introduce a new Gemini TTS provider and wire it through the driver, client, docs, and examples. Adds src/backend/drivers/ai-tts/providers/gemini/GeminiTTSProvider.ts (Google GenAI client usage, PCM->WAV wrapping, metering, model/voice validation) and a costs table in providers/gemini/costs.ts. Registers the provider in TTSDriver, exposes the alias gemini-tts, and prefers it in provider selection. Updates puter-js client to recognize "gemini" provider/engine and route driver calls to gemini-tts. Documentation updated with Gemini options, a usage example, and a playground example HTML file.
This commit is contained in:
@@ -226,6 +226,7 @@ You can see various Puter.js AI features in action from the following examples:
|
||||
- [Text to Speech with options](/playground/ai-txt2speech-options/)
|
||||
- [Text to Speech with engines](/playground/ai-txt2speech-engines/)
|
||||
- [Text to Speech with OpenAI voices](/playground/ai-txt2speech-openai/)
|
||||
- [Text to Speech with Gemini voices](/playground/ai-txt2speech-gemini/)
|
||||
- [Transcribe audio with `speech2txt`](/AI/speech2txt/)
|
||||
- Text to Video
|
||||
- [Generate a sample Sora clip](/AI/txt2vid/)
|
||||
|
||||
@@ -32,7 +32,7 @@ Additional settings for the generation request. Available options depend on the
|
||||
|
||||
| Option | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `provider` | `String` | TTS provider to use. `'aws-polly'` (default), `'openai'`, `'elevenlabs'` |
|
||||
| `provider` | `String` | TTS provider to use. `'aws-polly'` (default), `'openai'`, `'elevenlabs'`, `'gemini'` |
|
||||
| `model` | `String` | Model identifier (provider-specific) |
|
||||
| `voice` | `String` | Voice ID used for synthesis (provider-specific) |
|
||||
| `test_mode` | `Boolean` | When `true`, returns a sample audio without using credits |
|
||||
@@ -74,6 +74,18 @@ Available when `provider: 'elevenlabs'`:
|
||||
|
||||
For more details about each option, see the [ElevenLabs API reference](https://elevenlabs.io/docs/api-reference/text-to-speech).
|
||||
|
||||
#### Gemini Options
|
||||
|
||||
Available when `provider: 'gemini'`:
|
||||
|
||||
| Option | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `model` | `String` | TTS model. Available: `'gemini-2.5-flash-preview-tts'` (default), `'gemini-2.5-pro-preview-tts'`, `'gemini-3.1-flash-tts-preview'` |
|
||||
| `voice` | `String` | Voice name. Defaults to `'Kore'`. Available: `'Zephyr'`, `'Puck'`, `'Charon'`, `'Kore'`, `'Fenrir'`, `'Leda'`, `'Orus'`, `'Aoede'`, `'Callirrhoe'`, `'Autonoe'`, `'Enceladus'`, `'Iapetus'`, `'Umbriel'`, `'Algieba'`, `'Despina'`, `'Erinome'`, `'Algenib'`, `'Rasalgethi'`, `'Laomedeia'`, `'Achernar'`, `'Alnilam'`, `'Schedar'`, `'Gacrux'`, `'Pulcherrima'`, `'Achird'`, `'Zubenelgenubi'`, `'Vindemiatrix'`, `'Sadachbia'`, `'Sadaltager'`, `'Sulafat'` |
|
||||
| `instructions` | `String` | Natural language instructions to control speaking style (tone, speed, mood, etc.) |
|
||||
|
||||
For more details about Gemini TTS, see the [Google Gemini TTS documentation](https://ai.google.dev/gemini-api/docs/text-to-speech).
|
||||
|
||||
## Return value
|
||||
|
||||
A `Promise` that resolves to an `HTMLAudioElement`. The element’s `src` points at a blob or remote URL containing the synthesized audio.
|
||||
@@ -171,6 +183,31 @@ A `Promise` that resolves to an `HTMLAudioElement`. The element’s `src` points
|
||||
</html>
|
||||
```
|
||||
|
||||
<strong class="example-title">Use Gemini voices</strong>
|
||||
|
||||
```html;ai-txt2speech-gemini
|
||||
<html>
|
||||
<body>
|
||||
<script src="https://js.puter.com/v2/"></script>
|
||||
<button id="play">Use Gemini voice</button>
|
||||
<script>
|
||||
document.getElementById('play').addEventListener('click', async ()=>{
|
||||
const audio = await puter.ai.txt2speech(
|
||||
"Hello! This sample uses the Gemini Puck voice.",
|
||||
{
|
||||
provider: "gemini",
|
||||
model: "gemini-2.5-flash-preview-tts",
|
||||
voice: "Puck",
|
||||
instructions: "Speak in a friendly, upbeat tone."
|
||||
}
|
||||
);
|
||||
audio.play();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
<strong class="example-title">Compare different engines</strong>
|
||||
|
||||
```html;ai-txt2speech-engines
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<body>
|
||||
<script src="https://js.puter.com/v2/"></script>
|
||||
<button id="play">Use Gemini voice</button>
|
||||
<script>
|
||||
document.getElementById('play').addEventListener('click', async ()=>{
|
||||
const audio = await puter.ai.txt2speech(
|
||||
"Hello! This sample uses the Gemini Puck voice.",
|
||||
{
|
||||
provider: "gemini",
|
||||
model: "gemini-2.5-flash-preview-tts",
|
||||
voice: "Puck",
|
||||
instructions: "Speak in a friendly, upbeat tone."
|
||||
}
|
||||
);
|
||||
audio.play();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user