Przejdź do treści
Biblioteka skilli
Programowanie · Integracja z narzędziem

deepgram-java-text-to-speech

/deepgram-java-text-to-speech

Obsługuje w Javie Deepgram Text-to-Speech v1 (/v1/speak): jednorazową syntezę przez REST (audio().generate) oraz syntezę strumieniową przez WebSocket (v1WebSocket), w tym modele Aura.

Licencja
MIT
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
5
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Obsługuje w Javie Deepgram Text-to-Speech v1 (/v1/speak): jednorazową syntezę przez REST (audio().generate) oraz syntezę strumieniową przez WebSocket (v1WebSocket), w tym modele Aura.

Wyzwalacze z opisu

ttstext to speechspeakaurastreaming ttsspeak websocket
Oryginalny opis (EN)

Use when writing or reviewing Java code in this repo that calls Deepgram Text-to-Speech v1 (`/v1/speak`) for audio synthesis. Covers one-shot REST via `client.speak().v1().audio().generate(...)` and streaming synthesis via `client.speak().v1().v1WebSocket()`. Use `deepgram-java-voice-agent` for full-duplex assistants instead of one-way synthesis. Triggers include "tts", "text to speech", "speak", "aura", "streaming tts", and "speak websocket".

Jak działa

  1. When to use this product
  2. Authentication
  3. Quick start — REST
  4. Quick start — WebSocket
  5. Async equivalent
  6. Key parameters / API surface
  7. API reference (layered)
  8. Gotchas
  9. Example files in this repo
  10. Central product skills
Sekcje z nagłówków SKILL.md, w oryginale · 150 linii, 592 słów
Podgląd SKILL.md
---
name: deepgram-java-text-to-speech
description: Use when writing or reviewing Java code in this repo that calls Deepgram Text-to-Speech v1 (`/v1/speak`) for audio synthesis. Covers one-shot REST via `client.speak().v1().audio().generate(...)` and streaming synthesis via `client.speak().v1().v1WebSocket()`. Use `deepgram-java-voice-agent` for full-duplex assistants instead of one-way synthesis. Triggers include "tts", "text to speech", "speak", "aura", "streaming tts", and "speak websocket".
---

# Using Deepgram Text-to-Speech (Java SDK)

Convert text to audio with REST or stream audio back incrementally over WebSocket via `/v1/speak`.

## When to use this product

- **REST (`audio().generate`)** — one-shot synthesis when you already have the full text.
- **WebSocket (`v1WebSocket()`)** — lower-latency synthesis while text arrives in chunks.

**Use a different skill when:**
- You need the system to listen, think, and speak in one session → `deepgram-java-voice-agent`.

## Authentication

```java
import com.deepgram.DeepgramClient;

DeepgramClient client = DeepgramClient.builder()
        .apiKey(System.getenv("DEEPGRAM_API_KEY"))
        .build();
```

API key auth uses `Authorization: Token <apiKey>`.

## Quick start — REST

```java
import com.deepgram.resources.speak.v1.audio.requests.SpeakV1Request;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

SpeakV1Request request = SpeakV1Request.builder()
        .text("Hello! This is a text-to-speech example using the Deepgram Java SDK.")
        .build();

InputStream audioStream = client.speak().v1().audio().generate(request);
Files.copy(audioStream, Path.of("output.mp3"), StandardCopyOption.REPLACE_EXISTING);
audioStream.close();
```

REST returns an `InputStream`, not JSON.

## Quick start — WebSocket

```java
import com.deepgram.resources.speak.v1.types.SpeakV1Close;
import com.deepgram.resources.speak.v1.types.SpeakV1CloseType;
import com.deepgram.resources.speak.v1.types.SpeakV1Flush;
import com.deepgram.resources.speak.v1.types.SpeakV1FlushType;
import com.deepgram.resources.speak.v1.types.SpeakV1Text;
import com.deepgram.resources.speak.v1.websocket.V1WebSocketClient;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

Logger logger = Logger.getLogger("StreamingTts");
V1WebSocketClient wsClient = client.speak().v1().v1WebSocket();
OutputStream audioOutput = new FileOutputStream("output_streaming.wav");

// Log write failures rather than throwing from the WebSocket callback thread
// (matches examples/speak/StreamingTts.java).
wsClient.onSpeakV1Audio(audioData -> {
    try {
        audioOutput.write(audioData.toByteArray());
    } catch (IOException e) {
        logger.log(Level.SEVERE, "Failed to write streaming audio to output file.", e);
    }
});

// Close the output stream when the server disconnects so we don't leak the file handle.
wsClient.onDisconnected(message -> {
    try {
        audioOutput.close();
    } catch (IOException e) {
        logger.log(Level.WARNING, "Failed to close streaming audio output file.", e);
    }
});

wsClient.connect().get(10, TimeUnit.SECONDS);
wsClient.sendText(SpeakV1Text.builder().text("Hello, this is streaming text to speech.").build());
wsClient.sendFlush(SpeakV1Flush.builder().type(SpeakV1FlushType.FLUSH).build());
wsClient.sendClose(SpeakV1Close.builder().type(SpeakV1CloseType.CLOSE).build());
```

## Async equivalent

```java
import com.deepgram.AsyncDeepgramClient;
import java.io.InputStream;
import java.util.concurrent.CompletableFuture;

AsyncDeepgramClient asyncClient = AsyncDeepgramClient.builder()
        .apiKey(System.getenv("DEEPGRAM_API_KEY"))
        .build();

CompletableFuture<InputStream> future = asyncClient.speak().v1().audio().generate(request);
```

## Key parameters / API surface

- REST request builder: `SpeakV1Request.builder().text(...)`
- Verified REST params: `model`, `encoding`, `sampleRate`, `bitRate`, `container`, `callback`, `callbackMethod`, `mipOptOut`, `tag`
- REST methods: `audio().generate(request)` and `audio().withRawResponse().generate(request)`
- WSS connect options: `model`, `encoding`, `sampleRate`, `mipOptOut`
- WSS send methods: `sendText(...)`, `sendFlush(...)`, `sendClear(...)`, `sendClose(...)`
- WSS handlers: `onSpeakV1Audio`, `onMetadata`, `onFlushed`, `onCleared`, `onWarning`, plus generic connection/error hooks

## API reference (layered)

1. **In-repo source of truth**: `src/main/java/com/deepgram/resources/speak/v1/` and `examples/speak/`. `reference.md` is not present in this checkout.
2. **Canonical OpenAPI (REST)**: https://developers.deepgram.com/openapi.yaml
3. **Canonical AsyncAPI (WSS)**: https://developers.deepgram.com/asyncapi.yaml
4. **Context7**: `/llmstxt/developers_deepgram_llms_txt`
5. **Product docs**:
   - https://developers.deepgram.com/reference/text-to-speech/speak-request
   - https://developers.deepgram.com/reference/text-to-speech/speak-streaming
   - https://developers.deepgram.com/docs/tts-models

## Gotchas

1. **REST returns audio bytes as `InputStream`.** Save or consume it; do not try to deserialize JSON.
2. **Flush before close on WebSocket.** The example sends `Flush` before `Close` so the tail of the audio is not lost.
3. **Streaming audio arrives as binary `ByteString`.** Convert to bytes before writing or playback.
4. **WebSocket options are narrower than REST.** `container` and `bitRate` are REST request fields, not WebSocket connect options in this checkout.
5. **TTS defaults are minimal unless you set them.** The example only sets `text`; pick an explicit model/encoding when output format matters.
6. **There is no Java `TextBuilder` helper in this repo.** That Python helper does not exist here.
7. **Async REST is `CompletableFuture<InputStream>`.** You still need to close the stream after the future resolves.

## Example files in this repo

- `examples/speak/TextToSpeech.java`
- `examples/speak/StreamingTts.java`
- `examples/agent/ProviderCombinations.java` — shows Aura model selection inside Agent configs

## Central product skills

For cross-language Deepgram product knowledge — the consolidated API reference, documentation finder, focused runnable recipes, third-party integration examples, and MCP setup — install the central skills:

```bash
npx skills add deepgram/skills
```

This SDK ships language-idiomatic code skills; `deepgram/skills` ships cross-language product knowledge (see `api`, `docs`, `recipes`, `examples`, `starters`, `setup-mcp`).

Wersje

W bazie nie ma innych skilli o nazwie deepgram-java-text-to-speech.

Migawka bazy z 28.10.2026 · wersja paczki fa0ed5bf86d5 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100deepgram-js-text-to-speech
    Obsługuje w JavaScripcie i TypeScripcie Deepgram Text-to-Speech v1 (/v1/speak): jednorazowa synteza mowy przez REST i strumieniowanie przez WebSocket.
  • 100deepgram-python-text-to-speech
    Obsługuje w Pythonie Deepgram Text-to-Speech v1 (/v1/speak): jednorazowa synteza przez REST, strumieniowanie przez WebSocket oraz składanie tekstu pomocnikiem TextBuilder.
  • 100deepgram-go-text-to-speech
    Syntezuje w Go dźwięk przez Speak v1 REST lub Speak WebSocket w SDK Deepgram.
  • 100deepgram-rust-text-to-speech
    Wdraża w SDK Rust Deepgram text-to-speech: wybór modeli Aura i Flux TTS, flagi funkcji speak, zapis do pliku lub strumienia bajtów oraz strumieniowe uchwyty WebSocket Aura i Flux.
  • 100deepgram-dotnet-text-to-speech
    Obsługuje w C# syntezę mowy Deepgram Text-to-Speech: klient REST z ToStream i ToFile oraz klient WebSocket z Connect, SpeakWithText, Flush i strumieniowymi zdarzeniami AudioResponse.
  • 100deepgram-java-speech-to-text
    Obsługuje w Javie Deepgram Speech-to-Text v1 (/v1/listen) dla transkrypcji nagrań i na żywo, przez REST (transcribeUrl i transcribeFile) oraz WebSocket (v1WebSocket).

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.