From ac021184ddd165847661dbd4898fc864d14aee8e Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 12 Nov 2026 11:48:34 +0000 Subject: [PATCH 1/8] chore: initialize SDK regeneration branch From 9708264ac425249ecd9ef505f99c666f92d35373 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 12 Nov 2026 11:49:13 +0000 Subject: [PATCH 2/8] chore: unfreeze files pending regen --- .fernignore | 62 +- .../com/deepgram/core/ClientOptions.java.bak | 409 ++++ .../ReconnectingWebSocketListener.java.bak | 622 ++++++ .../v1/types/AgentV1AgentAudioDone.java.bak | 83 + .../v1/types/AgentV1ConversationText.java.bak | 317 +++ .../v1/types/AgentV1ForceEndTurn.java.bak | 83 + .../agent/v1/types/AgentV1KeepAlive.java.bak | 83 + .../v1/types/AgentV1ListenUpdated.java.bak | 83 + .../v1/types/AgentV1PromptUpdated.java.bak | 83 + ...ettingsAgentContextListenProvider.java.bak | 224 ++ ...gentV1SettingsAgentListenProvider.java.bak | 224 ++ .../v1/types/AgentV1SettingsApplied.java.bak | 83 + .../v1/types/AgentV1SpeakUpdated.java.bak | 83 + .../v1/types/AgentV1ThinkLiveUpdated.java.bak | 83 + .../v1/types/AgentV1ThinkUpdated.java.bak | 83 + ...AgentV1UpdateListenListenProvider.java.bak | 224 ++ .../types/AgentV1UserStartedSpeaking.java.bak | 83 + .../v1/websocket/V1WebSocketClient.java.bak | 981 +++++++++ .../requests/ListenV1RequestUrl.java.bak | 1932 +++++++++++++++++ ...MediaTranscribeRequestOctetStream.java.bak | 1931 ++++++++++++++++ .../v1/websocket/V1ConnectOptions.java.bak | 1129 ++++++++++ .../v1/websocket/V1WebSocketClient.java.bak | 650 ++++++ .../v2/types/ListenV2CloseStream.java.bak | 83 + .../v2/types/ListenV2ForceEndTurn.java.bak | 83 + .../v2/websocket/V2WebSocketClient.java.bak | 563 +++++ .../v1/websocket/V1WebSocketClient.java.bak | 467 ++++ .../speak/v2/types/SpeakV2Close.java.bak | 83 + .../SpeakV2ConfigureFailureCode.java.bak | 121 ++ .../speak/v2/types/SpeakV2Flush.java.bak | 83 + .../v2/websocket/V2WebSocketClient.java.bak | 630 ++++++ .../com/deepgram/types/DeepgramModel.java.bak | 1081 +++++++++ .../types/ThinkSettingsV1Provider.java.bak | 458 ++++ 32 files changed, 13156 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/deepgram/core/ClientOptions.java.bak create mode 100644 src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak create mode 100644 src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak create mode 100644 src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak create mode 100644 src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak create mode 100644 src/main/java/com/deepgram/types/DeepgramModel.java.bak create mode 100644 src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak diff --git a/.fernignore b/.fernignore index b7b416f..042e465 100644 --- a/.fernignore +++ b/.fernignore @@ -16,7 +16,7 @@ src/main/java/com/deepgram/AsyncDeepgramClientBuilder.java # Fern regen overwrites these with incorrect SDK names and strips the markers. # Fern 4.22.1 closes tracked WebSockets before SDK-owned OkHttp resources; retain that lifecycle behavior while # reapplying only these headers. -src/main/java/com/deepgram/core/ClientOptions.java +src/main/java/com/deepgram/core/ClientOptions.java.bak # Transport abstraction (pluggable transport for SageMaker, etc.) src/main/java/com/deepgram/core/transport/ @@ -30,7 +30,7 @@ src/main/java/com/deepgram/resources/listen/v1/websocket/ListenV1ConfigureFailur # Bug fixes for maxRetries(0) semantics ("connect once, don't retry") and a # configurable connectionTimeoutMs on ReconnectOptions (was hardcoded 4000ms). # Pull this back out once the fixes are upstreamed into the Fern generator. -src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java +src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak # Forward-compat patch: Fern's generated dispatcher routes any unrecognized message # type to the error handler ("Update your SDK version..."), which makes benign new @@ -40,8 +40,8 @@ src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java # NOTE: the listen v2 and speak v2 clients below also carry the streaming query-param patches # (multi-value serialization + the additionalProperties escape hatch) documented lower down — # keep them frozen until those fixes are upstreamed too. -src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java -src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java +src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak +src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak # Streaming query-param patches on the generated WS connect() builders. Two fixes: # (1) Multi-value serialization: array-valued params (listen: keyterm, keywords, replace, search, @@ -55,25 +55,25 @@ src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java # listen v2 and speak v2 clients are frozen above; freeze the listen v1 and speak v1 clients here too # so the fixes survive regen. Re-apply after regen; unfreeze once the generator emits array params as # repeats and serializes additionalProperties on the WS connect path (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java -src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak # Agent V1 forwards raw frames through onMessage(String); suppress generic errors only when a raw # handler is registered, otherwise retain legacy onError delivery for unknown control frames. -src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak # Source and binary compatibility for third-party implementations of generated builder stages. # Generated concrete builders override languageHint; default interface methods preserve existing custom implementations. -src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java -src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java -src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java +src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak +src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak +src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak # Preserve existing AgentV1ConversationText builder implementations after adding conversationalBehavior. -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak # Fern now generates the distinct Deepgram Think provider and model types. Keep the union frozen only to preserve the # default Visitor method for source and binary compatibility with callers compiled before the Deepgram provider existed. -src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java +src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak # Restores the FLUX_RENEE_EN constant that generator 4.18.0 dropped. The voice is live: # POST /v2/speak?model=flux-renee-en returns 200 with valid audio, and the name resolves in the @@ -85,26 +85,26 @@ src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java # changes -- 4.18.0 alone added 25 constants. On the next regen do NOT restore the .bak wholesale: # diff it against the newly generated file, carry forward every new voice, and re-apply only the # FLUX_RENEE_EN touchpoints (constant, Value enum, visit() case, valueOf() case, Visitor method). -src/main/java/com/deepgram/types/DeepgramModel.java +src/main/java/com/deepgram/types/DeepgramModel.java.bak # Manual equals/hashCode contract fix: Fern generates equals() (all instances equal) but no # hashCode() for fields-less message types, violating the Object contract. We add a consistent # hashCode() to each. Unfreeze and drop these patches once the generator emits a matching # equals/hashCode pair for fields-less types (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak # Union default-variant fix (STOPGAP). The agent listen-provider unions declare `version` as an # optional discriminator, so a provider payload without it is valid (and is what 0.7.x emits). Fern @@ -113,13 +113,13 @@ src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # {"provider":null}, silently dropping the caller's provider on the wire. Patched to # defaultImpl = V2Value on each. Guarded by AgentSettingsProviderDefaultTest. Unfreeze and drop once # the generator stops defaulting unions to the empty _UnknownValue (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak # Preserve binary-compatible Visitor implementations from before this generated enum added # CONTROL_COMBINATION_INVALID. The default method routes old visitors through visitUnknown. -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak # Build and project configuration build.gradle diff --git a/src/main/java/com/deepgram/core/ClientOptions.java.bak b/src/main/java/com/deepgram/core/ClientOptions.java.bak new file mode 100644 index 0000000..8369b24 --- /dev/null +++ b/src/main/java/com/deepgram/core/ClientOptions.java.bak @@ -0,0 +1,409 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.core; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; +import okhttp3.OkHttpClient; + +public final class ClientOptions { + private final Environment environment; + + private final Map headers; + + private final Map> headerSuppliers; + + private final OkHttpClient httpClient; + + private final boolean ownsHttpClient; + + private final AtomicBoolean closed; + + private final Set openWebSockets; + + private final int timeout; + + private final int maxRetries; + + private final Optional initialRetryDelayMillis; + + private final Optional maxRetryDelayMillis; + + private final Optional retryJitterFactor; + + private final Optional webSocketFactory; + + private final Optional logging; + + private ClientOptions( + Environment environment, + Map headers, + Map> headerSuppliers, + OkHttpClient httpClient, + boolean ownsHttpClient, + AtomicBoolean closed, + Set openWebSockets, + int timeout, + int maxRetries, + Optional initialRetryDelayMillis, + Optional maxRetryDelayMillis, + Optional retryJitterFactor, + Optional webSocketFactory, + Optional logging) { + this.environment = environment; + this.headers = new HashMap<>(); + this.headers.putAll(headers); + this.headers.putAll(new HashMap() { + { + put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.4"); // x-release-please-version + put("X-Fern-Language", "JAVA"); + put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); + put("X-Fern-SDK-Version", "0.11.4"); // x-release-please-version + } + }); + this.headerSuppliers = headerSuppliers; + this.httpClient = httpClient; + this.ownsHttpClient = ownsHttpClient; + this.closed = closed; + this.openWebSockets = openWebSockets; + this.timeout = timeout; + this.maxRetries = maxRetries; + this.initialRetryDelayMillis = initialRetryDelayMillis; + this.maxRetryDelayMillis = maxRetryDelayMillis; + this.retryJitterFactor = retryJitterFactor; + this.webSocketFactory = webSocketFactory; + this.logging = logging; + } + + public Environment environment() { + return this.environment; + } + + public Map headers(RequestOptions requestOptions) { + Map values = new HashMap<>(this.headers); + headerSuppliers.forEach((key, supplier) -> { + values.put(key, supplier.get()); + }); + if (requestOptions != null) { + values.putAll(requestOptions.getHeaders()); + } + return values; + } + + public int timeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.timeout; + } + return requestOptions.getTimeout().orElse(this.timeout); + } + + public OkHttpClient httpClient() { + return this.httpClient; + } + + public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { + if (requestOptions == null) { + return this.httpClient; + } + return this.httpClient + .newBuilder() + .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .build(); + } + + public int maxRetries() { + return this.maxRetries; + } + + public Optional initialRetryDelayMillis() { + return this.initialRetryDelayMillis; + } + + public Optional maxRetryDelayMillis() { + return this.maxRetryDelayMillis; + } + + public Optional retryJitterFactor() { + return this.retryJitterFactor; + } + + /** + * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's + * dispatcher executor and evicts its connection pool when this client created that + * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the + * caller owns its lifecycle. + *

+ * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later + * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous + * requests may still run. Options derived from this one via + * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either + * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method + * more than once has no further effect. + *

+ * WebSocket clients created from this client that are still connected are disconnected + * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the + * dispatcher goes away. Any WebSocket connect or reconnect attempted afterwards fails with + * an {@code IllegalStateException} explaining that the client has been closed. + */ + public void close() { + if (!this.closed.compareAndSet(false, true)) { + return; + } + for (AutoCloseable webSocket : new ArrayList<>(this.openWebSockets)) { + try { + webSocket.close(); + } catch (Exception e) { + // best effort; keep closing the remaining sockets and the HTTP client + } + } + this.openWebSockets.clear(); + if (!this.ownsHttpClient) { + return; + } + this.httpClient.dispatcher().executorService().shutdown(); + this.httpClient.connectionPool().evictAll(); + } + + /** + * Returns whether {@link #close()} has been called on this client. + */ + public boolean isClosed() { + return this.closed.get(); + } + + /** + * Tracks a connected WebSocket client so that {@link #close()} disconnects it. + * + * @throws IllegalStateException if this client has already been closed + */ + public void registerWebSocket(AutoCloseable webSocket) { + this.openWebSockets.add(webSocket); + if (this.closed.get()) { + this.openWebSockets.remove(webSocket); + throw new IllegalStateException("root client has been closed"); + } + } + + /** + * Stops tracking a WebSocket client that has been disconnected. + */ + public void unregisterWebSocket(AutoCloseable webSocket) { + this.openWebSockets.remove(webSocket); + } + + public Optional webSocketFactory() { + return this.webSocketFactory; + } + + public Optional logging() { + return this.logging; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Environment environment; + + private final Map headers = new HashMap<>(); + + private final Map> headerSuppliers = new HashMap<>(); + + private int maxRetries = 2; + + private Optional initialRetryDelayMillis = Optional.empty(); + + private Optional maxRetryDelayMillis = Optional.empty(); + + private Optional retryJitterFactor = Optional.empty(); + + private Optional timeout = Optional.empty(); + + private OkHttpClient httpClient = null; + + private boolean ownsHttpClient = true; + + private AtomicBoolean closed; + + private Set openWebSockets; + + private Optional logging = Optional.empty(); + + private Optional webSocketFactory = Optional.empty(); + + public Builder environment(Environment environment) { + this.environment = environment; + return this; + } + + public Builder addHeader(String key, String value) { + if (value != null) { + this.headers.put(key, value); + } + return this; + } + + public Builder addHeader(String key, Supplier value) { + this.headerSuppliers.put(key, value); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(int timeout) { + this.timeout = Optional.of(timeout); + return this; + } + + /** + * Override the timeout in seconds. Defaults to 60 seconds. + */ + public Builder timeout(Optional timeout) { + this.timeout = timeout; + return this; + } + + /** + * Override the maximum number of retries. Defaults to 2 retries. + */ + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + /** + * Override the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. + */ + public Builder initialRetryDelayMillis(long initialRetryDelayMillis) { + this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); + return this; + } + + /** + * Override the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. + */ + public Builder maxRetryDelayMillis(long maxRetryDelayMillis) { + this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); + return this; + } + + /** + * Override the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. + */ + public Builder retryJitterFactor(double retryJitterFactor) { + this.retryJitterFactor = Optional.of(retryJitterFactor); + return this; + } + + /** + * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle: + * close() will not shut down its dispatcher executor or evict its connection pool. + */ + public Builder httpClient(OkHttpClient httpClient) { + this.httpClient = httpClient; + this.ownsHttpClient = httpClient == null; + return this; + } + + /** + * Set a custom WebSocketFactory for creating WebSocket connections. + */ + public Builder webSocketFactory(WebSocketFactory webSocketFactory) { + this.webSocketFactory = Optional.of(webSocketFactory); + return this; + } + + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public Builder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + + public ClientOptions build() { + OkHttpClient.Builder httpClientBuilder = + this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); + + if (this.httpClient != null) { + timeout.ifPresent(timeout -> httpClientBuilder + .callTimeout(timeout, TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS)); + } else { + httpClientBuilder + .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) + .connectTimeout(0, TimeUnit.SECONDS) + .writeTimeout(0, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.SECONDS) + .addInterceptor(new RetryInterceptor( + this.maxRetries, + this.initialRetryDelayMillis, + this.maxRetryDelayMillis, + this.retryJitterFactor)); + } + + Logger logger = Logger.from(this.logging); + httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); + httpClientBuilder.addInterceptor(new ResponseDecompressionInterceptor()); + + this.httpClient = httpClientBuilder.build(); + this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); + + AtomicBoolean closedToUse = this.closed != null ? this.closed : new AtomicBoolean(false); + Set openWebSocketsToUse = + this.openWebSockets != null ? this.openWebSockets : ConcurrentHashMap.newKeySet(); + + return new ClientOptions( + environment, + headers, + headerSuppliers, + httpClient, + this.ownsHttpClient, + closedToUse, + openWebSocketsToUse, + this.timeout.get(), + this.maxRetries, + this.initialRetryDelayMillis, + this.maxRetryDelayMillis, + this.retryJitterFactor, + this.webSocketFactory, + this.logging); + } + + /** + * Create a new Builder initialized with values from an existing ClientOptions + */ + public static Builder from(ClientOptions clientOptions) { + Builder builder = new Builder(); + builder.environment = clientOptions.environment(); + builder.timeout = Optional.of(clientOptions.timeout(null)); + builder.httpClient = clientOptions.httpClient(); + builder.ownsHttpClient = clientOptions.ownsHttpClient; + builder.closed = clientOptions.closed; + builder.openWebSockets = clientOptions.openWebSockets; + builder.headers.putAll(clientOptions.headers); + builder.headerSuppliers.putAll(clientOptions.headerSuppliers); + builder.maxRetries = clientOptions.maxRetries(); + builder.initialRetryDelayMillis = clientOptions.initialRetryDelayMillis(); + builder.maxRetryDelayMillis = clientOptions.maxRetryDelayMillis(); + builder.retryJitterFactor = clientOptions.retryJitterFactor(); + builder.logging = clientOptions.logging(); + return builder; + } + } +} diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak new file mode 100644 index 0000000..b51aacc --- /dev/null +++ b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak @@ -0,0 +1,622 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.core; + +import static java.util.concurrent.TimeUnit.*; + +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; +import java.util.function.Supplier; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import okio.ByteString; + +/** + * WebSocketListener with automatic reconnection, exponential backoff, and message queuing. + * Provides production-ready resilience for WebSocket connections. + */ +public abstract class ReconnectingWebSocketListener extends WebSocketListener { + private volatile ReconnectOptions activeOptions; + + private final int maxEnqueuedMessages; + + private final AtomicInteger retryCount = new AtomicInteger(0); + + private final AtomicBoolean connectLock = new AtomicBoolean(false); + + private final AtomicBoolean shouldReconnect = new AtomicBoolean(true); + + protected volatile WebSocket webSocket; + + private volatile long connectionEstablishedTime = 0L; + + private final ConcurrentLinkedQueue messageQueue = new ConcurrentLinkedQueue<>(); + + private final ConcurrentLinkedQueue binaryMessageQueue = new ConcurrentLinkedQueue<>(); + + private final ScheduledExecutorService reconnectExecutor = Executors.newSingleThreadScheduledExecutor(); + + private final Supplier connectionSupplier; + + private final BooleanSupplier closedCheck; + + /** + * Creates a new reconnecting WebSocket listener. + * + * @param options Reconnection configuration options + * @param connectionSupplier Supplier that creates new WebSocket connections + */ + public ReconnectingWebSocketListener( + ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier) { + this(options, connectionSupplier, () -> false); + } + + /** + * Creates a new reconnecting WebSocket listener. + * + * @param options Reconnection configuration options + * @param connectionSupplier Supplier that creates new WebSocket connections + * @param closedCheck Returns true once the owning client has been closed; connect and + * reconnect attempts made after that point fail with an {@link IllegalStateException} + * instead of being retried + */ + public ReconnectingWebSocketListener( + ReconnectingWebSocketListener.ReconnectOptions options, + Supplier connectionSupplier, + BooleanSupplier closedCheck) { + this.activeOptions = options; + this.maxEnqueuedMessages = options.maxEnqueuedMessages; + this.connectionSupplier = connectionSupplier; + this.closedCheck = closedCheck; + } + + /** + * Replaces option-derived reconnect settings without rebuilding generated clients. + * + * @param options replacement options; {@code null} is a no-op + */ + public void applyOptionsOverride(ReconnectOptions options) { + if (options != null) { + this.activeOptions = options; + } + } + + /** + * Initiates a WebSocket connection with automatic reconnection enabled. + * + * Connection behavior: + * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) + * - Thread-safe via atomic lock (returns immediately if connection in progress) + * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry + * + * Error handling: + * - TimeoutException: Includes retry attempt context + * - InterruptedException: Preserves thread interruption status + * - ExecutionException: Extracts actual cause and adds context + * - Owning client closed: reports an IllegalStateException once and stops reconnecting + */ + public void connect() { + if (!connectLock.compareAndSet(false, true)) { + return; + } + if (closedCheck.getAsBoolean()) { + shouldReconnect.set(false); + connectLock.set(false); + onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); + return; + } + ReconnectOptions options = this.activeOptions; + if (retryCount.get() > options.maxRetries) { + connectLock.set(false); + return; + } + try { + CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); + try { + webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); + } catch (TimeoutException e) { + connectionFuture.cancel(true); + TimeoutException timeoutError = + new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs + + " milliseconds" + + (retryCount.get() > 0 + ? " (retry attempt #" + retryCount.get() + ")" + : " (initial connection attempt)")); + onWebSocketFailure(null, timeoutError, null); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } catch (InterruptedException e) { + connectionFuture.cancel(true); + Thread.currentThread().interrupt(); + InterruptedException interruptError = new InterruptedException("WebSocket connection interrupted" + + (retryCount.get() > 0 + ? " during retry attempt #" + retryCount.get() + : " during initial connection")); + interruptError.initCause(e); + onWebSocketFailure(null, interruptError, null); + } catch (ExecutionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + String context = retryCount.get() > 0 + ? "WebSocket connection failed during retry attempt #" + retryCount.get() + : "WebSocket connection failed during initial attempt"; + RuntimeException wrappedException = new RuntimeException( + context + ": " + cause.getClass().getSimpleName() + ": " + cause.getMessage()); + wrappedException.initCause(cause); + onWebSocketFailure(null, wrappedException, null); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } + } finally { + connectLock.set(false); + } + } + + /** + * Disconnects the WebSocket and disables automatic reconnection. + * + * This method: + * - Disables automatic reconnection + * - Clears queued messages to prevent stale data + * - Closes the WebSocket with standard close code 1000 + * - Properly shuts down the reconnect executor to prevent thread leaks + * - Waits up to 5 seconds for executor termination + */ + public void disconnect() { + shouldReconnect.set(false); + messageQueue.clear(); + binaryMessageQueue.clear(); + if (webSocket != null) { + webSocket.close(1000, "Client disconnecting"); + } + reconnectExecutor.shutdown(); + try { + if (!reconnectExecutor.awaitTermination(5, SECONDS)) { + reconnectExecutor.shutdownNow(); + } + } catch (InterruptedException e) { + reconnectExecutor.shutdownNow(); + Thread.currentThread().interrupt(); + } + } + + /** + * Sends a message or queues it if not connected. + * + * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). + * + * Behavior: + * - If connected: Attempts direct send, queues if buffer full + * - If disconnected: Queues message up to maxEnqueuedMessages limit + * - If queue full: Message is dropped + * + * @param message The message to send + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean send(String message) { + return send(message, null); + } + + /** + * Sends a message or queues it if not connected, exposing the accepting socket. + * + * Behaves like {@link #send(String)}, but additionally invokes {@code onSent} with the + * WebSocket that accepted the message. The callback is only invoked when the message was + * sent directly, never when it was queued or dropped. This lets callers associate a + * protocol-level message with the specific connection it was delivered on, e.g. to decide + * in {@link #shouldReconnectAfterClose(WebSocket, int, String)} whether a later close of that same + * connection was expected. + * + * @param message The message to send + * @param onSent Callback receiving the WebSocket that accepted the message, or null + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean send(String message, Consumer onSent) { + WebSocket ws = webSocket; + if (ws != null) { + boolean sent = ws.send(message); + if (sent && onSent != null) { + onSent.accept(ws); + } + if (!sent && messageQueue.size() < maxEnqueuedMessages) { + messageQueue.offer(message); + return false; + } + return sent; + } else { + if (messageQueue.size() < maxEnqueuedMessages) { + messageQueue.offer(message); + return false; + } + return false; + } + } + + /** + * Sends binary data or queues it if not connected. + * + * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). + * + * Behavior: + * - If connected: Attempts direct send, queues if buffer full + * - If disconnected: Queues data up to maxEnqueuedMessages limit + * - If queue full: Data is dropped + * + * @param data The binary data to send + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean sendBinary(ByteString data) { + return sendBinary(data, null); + } + + /** + * Sends binary data or queues it if not connected, exposing the accepting socket. + * + * Behaves like {@link #sendBinary(ByteString)}, but additionally invokes {@code onSent} with + * the WebSocket that accepted the data. The callback is only invoked when the data was sent + * directly, never when it was queued or dropped. + * + * @param data The binary data to send + * @param onSent Callback receiving the WebSocket that accepted the data, or null + * @return true if sent immediately, false if queued or dropped + */ + public synchronized boolean sendBinary(ByteString data, Consumer onSent) { + WebSocket ws = webSocket; + if (ws != null) { + boolean sent = ws.send(data); + if (sent && onSent != null) { + onSent.accept(ws); + } + if (!sent && binaryMessageQueue.size() < maxEnqueuedMessages) { + binaryMessageQueue.offer(data); + return false; + } + return sent; + } else { + if (binaryMessageQueue.size() < maxEnqueuedMessages) { + binaryMessageQueue.offer(data); + return false; + } + return false; + } + } + + /** + * Gets the current WebSocket instance. + * Thread-safe method to access the WebSocket connection. + * @return the WebSocket or null if not connected + */ + public WebSocket getWebSocket() { + return webSocket; + } + + /** + * @hidden + */ + @Override + public void onOpen(WebSocket webSocket, Response response) { + this.webSocket = webSocket; + connectionEstablishedTime = System.currentTimeMillis(); + retryCount.set(0); + flushMessageQueue(); + onWebSocketOpen(webSocket, response); + } + + @Override + public void onMessage(WebSocket webSocket, String text) { + onWebSocketMessage(webSocket, text); + } + + @Override + public void onMessage(WebSocket webSocket, ByteString bytes) { + onWebSocketBinaryMessage(webSocket, bytes); + } + + /** + * @hidden + */ + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + this.webSocket = null; + long uptime = 0L; + if (connectionEstablishedTime > 0) { + uptime = System.currentTimeMillis() - connectionEstablishedTime; + if (uptime >= 5000) { + retryCount.set(0); + } + } + connectionEstablishedTime = 0L; + Throwable enhancedError = t; + if (t != null) { + String errorContext = "WebSocket connection failed"; + if (uptime > 0) { + errorContext += " after " + (uptime / 1000) + " seconds"; + } + if (response != null) { + errorContext += " with HTTP " + response.code() + " " + response.message(); + } + enhancedError = + new RuntimeException(errorContext + ": " + t.getClass().getSimpleName() + ": " + t.getMessage()); + enhancedError.initCause(t); + } + onWebSocketFailure(webSocket, enhancedError, response); + if (shouldReconnect.get()) { + scheduleReconnect(); + } + } + + /** + * Acknowledges a peer-initiated close so OkHttp can complete the close handshake and + * invoke {@link #onClosed(WebSocket, int, String)}. + * + * Code 1005 is a local "no status received" sentinel reported when the peer sent an empty + * close frame. It is not a valid code to put on the wire, so it is acknowledged with + * the normal closure code 1000 instead. + * + * @hidden + */ + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + webSocket.close(code == 1005 ? 1000 : code, reason); + } + + /** + * @hidden + */ + @Override + public void onClosed(WebSocket webSocket, int code, String reason) { + this.webSocket = null; + if (connectionEstablishedTime > 0) { + long uptime = System.currentTimeMillis() - connectionEstablishedTime; + if (uptime >= 5000) { + retryCount.set(0); + } + } + connectionEstablishedTime = 0L; + onWebSocketClosed(webSocket, code, reason); + if (shouldReconnect.get() && shouldReconnectAfterClose(webSocket, code, reason)) { + scheduleReconnect(); + } + } + + /** + * Decides whether a completed close handshake should trigger a reconnect. + * + * Only consulted when reconnection has not been disabled via {@link #disconnect()}. + * The default treats normal closure (1000) as terminal and reconnects on any + * other code. Subclasses can override this when protocol context establishes that a + * particular close is terminal, for example a no-status close following a message that + * ends the stream. + * + * @param webSocket The WebSocket that was closed + * @param code The close status code reported by OkHttp + * @param reason The close reason sent by the peer, or an empty string + * @return true to schedule a reconnect, false to stay disconnected + */ + protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { + return code != 1000; + } + + /** + * Calculates the next reconnection delay using exponential backoff. + * + * Uses 0-based retry count where: + * - 0 = initial connection (not used by this method) + * - 1 = first retry (returns minReconnectionDelayMs) + * - 2+ = exponential backoff up to maxReconnectionDelayMs + */ + private long getNextDelay() { + if (retryCount.get() == 1) { + return activeOptions.minReconnectionDelayMs; + } + ReconnectOptions options = this.activeOptions; + long delay = (long) + (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); + return Math.min(delay, options.maxReconnectionDelayMs); + } + + /** + * Schedules a reconnection attempt with appropriate delay. + * Increments retry count and uses exponential backoff. + * Does nothing once the owning client has been closed. + */ + private void scheduleReconnect() { + if (closedCheck.getAsBoolean()) { + shouldReconnect.set(false); + return; + } + retryCount.incrementAndGet(); + long delay = getNextDelay(); + reconnectExecutor.schedule(this::connect, delay, MILLISECONDS); + } + + /** + * Sends all queued messages after reconnection. + * + * Thread-safe: Synchronized to prevent race conditions with send() method. + * + * Algorithm: + * 1. Drains queue into temporary list to avoid holding lock during sends + * 2. Attempts to send each message in order + * 3. If any send fails, re-queues that message and all subsequent messages + * 4. Preserves message ordering during re-queueing + * 5. Repeats for binary message queue + */ + private synchronized void flushMessageQueue() { + WebSocket ws = webSocket; + if (ws != null) { + ArrayList tempQueue = new ArrayList<>(); + String message; + while ((message = messageQueue.poll()) != null) { + tempQueue.add(message); + } + for (int i = 0; i < tempQueue.size(); i++) { + if (!ws.send(tempQueue.get(i))) { + for (int j = i; j < tempQueue.size(); j++) { + messageQueue.offer(tempQueue.get(j)); + } + break; + } + } + ArrayList tempBinaryQueue = new ArrayList<>(); + ByteString binaryMsg; + while ((binaryMsg = binaryMessageQueue.poll()) != null) { + tempBinaryQueue.add(binaryMsg); + } + for (int i = 0; i < tempBinaryQueue.size(); i++) { + if (!ws.send(tempBinaryQueue.get(i))) { + for (int j = i; j < tempBinaryQueue.size(); j++) { + binaryMessageQueue.offer(tempBinaryQueue.get(j)); + } + break; + } + } + } + } + + protected abstract void onWebSocketOpen(WebSocket webSocket, Response response); + + protected abstract void onWebSocketMessage(WebSocket webSocket, String text); + + protected abstract void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes); + + protected abstract void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response); + + protected abstract void onWebSocketClosed(WebSocket webSocket, int code, String reason); + + /** + * Configuration options for automatic reconnection. + */ + public static final class ReconnectOptions { + public final long minReconnectionDelayMs; + + public final long maxReconnectionDelayMs; + + public final double reconnectionDelayGrowFactor; + + public final int maxRetries; + + public final int maxEnqueuedMessages; + + public final long connectionTimeoutMs; + + private ReconnectOptions(Builder builder) { + this.minReconnectionDelayMs = builder.minReconnectionDelayMs; + this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; + this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; + this.maxRetries = builder.maxRetries; + this.maxEnqueuedMessages = builder.maxEnqueuedMessages; + this.connectionTimeoutMs = builder.connectionTimeoutMs; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private long minReconnectionDelayMs; + + private long maxReconnectionDelayMs; + + private double reconnectionDelayGrowFactor; + + private int maxRetries; + + private int maxEnqueuedMessages; + + private long connectionTimeoutMs; + + public Builder() { + this.minReconnectionDelayMs = 1000; + this.maxReconnectionDelayMs = 10000; + this.reconnectionDelayGrowFactor = 1.3; + this.maxRetries = 2147483647; + this.maxEnqueuedMessages = 1000; + this.connectionTimeoutMs = 4000; + } + + public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { + this.minReconnectionDelayMs = minReconnectionDelayMs; + return this; + } + + public Builder maxReconnectionDelayMs(long maxReconnectionDelayMs) { + this.maxReconnectionDelayMs = maxReconnectionDelayMs; + return this; + } + + public Builder reconnectionDelayGrowFactor(double reconnectionDelayGrowFactor) { + this.reconnectionDelayGrowFactor = reconnectionDelayGrowFactor; + return this; + } + + public Builder maxRetries(int maxRetries) { + this.maxRetries = maxRetries; + return this; + } + + public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { + this.maxEnqueuedMessages = maxEnqueuedMessages; + return this; + } + + /** + * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. + */ + public Builder connectionTimeoutMs(long connectionTimeoutMs) { + this.connectionTimeoutMs = connectionTimeoutMs; + return this; + } + + /** + * Builds the ReconnectOptions with validation. + * + * Validates that: + * - All delay values are positive + * - minReconnectionDelayMs <= maxReconnectionDelayMs + * - reconnectionDelayGrowFactor >= 1.0 + * - maxRetries and maxEnqueuedMessages are non-negative + * + * @return The validated ReconnectOptions instance + * @throws IllegalArgumentException if configuration is invalid + */ + public ReconnectOptions build() { + if (minReconnectionDelayMs <= 0) { + throw new IllegalArgumentException("minReconnectionDelayMs must be positive"); + } + if (maxReconnectionDelayMs <= 0) { + throw new IllegalArgumentException("maxReconnectionDelayMs must be positive"); + } + if (minReconnectionDelayMs > maxReconnectionDelayMs) { + throw new IllegalArgumentException("minReconnectionDelayMs (" + minReconnectionDelayMs + + ") must not exceed maxReconnectionDelayMs (" + maxReconnectionDelayMs + ")"); + } + if (reconnectionDelayGrowFactor < 1.0) { + throw new IllegalArgumentException("reconnectionDelayGrowFactor must be >= 1.0"); + } + if (maxRetries < 0) { + throw new IllegalArgumentException("maxRetries must be non-negative"); + } + if (maxEnqueuedMessages < 0) { + throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); + } + if (connectionTimeoutMs <= 0) { + throw new IllegalArgumentException("connectionTimeoutMs must be positive"); + } + return new ReconnectOptions(this); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak new file mode 100644 index 0000000..5962f4b --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1AgentAudioDone.Builder.class) +public final class AgentV1AgentAudioDone { + private final Map additionalProperties; + + private AgentV1AgentAudioDone(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier indicating the agent has finished sending audio + */ + @JsonProperty("type") + public String getType() { + return "AgentAudioDone"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1AgentAudioDone; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1AgentAudioDone other) { + return this; + } + + public AgentV1AgentAudioDone build() { + return new AgentV1AgentAudioDone(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak new file mode 100644 index 0000000..ef4f56a --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak @@ -0,0 +1,317 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ConversationText.Builder.class) +public final class AgentV1ConversationText { + private final AgentV1ConversationTextRole role; + + private final String content; + + private final AgentV1ConversationTextConversationalBehavior conversationalBehavior; + + private final Optional> languagesHinted; + + private final Optional> languages; + + private final Map additionalProperties; + + private AgentV1ConversationText( + AgentV1ConversationTextRole role, + String content, + AgentV1ConversationTextConversationalBehavior conversationalBehavior, + Optional> languagesHinted, + Optional> languages, + Map additionalProperties) { + this.role = role; + this.content = content; + this.conversationalBehavior = conversationalBehavior; + this.languagesHinted = languagesHinted; + this.languages = languages; + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for conversation text + */ + @JsonProperty("type") + public String getType() { + return "ConversationText"; + } + + /** + * @return Identifies who spoke the statement + */ + @JsonProperty("role") + public AgentV1ConversationTextRole getRole() { + return role; + } + + /** + * @return The actual statement that was spoken + */ + @JsonProperty("content") + public String getContent() { + return content; + } + + /** + * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off + */ + @JsonProperty("conversational_behavior") + public Optional getConversationalBehavior() { + return Optional.of(conversationalBehavior); + } + + /** + * @return The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi. + */ + @JsonProperty("languages_hinted") + public Optional> getLanguagesHinted() { + return languagesHinted; + } + + /** + * @return Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi. + */ + @JsonProperty("languages") + public Optional> getLanguages() { + return languages; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ConversationText && equalTo((AgentV1ConversationText) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AgentV1ConversationText other) { + return role.equals(other.role) + && content.equals(other.content) + && conversationalBehavior.equals(other.conversationalBehavior) + && languagesHinted.equals(other.languagesHinted) + && languages.equals(other.languages); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.role, this.content, this.conversationalBehavior, this.languagesHinted, this.languages); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static RoleStage builder() { + return new Builder(); + } + + public interface RoleStage { + /** + *

Identifies who spoke the statement

+ */ + ContentStage role(@NotNull AgentV1ConversationTextRole role); + + Builder from(AgentV1ConversationText other); + } + + public interface ContentStage { + /** + *

The actual statement that was spoken

+ */ + _FinalStage content(@NotNull String content); + } + + public interface ConversationalBehaviorStage { + /** + *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

+ */ + _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior); + } + + public interface _FinalStage { + AgentV1ConversationText build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + default _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { + return this; + } + + default _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ */ + _FinalStage languagesHinted(Optional> languagesHinted); + + _FinalStage languagesHinted(List languagesHinted); + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ */ + _FinalStage languages(Optional> languages); + + _FinalStage languages(List languages); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements RoleStage, ContentStage, ConversationalBehaviorStage, _FinalStage { + private AgentV1ConversationTextRole role; + + private String content; + + private AgentV1ConversationTextConversationalBehavior conversationalBehavior = + AgentV1ConversationTextConversationalBehavior.DEFAULT; + + private Optional> languages = Optional.empty(); + + private Optional> languagesHinted = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AgentV1ConversationText other) { + role(other.getRole()); + content(other.getContent()); + conversationalBehavior(other.getConversationalBehavior()); + languagesHinted(other.getLanguagesHinted()); + languages(other.getLanguages()); + return this; + } + + /** + *

Identifies who spoke the statement

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("role") + public ContentStage role(@NotNull AgentV1ConversationTextRole role) { + this.role = Objects.requireNonNull(role, "role must not be null"); + return this; + } + + /** + *

The actual statement that was spoken

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("content") + public _FinalStage content(@NotNull String content) { + this.content = Objects.requireNonNull(content, "content must not be null"); + return this; + } + + /** + *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) + public _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { + this.conversationalBehavior = + Objects.requireNonNull(conversationalBehavior, "conversationalBehavior must not be null"); + return this; + } + + public _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + this.conversationalBehavior = conversationalBehavior.orElse( + AgentV1ConversationTextConversationalBehavior.DEFAULT); + return this; + } + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languages(List languages) { + this.languages = Optional.ofNullable(languages); + return this; + } + + /** + *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

+ */ + @java.lang.Override + @JsonSetter(value = "languages", nulls = Nulls.SKIP) + public _FinalStage languages(Optional> languages) { + this.languages = languages; + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languagesHinted(List languagesHinted) { + this.languagesHinted = Optional.ofNullable(languagesHinted); + return this; + } + + /** + *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

+ */ + @java.lang.Override + @JsonSetter(value = "languages_hinted", nulls = Nulls.SKIP) + public _FinalStage languagesHinted(Optional> languagesHinted) { + this.languagesHinted = languagesHinted; + return this; + } + + @java.lang.Override + public AgentV1ConversationText build() { + return new AgentV1ConversationText( + role, content, conversationalBehavior, languagesHinted, languages, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak new file mode 100644 index 0000000..9bd5f76 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ForceEndTurn.Builder.class) +public final class AgentV1ForceEndTurn { + private final Map additionalProperties; + + private AgentV1ForceEndTurn(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for forcing the end of the current turn + */ + @JsonProperty("type") + public String getType() { + return "ForceEndTurn"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ForceEndTurn; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ForceEndTurn other) { + return this; + } + + public AgentV1ForceEndTurn build() { + return new AgentV1ForceEndTurn(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak new file mode 100644 index 0000000..f82f59e --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1KeepAlive.Builder.class) +public final class AgentV1KeepAlive { + private final Map additionalProperties; + + private AgentV1KeepAlive(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "KeepAlive"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1KeepAlive; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1KeepAlive other) { + return this; + } + + public AgentV1KeepAlive build() { + return new AgentV1KeepAlive(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak new file mode 100644 index 0000000..43b8628 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ListenUpdated.Builder.class) +public final class AgentV1ListenUpdated { + private final Map additionalProperties; + + private AgentV1ListenUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for listen update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ListenUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ListenUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ListenUpdated other) { + return this; + } + + public AgentV1ListenUpdated build() { + return new AgentV1ListenUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak new file mode 100644 index 0000000..e6efced --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1PromptUpdated.Builder.class) +public final class AgentV1PromptUpdated { + private final Map additionalProperties; + + private AgentV1PromptUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for prompt update confirmation + */ + @JsonProperty("type") + public String getType() { + return "PromptUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1PromptUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1PromptUpdated other) { + return this; + } + + public AgentV1PromptUpdated build() { + return new AgentV1PromptUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak new file mode 100644 index 0000000..393f1f9 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1SettingsAgentContextListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1SettingsAgentContextListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1SettingsAgentContextListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1SettingsAgentContextListenProvider(new V1Value(value)); + } + + public static AgentV1SettingsAgentContextListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1SettingsAgentContextListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsAgentContextListenProvider + && value.equals(((AgentV1SettingsAgentContextListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentContextListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak new file mode 100644 index 0000000..345ba2f --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1SettingsAgentListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1SettingsAgentListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1SettingsAgentListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1SettingsAgentListenProvider(new V1Value(value)); + } + + public static AgentV1SettingsAgentListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1SettingsAgentListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsAgentListenProvider + && value.equals(((AgentV1SettingsAgentListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1SettingsAgentListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak new file mode 100644 index 0000000..ad1fdb2 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1SettingsApplied.Builder.class) +public final class AgentV1SettingsApplied { + private final Map additionalProperties; + + private AgentV1SettingsApplied(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for settings applied confirmation + */ + @JsonProperty("type") + public String getType() { + return "SettingsApplied"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SettingsApplied; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1SettingsApplied other) { + return this; + } + + public AgentV1SettingsApplied build() { + return new AgentV1SettingsApplied(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak new file mode 100644 index 0000000..8b134b5 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1SpeakUpdated.Builder.class) +public final class AgentV1SpeakUpdated { + private final Map additionalProperties; + + private AgentV1SpeakUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for speak update confirmation + */ + @JsonProperty("type") + public String getType() { + return "SpeakUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1SpeakUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1SpeakUpdated other) { + return this; + } + + public AgentV1SpeakUpdated build() { + return new AgentV1SpeakUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak new file mode 100644 index 0000000..98eaf74 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ThinkLiveUpdated.Builder.class) +public final class AgentV1ThinkLiveUpdated { + private final Map additionalProperties; + + private AgentV1ThinkLiveUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for Think Live model update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ThinkLiveUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ThinkLiveUpdated; + } + + @java.lang.Override + public int hashCode() { + return 1; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ThinkLiveUpdated other) { + return this; + } + + public AgentV1ThinkLiveUpdated build() { + return new AgentV1ThinkLiveUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak new file mode 100644 index 0000000..2d67cad --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1ThinkUpdated.Builder.class) +public final class AgentV1ThinkUpdated { + private final Map additionalProperties; + + private AgentV1ThinkUpdated(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier for think update confirmation + */ + @JsonProperty("type") + public String getType() { + return "ThinkUpdated"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1ThinkUpdated; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1ThinkUpdated other) { + return this; + } + + public AgentV1ThinkUpdated build() { + return new AgentV1ThinkUpdated(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak new file mode 100644 index 0000000..e739aec --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak @@ -0,0 +1,224 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.types.DeepgramListenProviderV1; +import com.deepgram.types.DeepgramListenProviderV2; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class AgentV1UpdateListenListenProvider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private AgentV1UpdateListenListenProvider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static AgentV1UpdateListenListenProvider v1(DeepgramListenProviderV1 value) { + return new AgentV1UpdateListenListenProvider(new V1Value(value)); + } + + public static AgentV1UpdateListenListenProvider v2(DeepgramListenProviderV2 value) { + return new AgentV1UpdateListenListenProvider(new V2Value(value)); + } + + public boolean isV1() { + return value instanceof V1Value; + } + + public boolean isV2() { + return value instanceof V2Value; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getV1() { + if (isV1()) { + return Optional.of(((V1Value) value).value); + } + return Optional.empty(); + } + + public Optional getV2() { + if (isV2()) { + return Optional.of(((V2Value) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1UpdateListenListenProvider + && value.equals(((AgentV1UpdateListenListenProvider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitV1(DeepgramListenProviderV1 v1); + + T visitV2(DeepgramListenProviderV2 v2); + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("v1") + @JsonIgnoreProperties("version") + private static final class V1Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV1 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V1Value() {} + + private V1Value(DeepgramListenProviderV1 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV1(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1Value && equalTo((V1Value) other); + } + + private boolean equalTo(V1Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("v2") + @JsonIgnoreProperties("version") + private static final class V2Value implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "version", allowSetters = true) + private DeepgramListenProviderV2 value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private V2Value() {} + + private V2Value(DeepgramListenProviderV2 value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitV2(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V2Value && equalTo((V2Value) other); + } + + private boolean equalTo(V2Value other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("version") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "AgentV1UpdateListenListenProvider{" + "type: " + type + ", value: " + value + "}"; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak new file mode 100644 index 0000000..3556d31 --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AgentV1UserStartedSpeaking.Builder.class) +public final class AgentV1UserStartedSpeaking { + private final Map additionalProperties; + + private AgentV1UserStartedSpeaking(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier indicating that the user has begun speaking + */ + @JsonProperty("type") + public String getType() { + return "UserStartedSpeaking"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AgentV1UserStartedSpeaking; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(AgentV1UserStartedSpeaking other) { + return this; + } + + public AgentV1UserStartedSpeaking build() { + return new AgentV1UserStartedSpeaking(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..b648a3e --- /dev/null +++ b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,981 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.agent.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.agent.v1.types.AgentV1AgentAudioDone; +import com.deepgram.resources.agent.v1.types.AgentV1AgentStartedSpeaking; +import com.deepgram.resources.agent.v1.types.AgentV1AgentThinking; +import com.deepgram.resources.agent.v1.types.AgentV1ConversationText; +import com.deepgram.resources.agent.v1.types.AgentV1CustomFromThinkProvider; +import com.deepgram.resources.agent.v1.types.AgentV1CustomToThinkProvider; +import com.deepgram.resources.agent.v1.types.AgentV1Error; +import com.deepgram.resources.agent.v1.types.AgentV1ForceEndTurn; +import com.deepgram.resources.agent.v1.types.AgentV1FrustrationDetected; +import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallCancelled; +import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallRequest; +import com.deepgram.resources.agent.v1.types.AgentV1History; +import com.deepgram.resources.agent.v1.types.AgentV1InjectAgentMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectDynamicAgentMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectUserMessage; +import com.deepgram.resources.agent.v1.types.AgentV1InjectionRefused; +import com.deepgram.resources.agent.v1.types.AgentV1KeepAlive; +import com.deepgram.resources.agent.v1.types.AgentV1LatencyReport; +import com.deepgram.resources.agent.v1.types.AgentV1ListenUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1PromptUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ReceiveFunctionCallResponse; +import com.deepgram.resources.agent.v1.types.AgentV1SendFunctionCallResponse; +import com.deepgram.resources.agent.v1.types.AgentV1Settings; +import com.deepgram.resources.agent.v1.types.AgentV1SettingsApplied; +import com.deepgram.resources.agent.v1.types.AgentV1SpeakUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ThinkLiveUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1ThinkUpdated; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateListen; +import com.deepgram.resources.agent.v1.types.AgentV1UpdatePrompt; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateSpeak; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateThink; +import com.deepgram.resources.agent.v1.types.AgentV1UpdateThinkLive; +import com.deepgram.resources.agent.v1.types.AgentV1UserStartedSpeaking; +import com.deepgram.resources.agent.v1.types.AgentV1Warning; +import com.deepgram.resources.agent.v1.types.AgentV1Welcome; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer listenUpdatedHandler; + + private volatile Consumer thinkUpdatedHandler; + + private volatile Consumer thinkLiveUpdatedHandler; + + private volatile Consumer frustrationDetectedHandler; + + private volatile Consumer onFunctionCallResponseHandler; + + private volatile Consumer promptUpdatedHandler; + + private volatile Consumer speakUpdatedHandler; + + private volatile Consumer injectionRefusedHandler; + + private volatile Consumer welcomeHandler; + + private volatile Consumer settingsAppliedHandler; + + private volatile Consumer conversationTextHandler; + + private volatile Consumer userStartedSpeakingHandler; + + private volatile Consumer agentThinkingHandler; + + private volatile Consumer latencyReportHandler; + + private volatile Consumer functionCallRequestHandler; + + private volatile Consumer functionCallCancelledHandler; + + private volatile Consumer agentStartedSpeakingHandler; + + private volatile Consumer agentAudioDoneHandler; + + private volatile Consumer customFromThinkProviderHandler; + + private volatile Consumer errorHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer agentV1HistoryHandler; + + private volatile Consumer agentV1AudioHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + */ + public CompletableFuture connect() { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getAgentURL(); + String fullPath = "/v1/agent/converse"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (agentV1AudioHandler != null) { + agentV1AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends an AgentV1Settings message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendSettings(AgentV1Settings message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateListen message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateListen(AgentV1UpdateListen message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateThink message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateThink(AgentV1UpdateThink message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateThinkLive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateThinkLive(AgentV1UpdateThinkLive message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdateSpeak message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdateSpeak(AgentV1UpdateSpeak message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectUserMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectUserMessage(AgentV1InjectUserMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectAgentMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectAgentMessage(AgentV1InjectAgentMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1InjectDynamicAgentMessage message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInjectDynamicAgentMessage(AgentV1InjectDynamicAgentMessage message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1SendFunctionCallResponse message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFunctionCallResponse(AgentV1SendFunctionCallResponse message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1KeepAlive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendKeepAlive(AgentV1KeepAlive message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1UpdatePrompt message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendUpdatePrompt(AgentV1UpdatePrompt message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1ForceEndTurn message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendForceEndTurn(AgentV1ForceEndTurn message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1CustomToThinkProvider message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCustomToThinkProvider(AgentV1CustomToThinkProvider message) { + return sendMessage(message); + } + + /** + * Sends an AgentV1Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Registers a handler for AgentV1ListenUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onListenUpdated(Consumer handler) { + this.listenUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1ThinkUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onThinkUpdated(Consumer handler) { + this.thinkUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1ThinkLiveUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onThinkLiveUpdated(Consumer handler) { + this.thinkLiveUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1FrustrationDetected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFrustrationDetected(Consumer handler) { + this.frustrationDetectedHandler = handler; + } + + /** + * Registers a handler for AgentV1ReceiveFunctionCallResponse messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallResponse(Consumer handler) { + this.onFunctionCallResponseHandler = handler; + } + + /** + * Registers a handler for AgentV1PromptUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onPromptUpdated(Consumer handler) { + this.promptUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1SpeakUpdated messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakUpdated(Consumer handler) { + this.speakUpdatedHandler = handler; + } + + /** + * Registers a handler for AgentV1InjectionRefused messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onInjectionRefused(Consumer handler) { + this.injectionRefusedHandler = handler; + } + + /** + * Registers a handler for AgentV1Welcome messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWelcome(Consumer handler) { + this.welcomeHandler = handler; + } + + /** + * Registers a handler for AgentV1SettingsApplied messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSettingsApplied(Consumer handler) { + this.settingsAppliedHandler = handler; + } + + /** + * Registers a handler for AgentV1ConversationText messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConversationText(Consumer handler) { + this.conversationTextHandler = handler; + } + + /** + * Registers a handler for AgentV1UserStartedSpeaking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onUserStartedSpeaking(Consumer handler) { + this.userStartedSpeakingHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentThinking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentThinking(Consumer handler) { + this.agentThinkingHandler = handler; + } + + /** + * Registers a handler for AgentV1LatencyReport messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onLatencyReport(Consumer handler) { + this.latencyReportHandler = handler; + } + + /** + * Registers a handler for AgentV1FunctionCallRequest messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallRequest(Consumer handler) { + this.functionCallRequestHandler = handler; + } + + /** + * Registers a handler for AgentV1FunctionCallCancelled messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFunctionCallCancelled(Consumer handler) { + this.functionCallCancelledHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentStartedSpeaking messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentStartedSpeaking(Consumer handler) { + this.agentStartedSpeakingHandler = handler; + } + + /** + * Registers a handler for AgentV1AgentAudioDone messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentAudioDone(Consumer handler) { + this.agentAudioDoneHandler = handler; + } + + /** + * Registers a handler for AgentV1CustomFromThinkProvider messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onCustomFromThinkProvider(Consumer handler) { + this.customFromThinkProviderHandler = handler; + } + + /** + * Registers a handler for AgentV1Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler for AgentV1Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for AgentV1History messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentV1History(Consumer handler) { + this.agentV1HistoryHandler = handler; + } + + /** + * Registers a handler for AgentV1Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onAgentV1Audio(Consumer handler) { + this.agentV1AudioHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { + AgentV1ConversationText conversationTextHandlerEvent = null; + try { + conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); + } catch (Exception e) { + } + if (conversationTextHandlerEvent != null) { + if (conversationTextHandler != null) { + conversationTextHandler.accept(conversationTextHandlerEvent); + } + return; + } + } + if (node.has("total_latency") + && node.has("tts_latency") + && node.has("ttt_latency") + && "AgentStartedSpeaking".equals(node.path("type").asText())) { + AgentV1AgentStartedSpeaking agentStartedSpeakingHandlerEvent = null; + try { + agentStartedSpeakingHandlerEvent = + objectMapper.treeToValue(node, AgentV1AgentStartedSpeaking.class); + } catch (Exception e) { + } + if (agentStartedSpeakingHandlerEvent != null) { + if (agentStartedSpeakingHandler != null) { + agentStartedSpeakingHandler.accept(agentStartedSpeakingHandlerEvent); + } + return; + } + } + if (node.has("count") + && node.has("escalated") + && "FrustrationDetected".equals(node.path("type").asText())) { + AgentV1FrustrationDetected frustrationDetectedHandlerEvent = null; + try { + frustrationDetectedHandlerEvent = objectMapper.treeToValue(node, AgentV1FrustrationDetected.class); + } catch (Exception e) { + } + if (frustrationDetectedHandlerEvent != null) { + if (frustrationDetectedHandler != null) { + frustrationDetectedHandler.accept(frustrationDetectedHandlerEvent); + } + return; + } + } + if (node.has("name") + && node.has("content") + && "FunctionCallResponse".equals(node.path("type").asText())) { + AgentV1ReceiveFunctionCallResponse onFunctionCallResponseHandlerEvent = null; + try { + onFunctionCallResponseHandlerEvent = + objectMapper.treeToValue(node, AgentV1ReceiveFunctionCallResponse.class); + } catch (Exception e) { + } + if (onFunctionCallResponseHandlerEvent != null) { + if (onFunctionCallResponseHandler != null) { + onFunctionCallResponseHandler.accept(onFunctionCallResponseHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Error".equals(node.path("type").asText())) { + AgentV1Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, AgentV1Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Warning".equals(node.path("type").asText())) { + AgentV1Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, AgentV1Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("message") + && "InjectionRefused".equals(node.path("type").asText())) { + AgentV1InjectionRefused injectionRefusedHandlerEvent = null; + try { + injectionRefusedHandlerEvent = objectMapper.treeToValue(node, AgentV1InjectionRefused.class); + } catch (Exception e) { + } + if (injectionRefusedHandlerEvent != null) { + if (injectionRefusedHandler != null) { + injectionRefusedHandler.accept(injectionRefusedHandlerEvent); + } + return; + } + } + if (node.has("request_id") && "Welcome".equals(node.path("type").asText())) { + AgentV1Welcome welcomeHandlerEvent = null; + try { + welcomeHandlerEvent = objectMapper.treeToValue(node, AgentV1Welcome.class); + } catch (Exception e) { + } + if (welcomeHandlerEvent != null) { + if (welcomeHandler != null) { + welcomeHandler.accept(welcomeHandlerEvent); + } + return; + } + } + if (node.has("content") && "AgentThinking".equals(node.path("type").asText())) { + AgentV1AgentThinking agentThinkingHandlerEvent = null; + try { + agentThinkingHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentThinking.class); + } catch (Exception e) { + } + if (agentThinkingHandlerEvent != null) { + if (agentThinkingHandler != null) { + agentThinkingHandler.accept(agentThinkingHandlerEvent); + } + return; + } + } + if (node.has("functions") + && "FunctionCallRequest".equals(node.path("type").asText())) { + AgentV1FunctionCallRequest functionCallRequestHandlerEvent = null; + try { + functionCallRequestHandlerEvent = objectMapper.treeToValue(node, AgentV1FunctionCallRequest.class); + } catch (Exception e) { + } + if (functionCallRequestHandlerEvent != null) { + if (functionCallRequestHandler != null) { + functionCallRequestHandler.accept(functionCallRequestHandlerEvent); + } + return; + } + } + if (node.has("functions") + && "FunctionCallCancelled".equals(node.path("type").asText())) { + AgentV1FunctionCallCancelled functionCallCancelledHandlerEvent = null; + try { + functionCallCancelledHandlerEvent = + objectMapper.treeToValue(node, AgentV1FunctionCallCancelled.class); + } catch (Exception e) { + } + if (functionCallCancelledHandlerEvent != null) { + if (functionCallCancelledHandler != null) { + functionCallCancelledHandler.accept(functionCallCancelledHandlerEvent); + } + return; + } + } + if (node.has("content") + && "__customFromThinkProvider".equals(node.path("type").asText())) { + AgentV1CustomFromThinkProvider customFromThinkProviderHandlerEvent = null; + try { + customFromThinkProviderHandlerEvent = + objectMapper.treeToValue(node, AgentV1CustomFromThinkProvider.class); + } catch (Exception e) { + } + if (customFromThinkProviderHandlerEvent != null) { + if (customFromThinkProviderHandler != null) { + customFromThinkProviderHandler.accept(customFromThinkProviderHandlerEvent); + } + return; + } + } + if ("ListenUpdated".equals(node.path("type").asText())) { + AgentV1ListenUpdated listenUpdatedHandlerEvent = null; + try { + listenUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ListenUpdated.class); + } catch (Exception e) { + } + if (listenUpdatedHandlerEvent != null) { + if (listenUpdatedHandler != null) { + listenUpdatedHandler.accept(listenUpdatedHandlerEvent); + } + return; + } + } + if ("ThinkUpdated".equals(node.path("type").asText())) { + AgentV1ThinkUpdated thinkUpdatedHandlerEvent = null; + try { + thinkUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkUpdated.class); + } catch (Exception e) { + } + if (thinkUpdatedHandlerEvent != null) { + if (thinkUpdatedHandler != null) { + thinkUpdatedHandler.accept(thinkUpdatedHandlerEvent); + } + return; + } + } + if ("ThinkLiveUpdated".equals(node.path("type").asText())) { + AgentV1ThinkLiveUpdated thinkLiveUpdatedHandlerEvent = null; + try { + thinkLiveUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkLiveUpdated.class); + } catch (Exception e) { + } + if (thinkLiveUpdatedHandlerEvent != null) { + if (thinkLiveUpdatedHandler != null) { + thinkLiveUpdatedHandler.accept(thinkLiveUpdatedHandlerEvent); + } + return; + } + } + if ("PromptUpdated".equals(node.path("type").asText())) { + AgentV1PromptUpdated promptUpdatedHandlerEvent = null; + try { + promptUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1PromptUpdated.class); + } catch (Exception e) { + } + if (promptUpdatedHandlerEvent != null) { + if (promptUpdatedHandler != null) { + promptUpdatedHandler.accept(promptUpdatedHandlerEvent); + } + return; + } + } + if ("SpeakUpdated".equals(node.path("type").asText())) { + AgentV1SpeakUpdated speakUpdatedHandlerEvent = null; + try { + speakUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1SpeakUpdated.class); + } catch (Exception e) { + } + if (speakUpdatedHandlerEvent != null) { + if (speakUpdatedHandler != null) { + speakUpdatedHandler.accept(speakUpdatedHandlerEvent); + } + return; + } + } + if ("SettingsApplied".equals(node.path("type").asText())) { + AgentV1SettingsApplied settingsAppliedHandlerEvent = null; + try { + settingsAppliedHandlerEvent = objectMapper.treeToValue(node, AgentV1SettingsApplied.class); + } catch (Exception e) { + } + if (settingsAppliedHandlerEvent != null) { + if (settingsAppliedHandler != null) { + settingsAppliedHandler.accept(settingsAppliedHandlerEvent); + } + return; + } + } + if ("UserStartedSpeaking".equals(node.path("type").asText())) { + AgentV1UserStartedSpeaking userStartedSpeakingHandlerEvent = null; + try { + userStartedSpeakingHandlerEvent = objectMapper.treeToValue(node, AgentV1UserStartedSpeaking.class); + } catch (Exception e) { + } + if (userStartedSpeakingHandlerEvent != null) { + if (userStartedSpeakingHandler != null) { + userStartedSpeakingHandler.accept(userStartedSpeakingHandlerEvent); + } + return; + } + } + if ("LatencyReport".equals(node.path("type").asText())) { + AgentV1LatencyReport latencyReportHandlerEvent = null; + try { + latencyReportHandlerEvent = objectMapper.treeToValue(node, AgentV1LatencyReport.class); + } catch (Exception e) { + } + if (latencyReportHandlerEvent != null) { + if (latencyReportHandler != null) { + latencyReportHandler.accept(latencyReportHandlerEvent); + } + return; + } + } + if ("AgentAudioDone".equals(node.path("type").asText())) { + AgentV1AgentAudioDone agentAudioDoneHandlerEvent = null; + try { + agentAudioDoneHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentAudioDone.class); + } catch (Exception e) { + } + if (agentAudioDoneHandlerEvent != null) { + if (agentAudioDoneHandler != null) { + agentAudioDoneHandler.accept(agentAudioDoneHandlerEvent); + } + return; + } + } + AgentV1History agentV1HistoryHandlerEvent = null; + try { + agentV1HistoryHandlerEvent = objectMapper.treeToValue(node, AgentV1History.class); + } catch (Exception e) { + } + if (agentV1HistoryHandlerEvent != null) { + if (agentV1HistoryHandler != null) { + agentV1HistoryHandler.accept(agentV1HistoryHandlerEvent); + } + return; + } + if (onMessageHandler == null && onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak new file mode 100644 index 0000000..448c459 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak @@ -0,0 +1,1932 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.media.requests; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV1RequestUrl.Builder.class) +public final class ListenV1RequestUrl { + private final Optional> extra; + + private final Optional> tag; + + private final Optional> customTopic; + + private final Optional> customIntent; + + private final Optional> keyterm; + + private final Optional> keywords; + + private final Optional> languageHint; + + private final Optional> replace; + + private final Optional> search; + + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional sentiment; + + private final Optional summarize; + + private final Optional topics; + + private final Optional customTopicMode; + + private final Optional intents; + + private final Optional customIntentMode; + + private final Optional detectEntities; + + private final Optional detectLanguage; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional fillerWords; + + private final Optional language; + + private final Optional measurements; + + private final Optional model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional paragraphs; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional smartFormat; + + private final Optional utterances; + + private final Optional uttSplit; + + private final Optional version; + + private final Optional mipOptOut; + + private final String url; + + private final Map additionalProperties; + + private ListenV1RequestUrl( + Optional> extra, + Optional> tag, + Optional> customTopic, + Optional> customIntent, + Optional> keyterm, + Optional> keywords, + Optional> languageHint, + Optional> replace, + Optional> search, + Optional callback, + Optional callbackMethod, + Optional sentiment, + Optional summarize, + Optional topics, + Optional customTopicMode, + Optional intents, + Optional customIntentMode, + Optional detectEntities, + Optional detectLanguage, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional fillerWords, + Optional language, + Optional measurements, + Optional model, + Optional multichannel, + Optional numerals, + Optional paragraphs, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional smartFormat, + Optional utterances, + Optional uttSplit, + Optional version, + Optional mipOptOut, + String url, + Map additionalProperties) { + this.extra = extra; + this.tag = tag; + this.customTopic = customTopic; + this.customIntent = customIntent; + this.keyterm = keyterm; + this.keywords = keywords; + this.languageHint = languageHint; + this.replace = replace; + this.search = search; + this.callback = callback; + this.callbackMethod = callbackMethod; + this.sentiment = sentiment; + this.summarize = summarize; + this.topics = topics; + this.customTopicMode = customTopicMode; + this.intents = intents; + this.customIntentMode = customIntentMode; + this.detectEntities = detectEntities; + this.detectLanguage = detectLanguage; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.fillerWords = fillerWords; + this.language = language; + this.measurements = measurements; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.paragraphs = paragraphs; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.smartFormat = smartFormat; + this.utterances = utterances; + this.uttSplit = uttSplit; + this.version = version; + this.mipOptOut = mipOptOut; + this.url = url; + this.additionalProperties = additionalProperties; + } + + /** + * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ + @JsonIgnore + public Optional> getExtra() { + return extra; + } + + /** + * @return Label your requests for the purpose of identification during usage reporting + */ + @JsonIgnore + public Optional> getTag() { + return tag; + } + + /** + * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. + */ + @JsonIgnore + public Optional> getCustomTopic() { + return customTopic; + } + + /** + * @return Custom intents you want the model to detect within your input audio if present + */ + @JsonIgnore + public Optional> getCustomIntent() { + return customIntent; + } + + /** + * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. + *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @JsonIgnore + public Optional> getKeyterm() { + return keyterm; + } + + /** + * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. + */ + @JsonIgnore + public Optional> getKeywords() { + return keywords; + } + + /** + * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. + */ + @JsonIgnore + public Optional> getLanguageHint() { + return languageHint; + } + + /** + * @return Search for terms or phrases in submitted audio and replaces them + */ + @JsonIgnore + public Optional> getReplace() { + return replace; + } + + /** + * @return Search for terms or phrases in submitted audio + */ + @JsonIgnore + public Optional> getSearch() { + return search; + } + + /** + * @return URL to which we'll make the callback request + */ + @JsonIgnore + public Optional getCallback() { + return callback; + } + + /** + * @return HTTP method by which the callback request will be made + */ + @JsonIgnore + public Optional getCallbackMethod() { + return callbackMethod; + } + + /** + * @return Recognizes the sentiment throughout a transcript or text + */ + @JsonIgnore + public Optional getSentiment() { + return sentiment; + } + + /** + * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. + */ + @JsonIgnore + public Optional getSummarize() { + return summarize; + } + + /** + * @return Detect topics throughout a transcript or text + */ + @JsonIgnore + public Optional getTopics() { + return topics; + } + + /** + * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param + */ + @JsonIgnore + public Optional getCustomTopicMode() { + return customTopicMode; + } + + /** + * @return Recognizes speaker intent throughout a transcript or text + */ + @JsonIgnore + public Optional getIntents() { + return intents; + } + + /** + * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. + */ + @JsonIgnore + public Optional getCustomIntentMode() { + return customIntentMode; + } + + /** + * @return Identifies and extracts key entities from content in submitted audio + */ + @JsonIgnore + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Identifies the dominant language spoken in submitted audio + */ + @JsonIgnore + public Optional getDetectLanguage() { + return detectLanguage; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonIgnore + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. + */ + @JsonIgnore + public Optional getDiarizeModel() { + return diarizeModel; + } + + /** + * @return Dictation mode for controlling formatting with dictated speech + */ + @JsonIgnore + public Optional getDictation() { + return dictation; + } + + /** + * @return Specify the expected encoding of your submitted audio + */ + @JsonIgnore + public Optional getEncoding() { + return encoding; + } + + /** + * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" + */ + @JsonIgnore + public Optional getFillerWords() { + return fillerWords; + } + + /** + * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available + */ + @JsonIgnore + public Optional getLanguage() { + return language; + } + + /** + * @return Spoken measurements will be converted to their corresponding abbreviations + */ + @JsonIgnore + public Optional getMeasurements() { + return measurements; + } + + /** + * @return AI model used to process submitted audio + */ + @JsonIgnore + public Optional getModel() { + return model; + } + + /** + * @return Transcribe each audio channel independently + */ + @JsonIgnore + public Optional getMultichannel() { + return multichannel; + } + + /** + * @return Numerals converts numbers from written format to numerical format + */ + @JsonIgnore + public Optional getNumerals() { + return numerals; + } + + /** + * @return Splits audio into paragraphs to improve transcript readability + */ + @JsonIgnore + public Optional getParagraphs() { + return paragraphs; + } + + /** + * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely + */ + @JsonIgnore + public Optional getProfanityFilter() { + return profanityFilter; + } + + /** + * @return Add punctuation and capitalization to the transcript + */ + @JsonIgnore + public Optional getPunctuate() { + return punctuate; + } + + /** + * @return Redaction removes sensitive information from your transcripts + */ + @JsonIgnore + public Optional getRedact() { + return redact; + } + + /** + * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability + */ + @JsonIgnore + public Optional getSmartFormat() { + return smartFormat; + } + + /** + * @return Segments speech into meaningful semantic units + */ + @JsonIgnore + public Optional getUtterances() { + return utterances; + } + + /** + * @return Seconds to wait before detecting a pause between words in submitted audio + */ + @JsonIgnore + public Optional getUttSplit() { + return uttSplit; + } + + /** + * @return Version of an AI model to use + */ + @JsonIgnore + public Optional getVersion() { + return version; + } + + /** + * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ + @JsonIgnore + public Optional getMipOptOut() { + return mipOptOut; + } + + @JsonProperty("url") + public String getUrl() { + return url; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV1RequestUrl && equalTo((ListenV1RequestUrl) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ListenV1RequestUrl other) { + return extra.equals(other.extra) + && tag.equals(other.tag) + && customTopic.equals(other.customTopic) + && customIntent.equals(other.customIntent) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && languageHint.equals(other.languageHint) + && replace.equals(other.replace) + && search.equals(other.search) + && callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && sentiment.equals(other.sentiment) + && summarize.equals(other.summarize) + && topics.equals(other.topics) + && customTopicMode.equals(other.customTopicMode) + && intents.equals(other.intents) + && customIntentMode.equals(other.customIntentMode) + && detectEntities.equals(other.detectEntities) + && detectLanguage.equals(other.detectLanguage) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && fillerWords.equals(other.fillerWords) + && language.equals(other.language) + && measurements.equals(other.measurements) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && paragraphs.equals(other.paragraphs) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && smartFormat.equals(other.smartFormat) + && utterances.equals(other.utterances) + && uttSplit.equals(other.uttSplit) + && version.equals(other.version) + && mipOptOut.equals(other.mipOptOut) + && url.equals(other.url); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.extra, + this.tag, + this.customTopic, + this.customIntent, + this.keyterm, + this.keywords, + this.languageHint, + this.replace, + this.search, + this.callback, + this.callbackMethod, + this.sentiment, + this.summarize, + this.topics, + this.customTopicMode, + this.intents, + this.customIntentMode, + this.detectEntities, + this.detectLanguage, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.fillerWords, + this.language, + this.measurements, + this.model, + this.multichannel, + this.numerals, + this.paragraphs, + this.profanityFilter, + this.punctuate, + this.redact, + this.smartFormat, + this.utterances, + this.uttSplit, + this.version, + this.mipOptOut, + this.url); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static UrlStage builder() { + return new Builder(); + } + + public interface UrlStage { + _FinalStage url(@NotNull String url); + + Builder from(ListenV1RequestUrl other); + } + + public interface _FinalStage { + ListenV1RequestUrl build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + _FinalStage extra(Optional> extra); + + _FinalStage extra(List extra); + + _FinalStage extra(String extra); + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + _FinalStage tag(Optional> tag); + + _FinalStage tag(List tag); + + _FinalStage tag(String tag); + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + _FinalStage customTopic(Optional> customTopic); + + _FinalStage customTopic(List customTopic); + + _FinalStage customTopic(String customTopic); + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + _FinalStage customIntent(Optional> customIntent); + + _FinalStage customIntent(List customIntent); + + _FinalStage customIntent(String customIntent); + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + _FinalStage keyterm(Optional> keyterm); + + _FinalStage keyterm(List keyterm); + + _FinalStage keyterm(String keyterm); + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + _FinalStage keywords(Optional> keywords); + + _FinalStage keywords(List keywords); + + _FinalStage keywords(String keywords); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional> languageHint) { + return this; + } + + default _FinalStage languageHint(List languageHint) { + return this; + } + + default _FinalStage languageHint(String languageHint) { + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + _FinalStage replace(Optional> replace); + + _FinalStage replace(List replace); + + _FinalStage replace(String replace); + + /** + *

Search for terms or phrases in submitted audio

+ */ + _FinalStage search(Optional> search); + + _FinalStage search(List search); + + _FinalStage search(String search); + + /** + *

URL to which we'll make the callback request

+ */ + _FinalStage callback(Optional callback); + + _FinalStage callback(String callback); + + /** + *

HTTP method by which the callback request will be made

+ */ + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + _FinalStage sentiment(Optional sentiment); + + _FinalStage sentiment(Boolean sentiment); + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + _FinalStage summarize(Optional summarize); + + _FinalStage summarize(MediaTranscribeRequestSummarize summarize); + + /** + *

Detect topics throughout a transcript or text

+ */ + _FinalStage topics(Optional topics); + + _FinalStage topics(Boolean topics); + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + _FinalStage customTopicMode(Optional customTopicMode); + + _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + _FinalStage intents(Optional intents); + + _FinalStage intents(Boolean intents); + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + _FinalStage customIntentMode(Optional customIntentMode); + + _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(Boolean detectEntities); + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + _FinalStage detectLanguage(Optional detectLanguage); + + _FinalStage detectLanguage(Boolean detectLanguage); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(Boolean diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(Boolean dictation); + + /** + *

Specify the expected encoding of your submitted audio

+ */ + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(MediaTranscribeRequestEncoding encoding); + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + _FinalStage fillerWords(Optional fillerWords); + + _FinalStage fillerWords(Boolean fillerWords); + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + _FinalStage language(Optional language); + + _FinalStage language(String language); + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + _FinalStage measurements(Optional measurements); + + _FinalStage measurements(Boolean measurements); + + /** + *

AI model used to process submitted audio

+ */ + _FinalStage model(Optional model); + + _FinalStage model(MediaTranscribeRequestModel model); + + /** + *

Transcribe each audio channel independently

+ */ + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(Boolean multichannel); + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(Boolean numerals); + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + _FinalStage paragraphs(Optional paragraphs); + + _FinalStage paragraphs(Boolean paragraphs); + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(Boolean profanityFilter); + + /** + *

Add punctuation and capitalization to the transcript

+ */ + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(Boolean punctuate); + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + _FinalStage redact(Optional redact); + + _FinalStage redact(String redact); + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(Boolean smartFormat); + + /** + *

Segments speech into meaningful semantic units

+ */ + _FinalStage utterances(Optional utterances); + + _FinalStage utterances(Boolean utterances); + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + _FinalStage uttSplit(Optional uttSplit); + + _FinalStage uttSplit(Double uttSplit); + + /** + *

Version of an AI model to use

+ */ + _FinalStage version(Optional version); + + _FinalStage version(MediaTranscribeRequestVersion version); + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(Boolean mipOptOut); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements UrlStage, _FinalStage { + private String url; + + private Optional mipOptOut = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional uttSplit = Optional.empty(); + + private Optional utterances = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional paragraphs = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional measurements = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional fillerWords = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectLanguage = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional customIntentMode = Optional.empty(); + + private Optional intents = Optional.empty(); + + private Optional customTopicMode = Optional.empty(); + + private Optional topics = Optional.empty(); + + private Optional summarize = Optional.empty(); + + private Optional sentiment = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + private Optional> search = Optional.empty(); + + private Optional> replace = Optional.empty(); + + private Optional> languageHint = Optional.empty(); + + private Optional> keywords = Optional.empty(); + + private Optional> keyterm = Optional.empty(); + + private Optional> customIntent = Optional.empty(); + + private Optional> customTopic = Optional.empty(); + + private Optional> tag = Optional.empty(); + + private Optional> extra = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ListenV1RequestUrl other) { + extra(other.getExtra()); + tag(other.getTag()); + customTopic(other.getCustomTopic()); + customIntent(other.getCustomIntent()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + languageHint(other.getLanguageHint()); + replace(other.getReplace()); + search(other.getSearch()); + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + sentiment(other.getSentiment()); + summarize(other.getSummarize()); + topics(other.getTopics()); + customTopicMode(other.getCustomTopicMode()); + intents(other.getIntents()); + customIntentMode(other.getCustomIntentMode()); + detectEntities(other.getDetectEntities()); + detectLanguage(other.getDetectLanguage()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + fillerWords(other.getFillerWords()); + language(other.getLanguage()); + measurements(other.getMeasurements()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + paragraphs(other.getParagraphs()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + smartFormat(other.getSmartFormat()); + utterances(other.getUtterances()); + uttSplit(other.getUttSplit()); + version(other.getVersion()); + mipOptOut(other.getMipOptOut()); + url(other.getUrl()); + return this; + } + + @java.lang.Override + @JsonSetter("url") + public _FinalStage url(@NotNull String url) { + this.url = Objects.requireNonNull(url, "url must not be null"); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage mipOptOut(Boolean mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + /** + *

Version of an AI model to use

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(MediaTranscribeRequestVersion version) { + this.version = Optional.ofNullable(version); + return this; + } + + /** + *

Version of an AI model to use

+ */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage uttSplit(Double uttSplit) { + this.uttSplit = Optional.ofNullable(uttSplit); + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) + public _FinalStage uttSplit(Optional uttSplit) { + this.uttSplit = uttSplit; + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage utterances(Boolean utterances) { + this.utterances = Optional.ofNullable(utterances); + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ */ + @java.lang.Override + @JsonSetter(value = "utterances", nulls = Nulls.SKIP) + public _FinalStage utterances(Optional utterances) { + this.utterances = utterances; + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage smartFormat(Boolean smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redact(String redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage punctuate(Boolean punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ */ + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage profanityFilter(Boolean profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage paragraphs(Boolean paragraphs) { + this.paragraphs = Optional.ofNullable(paragraphs); + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + @java.lang.Override + @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) + public _FinalStage paragraphs(Optional paragraphs) { + this.paragraphs = paragraphs; + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numerals(Boolean numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + /** + *

Transcribe each audio channel independently

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multichannel(Boolean multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + /** + *

Transcribe each audio channel independently

+ */ + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + /** + *

AI model used to process submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(MediaTranscribeRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

AI model used to process submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage measurements(Boolean measurements) { + this.measurements = Optional.ofNullable(measurements); + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + @java.lang.Override + @JsonSetter(value = "measurements", nulls = Nulls.SKIP) + public _FinalStage measurements(Optional measurements) { + this.measurements = measurements; + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage language(String language) { + this.language = Optional.ofNullable(language); + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage fillerWords(Boolean fillerWords) { + this.fillerWords = Optional.ofNullable(fillerWords); + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + @java.lang.Override + @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) + public _FinalStage fillerWords(Optional fillerWords) { + this.fillerWords = fillerWords; + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage dictation(Boolean dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(Boolean diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectLanguage(Boolean detectLanguage) { + this.detectLanguage = Optional.ofNullable(detectLanguage); + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) + public _FinalStage detectLanguage(Optional detectLanguage) { + this.detectLanguage = detectLanguage; + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectEntities(Boolean detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { + this.customIntentMode = Optional.ofNullable(customIntentMode); + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) + public _FinalStage customIntentMode(Optional customIntentMode) { + this.customIntentMode = customIntentMode; + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intents(Boolean intents) { + this.intents = Optional.ofNullable(intents); + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "intents", nulls = Nulls.SKIP) + public _FinalStage intents(Optional intents) { + this.intents = intents; + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { + this.customTopicMode = Optional.ofNullable(customTopicMode); + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) + public _FinalStage customTopicMode(Optional customTopicMode) { + this.customTopicMode = customTopicMode; + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage topics(Boolean topics) { + this.topics = Optional.ofNullable(topics); + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "topics", nulls = Nulls.SKIP) + public _FinalStage topics(Optional topics) { + this.topics = topics; + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { + this.summarize = Optional.ofNullable(summarize); + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + @java.lang.Override + @JsonSetter(value = "summarize", nulls = Nulls.SKIP) + public _FinalStage summarize(Optional summarize) { + this.summarize = summarize; + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sentiment(Boolean sentiment) { + this.sentiment = Optional.ofNullable(sentiment); + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) + public _FinalStage sentiment(Optional sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ */ + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + /** + *

URL to which we'll make the callback request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callback(String callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + /** + *

URL to which we'll make the callback request

+ */ + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public _FinalStage search(String search) { + this.search = Optional.of(Collections.singletonList(search)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage search(List search) { + this.search = Optional.ofNullable(search); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional> search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage replace(String replace) { + this.replace = Optional.of(Collections.singletonList(replace)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage replace(List replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional> replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(String languageHint) { + this.languageHint = Optional.of(Collections.singletonList(languageHint)); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languageHint(List languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional> languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage keywords(String keywords) { + this.keywords = Optional.of(Collections.singletonList(keywords)); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keywords(List keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional> keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(String keyterm) { + this.keyterm = Optional.of(Collections.singletonList(keyterm)); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keyterm(List keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional> keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage customIntent(String customIntent) { + this.customIntent = Optional.of(Collections.singletonList(customIntent)); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntent(List customIntent) { + this.customIntent = Optional.ofNullable(customIntent); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) + public _FinalStage customIntent(Optional> customIntent) { + this.customIntent = customIntent; + return this; + } + + @java.lang.Override + public _FinalStage customTopic(String customTopic) { + this.customTopic = Optional.of(Collections.singletonList(customTopic)); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopic(List customTopic) { + this.customTopic = Optional.ofNullable(customTopic); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) + public _FinalStage customTopic(Optional> customTopic) { + this.customTopic = customTopic; + return this; + } + + @java.lang.Override + public _FinalStage tag(String tag) { + this.tag = Optional.of(Collections.singletonList(tag)); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tag(List tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional> tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage extra(String extra) { + this.extra = Optional.of(Collections.singletonList(extra)); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage extra(List extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional> extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public ListenV1RequestUrl build() { + return new ListenV1RequestUrl( + extra, + tag, + customTopic, + customIntent, + keyterm, + keywords, + languageHint, + replace, + search, + callback, + callbackMethod, + sentiment, + summarize, + topics, + customTopicMode, + intents, + customIntentMode, + detectEntities, + detectLanguage, + diarize, + diarizeModel, + dictation, + encoding, + fillerWords, + language, + measurements, + model, + multichannel, + numerals, + paragraphs, + profanityFilter, + punctuate, + redact, + smartFormat, + utterances, + uttSplit, + version, + mipOptOut, + url, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak new file mode 100644 index 0000000..f094b06 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak @@ -0,0 +1,1931 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.media.requests; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; +import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = MediaTranscribeRequestOctetStream.Builder.class) +public final class MediaTranscribeRequestOctetStream { + private final Optional> extra; + + private final Optional> tag; + + private final Optional> customTopic; + + private final Optional> customIntent; + + private final Optional> keyterm; + + private final Optional> keywords; + + private final Optional> languageHint; + + private final Optional> replace; + + private final Optional> search; + + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional sentiment; + + private final Optional summarize; + + private final Optional topics; + + private final Optional customTopicMode; + + private final Optional intents; + + private final Optional customIntentMode; + + private final Optional detectEntities; + + private final Optional detectLanguage; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional fillerWords; + + private final Optional language; + + private final Optional measurements; + + private final Optional model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional paragraphs; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional smartFormat; + + private final Optional utterances; + + private final Optional uttSplit; + + private final Optional version; + + private final Optional mipOptOut; + + private final byte[] body; + + private final Map additionalProperties; + + private MediaTranscribeRequestOctetStream( + Optional> extra, + Optional> tag, + Optional> customTopic, + Optional> customIntent, + Optional> keyterm, + Optional> keywords, + Optional> languageHint, + Optional> replace, + Optional> search, + Optional callback, + Optional callbackMethod, + Optional sentiment, + Optional summarize, + Optional topics, + Optional customTopicMode, + Optional intents, + Optional customIntentMode, + Optional detectEntities, + Optional detectLanguage, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional fillerWords, + Optional language, + Optional measurements, + Optional model, + Optional multichannel, + Optional numerals, + Optional paragraphs, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional smartFormat, + Optional utterances, + Optional uttSplit, + Optional version, + Optional mipOptOut, + byte[] body, + Map additionalProperties) { + this.extra = extra; + this.tag = tag; + this.customTopic = customTopic; + this.customIntent = customIntent; + this.keyterm = keyterm; + this.keywords = keywords; + this.languageHint = languageHint; + this.replace = replace; + this.search = search; + this.callback = callback; + this.callbackMethod = callbackMethod; + this.sentiment = sentiment; + this.summarize = summarize; + this.topics = topics; + this.customTopicMode = customTopicMode; + this.intents = intents; + this.customIntentMode = customIntentMode; + this.detectEntities = detectEntities; + this.detectLanguage = detectLanguage; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.fillerWords = fillerWords; + this.language = language; + this.measurements = measurements; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.paragraphs = paragraphs; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.smartFormat = smartFormat; + this.utterances = utterances; + this.uttSplit = uttSplit; + this.version = version; + this.mipOptOut = mipOptOut; + this.body = body; + this.additionalProperties = additionalProperties; + } + + /** + * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ + @JsonProperty("extra") + public Optional> getExtra() { + return extra; + } + + /** + * @return Label your requests for the purpose of identification during usage reporting + */ + @JsonProperty("tag") + public Optional> getTag() { + return tag; + } + + /** + * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. + */ + @JsonProperty("custom_topic") + public Optional> getCustomTopic() { + return customTopic; + } + + /** + * @return Custom intents you want the model to detect within your input audio if present + */ + @JsonProperty("custom_intent") + public Optional> getCustomIntent() { + return customIntent; + } + + /** + * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. + *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @JsonProperty("keyterm") + public Optional> getKeyterm() { + return keyterm; + } + + /** + * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. + */ + @JsonProperty("keywords") + public Optional> getKeywords() { + return keywords; + } + + /** + * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. + */ + @JsonProperty("language_hint") + public Optional> getLanguageHint() { + return languageHint; + } + + /** + * @return Search for terms or phrases in submitted audio and replaces them + */ + @JsonProperty("replace") + public Optional> getReplace() { + return replace; + } + + /** + * @return Search for terms or phrases in submitted audio + */ + @JsonProperty("search") + public Optional> getSearch() { + return search; + } + + /** + * @return URL to which we'll make the callback request + */ + @JsonProperty("callback") + public Optional getCallback() { + return callback; + } + + /** + * @return HTTP method by which the callback request will be made + */ + @JsonProperty("callback_method") + public Optional getCallbackMethod() { + return callbackMethod; + } + + /** + * @return Recognizes the sentiment throughout a transcript or text + */ + @JsonProperty("sentiment") + public Optional getSentiment() { + return sentiment; + } + + /** + * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. + */ + @JsonProperty("summarize") + public Optional getSummarize() { + return summarize; + } + + /** + * @return Detect topics throughout a transcript or text + */ + @JsonProperty("topics") + public Optional getTopics() { + return topics; + } + + /** + * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param + */ + @JsonProperty("custom_topic_mode") + public Optional getCustomTopicMode() { + return customTopicMode; + } + + /** + * @return Recognizes speaker intent throughout a transcript or text + */ + @JsonProperty("intents") + public Optional getIntents() { + return intents; + } + + /** + * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. + */ + @JsonProperty("custom_intent_mode") + public Optional getCustomIntentMode() { + return customIntentMode; + } + + /** + * @return Identifies and extracts key entities from content in submitted audio + */ + @JsonProperty("detect_entities") + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Identifies the dominant language spoken in submitted audio + */ + @JsonProperty("detect_language") + public Optional getDetectLanguage() { + return detectLanguage; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonProperty("diarize") + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. + */ + @JsonProperty("diarize_model") + public Optional getDiarizeModel() { + return diarizeModel; + } + + /** + * @return Dictation mode for controlling formatting with dictated speech + */ + @JsonProperty("dictation") + public Optional getDictation() { + return dictation; + } + + /** + * @return Specify the expected encoding of your submitted audio + */ + @JsonProperty("encoding") + public Optional getEncoding() { + return encoding; + } + + /** + * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" + */ + @JsonProperty("filler_words") + public Optional getFillerWords() { + return fillerWords; + } + + /** + * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available + */ + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + /** + * @return Spoken measurements will be converted to their corresponding abbreviations + */ + @JsonProperty("measurements") + public Optional getMeasurements() { + return measurements; + } + + /** + * @return AI model used to process submitted audio + */ + @JsonProperty("model") + public Optional getModel() { + return model; + } + + /** + * @return Transcribe each audio channel independently + */ + @JsonProperty("multichannel") + public Optional getMultichannel() { + return multichannel; + } + + /** + * @return Numerals converts numbers from written format to numerical format + */ + @JsonProperty("numerals") + public Optional getNumerals() { + return numerals; + } + + /** + * @return Splits audio into paragraphs to improve transcript readability + */ + @JsonProperty("paragraphs") + public Optional getParagraphs() { + return paragraphs; + } + + /** + * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely + */ + @JsonProperty("profanity_filter") + public Optional getProfanityFilter() { + return profanityFilter; + } + + /** + * @return Add punctuation and capitalization to the transcript + */ + @JsonProperty("punctuate") + public Optional getPunctuate() { + return punctuate; + } + + /** + * @return Redaction removes sensitive information from your transcripts + */ + @JsonProperty("redact") + public Optional getRedact() { + return redact; + } + + /** + * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability + */ + @JsonProperty("smart_format") + public Optional getSmartFormat() { + return smartFormat; + } + + /** + * @return Segments speech into meaningful semantic units + */ + @JsonProperty("utterances") + public Optional getUtterances() { + return utterances; + } + + /** + * @return Seconds to wait before detecting a pause between words in submitted audio + */ + @JsonProperty("utt_split") + public Optional getUttSplit() { + return uttSplit; + } + + /** + * @return Version of an AI model to use + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + /** + * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ + @JsonProperty("mip_opt_out") + public Optional getMipOptOut() { + return mipOptOut; + } + + @JsonProperty("body") + public byte[] getBody() { + return body; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof MediaTranscribeRequestOctetStream && equalTo((MediaTranscribeRequestOctetStream) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(MediaTranscribeRequestOctetStream other) { + return extra.equals(other.extra) + && tag.equals(other.tag) + && customTopic.equals(other.customTopic) + && customIntent.equals(other.customIntent) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && languageHint.equals(other.languageHint) + && replace.equals(other.replace) + && search.equals(other.search) + && callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && sentiment.equals(other.sentiment) + && summarize.equals(other.summarize) + && topics.equals(other.topics) + && customTopicMode.equals(other.customTopicMode) + && intents.equals(other.intents) + && customIntentMode.equals(other.customIntentMode) + && detectEntities.equals(other.detectEntities) + && detectLanguage.equals(other.detectLanguage) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && fillerWords.equals(other.fillerWords) + && language.equals(other.language) + && measurements.equals(other.measurements) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && paragraphs.equals(other.paragraphs) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && smartFormat.equals(other.smartFormat) + && utterances.equals(other.utterances) + && uttSplit.equals(other.uttSplit) + && version.equals(other.version) + && mipOptOut.equals(other.mipOptOut) + && body.equals(other.body); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.extra, + this.tag, + this.customTopic, + this.customIntent, + this.keyterm, + this.keywords, + this.languageHint, + this.replace, + this.search, + this.callback, + this.callbackMethod, + this.sentiment, + this.summarize, + this.topics, + this.customTopicMode, + this.intents, + this.customIntentMode, + this.detectEntities, + this.detectLanguage, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.fillerWords, + this.language, + this.measurements, + this.model, + this.multichannel, + this.numerals, + this.paragraphs, + this.profanityFilter, + this.punctuate, + this.redact, + this.smartFormat, + this.utterances, + this.uttSplit, + this.version, + this.mipOptOut, + this.body); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static BodyStage builder() { + return new Builder(); + } + + public interface BodyStage { + _FinalStage body(@NotNull byte[] body); + + Builder from(MediaTranscribeRequestOctetStream other); + } + + public interface _FinalStage { + MediaTranscribeRequestOctetStream build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + _FinalStage extra(Optional> extra); + + _FinalStage extra(List extra); + + _FinalStage extra(String extra); + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + _FinalStage tag(Optional> tag); + + _FinalStage tag(List tag); + + _FinalStage tag(String tag); + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + _FinalStage customTopic(Optional> customTopic); + + _FinalStage customTopic(List customTopic); + + _FinalStage customTopic(String customTopic); + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + _FinalStage customIntent(Optional> customIntent); + + _FinalStage customIntent(List customIntent); + + _FinalStage customIntent(String customIntent); + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + _FinalStage keyterm(Optional> keyterm); + + _FinalStage keyterm(List keyterm); + + _FinalStage keyterm(String keyterm); + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + _FinalStage keywords(Optional> keywords); + + _FinalStage keywords(List keywords); + + _FinalStage keywords(String keywords); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional> languageHint) { + return this; + } + + default _FinalStage languageHint(List languageHint) { + return this; + } + + default _FinalStage languageHint(String languageHint) { + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + _FinalStage replace(Optional> replace); + + _FinalStage replace(List replace); + + _FinalStage replace(String replace); + + /** + *

Search for terms or phrases in submitted audio

+ */ + _FinalStage search(Optional> search); + + _FinalStage search(List search); + + _FinalStage search(String search); + + /** + *

URL to which we'll make the callback request

+ */ + _FinalStage callback(Optional callback); + + _FinalStage callback(String callback); + + /** + *

HTTP method by which the callback request will be made

+ */ + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + _FinalStage sentiment(Optional sentiment); + + _FinalStage sentiment(Boolean sentiment); + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + _FinalStage summarize(Optional summarize); + + _FinalStage summarize(MediaTranscribeRequestSummarize summarize); + + /** + *

Detect topics throughout a transcript or text

+ */ + _FinalStage topics(Optional topics); + + _FinalStage topics(Boolean topics); + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + _FinalStage customTopicMode(Optional customTopicMode); + + _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + _FinalStage intents(Optional intents); + + _FinalStage intents(Boolean intents); + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + _FinalStage customIntentMode(Optional customIntentMode); + + _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(Boolean detectEntities); + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + _FinalStage detectLanguage(Optional detectLanguage); + + _FinalStage detectLanguage(Boolean detectLanguage); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(Boolean diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(Boolean dictation); + + /** + *

Specify the expected encoding of your submitted audio

+ */ + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(MediaTranscribeRequestEncoding encoding); + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + _FinalStage fillerWords(Optional fillerWords); + + _FinalStage fillerWords(Boolean fillerWords); + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + _FinalStage language(Optional language); + + _FinalStage language(String language); + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + _FinalStage measurements(Optional measurements); + + _FinalStage measurements(Boolean measurements); + + /** + *

AI model used to process submitted audio

+ */ + _FinalStage model(Optional model); + + _FinalStage model(MediaTranscribeRequestModel model); + + /** + *

Transcribe each audio channel independently

+ */ + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(Boolean multichannel); + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(Boolean numerals); + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + _FinalStage paragraphs(Optional paragraphs); + + _FinalStage paragraphs(Boolean paragraphs); + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(Boolean profanityFilter); + + /** + *

Add punctuation and capitalization to the transcript

+ */ + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(Boolean punctuate); + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + _FinalStage redact(Optional redact); + + _FinalStage redact(String redact); + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(Boolean smartFormat); + + /** + *

Segments speech into meaningful semantic units

+ */ + _FinalStage utterances(Optional utterances); + + _FinalStage utterances(Boolean utterances); + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + _FinalStage uttSplit(Optional uttSplit); + + _FinalStage uttSplit(Double uttSplit); + + /** + *

Version of an AI model to use

+ */ + _FinalStage version(Optional version); + + _FinalStage version(MediaTranscribeRequestVersion version); + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(Boolean mipOptOut); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements BodyStage, _FinalStage { + private byte[] body; + + private Optional mipOptOut = Optional.empty(); + + private Optional version = Optional.empty(); + + private Optional uttSplit = Optional.empty(); + + private Optional utterances = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional paragraphs = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional model = Optional.empty(); + + private Optional measurements = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional fillerWords = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectLanguage = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional customIntentMode = Optional.empty(); + + private Optional intents = Optional.empty(); + + private Optional customTopicMode = Optional.empty(); + + private Optional topics = Optional.empty(); + + private Optional summarize = Optional.empty(); + + private Optional sentiment = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + private Optional> search = Optional.empty(); + + private Optional> replace = Optional.empty(); + + private Optional> languageHint = Optional.empty(); + + private Optional> keywords = Optional.empty(); + + private Optional> keyterm = Optional.empty(); + + private Optional> customIntent = Optional.empty(); + + private Optional> customTopic = Optional.empty(); + + private Optional> tag = Optional.empty(); + + private Optional> extra = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(MediaTranscribeRequestOctetStream other) { + extra(other.getExtra()); + tag(other.getTag()); + customTopic(other.getCustomTopic()); + customIntent(other.getCustomIntent()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + languageHint(other.getLanguageHint()); + replace(other.getReplace()); + search(other.getSearch()); + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + sentiment(other.getSentiment()); + summarize(other.getSummarize()); + topics(other.getTopics()); + customTopicMode(other.getCustomTopicMode()); + intents(other.getIntents()); + customIntentMode(other.getCustomIntentMode()); + detectEntities(other.getDetectEntities()); + detectLanguage(other.getDetectLanguage()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + fillerWords(other.getFillerWords()); + language(other.getLanguage()); + measurements(other.getMeasurements()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + paragraphs(other.getParagraphs()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + smartFormat(other.getSmartFormat()); + utterances(other.getUtterances()); + uttSplit(other.getUttSplit()); + version(other.getVersion()); + mipOptOut(other.getMipOptOut()); + body(other.getBody()); + return this; + } + + @java.lang.Override + @JsonSetter("body") + public _FinalStage body(@NotNull byte[] body) { + this.body = Objects.requireNonNull(body, "body must not be null"); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage mipOptOut(Boolean mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + /** + *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

+ */ + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + /** + *

Version of an AI model to use

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage version(MediaTranscribeRequestVersion version) { + this.version = Optional.ofNullable(version); + return this; + } + + /** + *

Version of an AI model to use

+ */ + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage uttSplit(Double uttSplit) { + this.uttSplit = Optional.ofNullable(uttSplit); + return this; + } + + /** + *

Seconds to wait before detecting a pause between words in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) + public _FinalStage uttSplit(Optional uttSplit) { + this.uttSplit = uttSplit; + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage utterances(Boolean utterances) { + this.utterances = Optional.ofNullable(utterances); + return this; + } + + /** + *

Segments speech into meaningful semantic units

+ */ + @java.lang.Override + @JsonSetter(value = "utterances", nulls = Nulls.SKIP) + public _FinalStage utterances(Optional utterances) { + this.utterances = utterances; + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage smartFormat(Boolean smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + /** + *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

+ */ + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redact(String redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + /** + *

Redaction removes sensitive information from your transcripts

+ */ + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage punctuate(Boolean punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + /** + *

Add punctuation and capitalization to the transcript

+ */ + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage profanityFilter(Boolean profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + /** + *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

+ */ + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage paragraphs(Boolean paragraphs) { + this.paragraphs = Optional.ofNullable(paragraphs); + return this; + } + + /** + *

Splits audio into paragraphs to improve transcript readability

+ */ + @java.lang.Override + @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) + public _FinalStage paragraphs(Optional paragraphs) { + this.paragraphs = paragraphs; + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage numerals(Boolean numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + /** + *

Numerals converts numbers from written format to numerical format

+ */ + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + /** + *

Transcribe each audio channel independently

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage multichannel(Boolean multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + /** + *

Transcribe each audio channel independently

+ */ + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + /** + *

AI model used to process submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage model(MediaTranscribeRequestModel model) { + this.model = Optional.ofNullable(model); + return this; + } + + /** + *

AI model used to process submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "model", nulls = Nulls.SKIP) + public _FinalStage model(Optional model) { + this.model = model; + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage measurements(Boolean measurements) { + this.measurements = Optional.ofNullable(measurements); + return this; + } + + /** + *

Spoken measurements will be converted to their corresponding abbreviations

+ */ + @java.lang.Override + @JsonSetter(value = "measurements", nulls = Nulls.SKIP) + public _FinalStage measurements(Optional measurements) { + this.measurements = measurements; + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage language(String language) { + this.language = Optional.ofNullable(language); + return this; + } + + /** + *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

+ */ + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage fillerWords(Boolean fillerWords) { + this.fillerWords = Optional.ofNullable(fillerWords); + return this; + } + + /** + *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

+ */ + @java.lang.Override + @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) + public _FinalStage fillerWords(Optional fillerWords) { + this.fillerWords = fillerWords; + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + /** + *

Specify the expected encoding of your submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage dictation(Boolean dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + /** + *

Dictation mode for controlling formatting with dictated speech

+ */ + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(Boolean diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectLanguage(Boolean detectLanguage) { + this.detectLanguage = Optional.ofNullable(detectLanguage); + return this; + } + + /** + *

Identifies the dominant language spoken in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) + public _FinalStage detectLanguage(Optional detectLanguage) { + this.detectLanguage = detectLanguage; + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage detectEntities(Boolean detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + /** + *

Identifies and extracts key entities from content in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { + this.customIntentMode = Optional.ofNullable(customIntentMode); + return this; + } + + /** + *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) + public _FinalStage customIntentMode(Optional customIntentMode) { + this.customIntentMode = customIntentMode; + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage intents(Boolean intents) { + this.intents = Optional.ofNullable(intents); + return this; + } + + /** + *

Recognizes speaker intent throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "intents", nulls = Nulls.SKIP) + public _FinalStage intents(Optional intents) { + this.intents = intents; + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { + this.customTopicMode = Optional.ofNullable(customTopicMode); + return this; + } + + /** + *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) + public _FinalStage customTopicMode(Optional customTopicMode) { + this.customTopicMode = customTopicMode; + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage topics(Boolean topics) { + this.topics = Optional.ofNullable(topics); + return this; + } + + /** + *

Detect topics throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "topics", nulls = Nulls.SKIP) + public _FinalStage topics(Optional topics) { + this.topics = topics; + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { + this.summarize = Optional.ofNullable(summarize); + return this; + } + + /** + *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

+ */ + @java.lang.Override + @JsonSetter(value = "summarize", nulls = Nulls.SKIP) + public _FinalStage summarize(Optional summarize) { + this.summarize = summarize; + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sentiment(Boolean sentiment) { + this.sentiment = Optional.ofNullable(sentiment); + return this; + } + + /** + *

Recognizes the sentiment throughout a transcript or text

+ */ + @java.lang.Override + @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) + public _FinalStage sentiment(Optional sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + /** + *

HTTP method by which the callback request will be made

+ */ + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + /** + *

URL to which we'll make the callback request

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage callback(String callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + /** + *

URL to which we'll make the callback request

+ */ + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public _FinalStage search(String search) { + this.search = Optional.of(Collections.singletonList(search)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage search(List search) { + this.search = Optional.ofNullable(search); + return this; + } + + /** + *

Search for terms or phrases in submitted audio

+ */ + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional> search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage replace(String replace) { + this.replace = Optional.of(Collections.singletonList(replace)); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage replace(List replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + /** + *

Search for terms or phrases in submitted audio and replaces them

+ */ + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional> replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(String languageHint) { + this.languageHint = Optional.of(Collections.singletonList(languageHint)); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage languageHint(List languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

+ */ + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional> languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage keywords(String keywords) { + this.keywords = Optional.of(Collections.singletonList(keywords)); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keywords(List keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + /** + *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

+ */ + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional> keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(String keyterm) { + this.keyterm = Optional.of(Collections.singletonList(keyterm)); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage keyterm(List keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + /** + *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

+ *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

+ *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

+ */ + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional> keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage customIntent(String customIntent) { + this.customIntent = Optional.of(Collections.singletonList(customIntent)); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customIntent(List customIntent) { + this.customIntent = Optional.ofNullable(customIntent); + return this; + } + + /** + *

Custom intents you want the model to detect within your input audio if present

+ */ + @java.lang.Override + @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) + public _FinalStage customIntent(Optional> customIntent) { + this.customIntent = customIntent; + return this; + } + + @java.lang.Override + public _FinalStage customTopic(String customTopic) { + this.customTopic = Optional.of(Collections.singletonList(customTopic)); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage customTopic(List customTopic) { + this.customTopic = Optional.ofNullable(customTopic); + return this; + } + + /** + *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

+ */ + @java.lang.Override + @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) + public _FinalStage customTopic(Optional> customTopic) { + this.customTopic = customTopic; + return this; + } + + @java.lang.Override + public _FinalStage tag(String tag) { + this.tag = Optional.of(Collections.singletonList(tag)); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage tag(List tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + /** + *

Label your requests for the purpose of identification during usage reporting

+ */ + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional> tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage extra(String extra) { + this.extra = Optional.of(Collections.singletonList(extra)); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage extra(List extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + /** + *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

+ */ + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional> extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public MediaTranscribeRequestOctetStream build() { + return new MediaTranscribeRequestOctetStream( + extra, + tag, + customTopic, + customIntent, + keyterm, + keywords, + languageHint, + replace, + search, + callback, + callbackMethod, + sentiment, + summarize, + topics, + customTopicMode, + intents, + customIntentMode, + detectEntities, + detectLanguage, + diarize, + diarizeModel, + dictation, + encoding, + fillerWords, + language, + measurements, + model, + multichannel, + numerals, + paragraphs, + profanityFilter, + punctuate, + redact, + smartFormat, + utterances, + uttSplit, + version, + mipOptOut, + body, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak new file mode 100644 index 0000000..2694721 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak @@ -0,0 +1,1129 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.websocket; + +import com.deepgram.core.ObjectMappers; +import com.deepgram.resources.listen.v1.types.DiarizeModel; +import com.deepgram.types.ListenV1Callback; +import com.deepgram.types.ListenV1CallbackMethod; +import com.deepgram.types.ListenV1Channels; +import com.deepgram.types.ListenV1DetectEntities; +import com.deepgram.types.ListenV1Diarize; +import com.deepgram.types.ListenV1Dictation; +import com.deepgram.types.ListenV1Encoding; +import com.deepgram.types.ListenV1Endpointing; +import com.deepgram.types.ListenV1Extra; +import com.deepgram.types.ListenV1InterimResults; +import com.deepgram.types.ListenV1Keyterm; +import com.deepgram.types.ListenV1Keywords; +import com.deepgram.types.ListenV1Language; +import com.deepgram.types.ListenV1LanguageHint; +import com.deepgram.types.ListenV1MipOptOut; +import com.deepgram.types.ListenV1Model; +import com.deepgram.types.ListenV1Multichannel; +import com.deepgram.types.ListenV1Numerals; +import com.deepgram.types.ListenV1ProfanityFilter; +import com.deepgram.types.ListenV1Punctuate; +import com.deepgram.types.ListenV1Redact; +import com.deepgram.types.ListenV1Replace; +import com.deepgram.types.ListenV1SampleRate; +import com.deepgram.types.ListenV1Search; +import com.deepgram.types.ListenV1SmartFormat; +import com.deepgram.types.ListenV1Tag; +import com.deepgram.types.ListenV1UtteranceEndMs; +import com.deepgram.types.ListenV1VadEvents; +import com.deepgram.types.ListenV1Version; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = V1ConnectOptions.Builder.class) +public final class V1ConnectOptions { + private final Optional callback; + + private final Optional callbackMethod; + + private final Optional channels; + + private final Optional detectEntities; + + private final Optional diarize; + + private final Optional diarizeModel; + + private final Optional dictation; + + private final Optional encoding; + + private final Optional endpointing; + + private final Optional extra; + + private final Optional interimResults; + + private final Optional keyterm; + + private final Optional keywords; + + private final Optional language; + + private final Optional languageHint; + + private final Optional mipOptOut; + + private final ListenV1Model model; + + private final Optional multichannel; + + private final Optional numerals; + + private final Optional profanityFilter; + + private final Optional punctuate; + + private final Optional redact; + + private final Optional replace; + + private final Optional sampleRate; + + private final Optional search; + + private final Optional smartFormat; + + private final Optional tag; + + private final Optional utteranceEndMs; + + private final Optional vadEvents; + + private final Optional version; + + private final Map additionalProperties; + + private V1ConnectOptions( + Optional callback, + Optional callbackMethod, + Optional channels, + Optional detectEntities, + Optional diarize, + Optional diarizeModel, + Optional dictation, + Optional encoding, + Optional endpointing, + Optional extra, + Optional interimResults, + Optional keyterm, + Optional keywords, + Optional language, + Optional languageHint, + Optional mipOptOut, + ListenV1Model model, + Optional multichannel, + Optional numerals, + Optional profanityFilter, + Optional punctuate, + Optional redact, + Optional replace, + Optional sampleRate, + Optional search, + Optional smartFormat, + Optional tag, + Optional utteranceEndMs, + Optional vadEvents, + Optional version, + Map additionalProperties) { + this.callback = callback; + this.callbackMethod = callbackMethod; + this.channels = channels; + this.detectEntities = detectEntities; + this.diarize = diarize; + this.diarizeModel = diarizeModel; + this.dictation = dictation; + this.encoding = encoding; + this.endpointing = endpointing; + this.extra = extra; + this.interimResults = interimResults; + this.keyterm = keyterm; + this.keywords = keywords; + this.language = language; + this.languageHint = languageHint; + this.mipOptOut = mipOptOut; + this.model = model; + this.multichannel = multichannel; + this.numerals = numerals; + this.profanityFilter = profanityFilter; + this.punctuate = punctuate; + this.redact = redact; + this.replace = replace; + this.sampleRate = sampleRate; + this.search = search; + this.smartFormat = smartFormat; + this.tag = tag; + this.utteranceEndMs = utteranceEndMs; + this.vadEvents = vadEvents; + this.version = version; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("callback") + public Optional getCallback() { + return callback; + } + + @JsonProperty("callback_method") + public Optional getCallbackMethod() { + return callbackMethod; + } + + @JsonProperty("channels") + public Optional getChannels() { + return channels; + } + + @JsonProperty("detect_entities") + public Optional getDetectEntities() { + return detectEntities; + } + + /** + * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. + */ + @JsonProperty("diarize") + public Optional getDiarize() { + return diarize; + } + + /** + * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error. + */ + @JsonProperty("diarize_model") + public Optional getDiarizeModel() { + return diarizeModel; + } + + @JsonProperty("dictation") + public Optional getDictation() { + return dictation; + } + + @JsonProperty("encoding") + public Optional getEncoding() { + return encoding; + } + + @JsonProperty("endpointing") + public Optional getEndpointing() { + return endpointing; + } + + @JsonProperty("extra") + public Optional getExtra() { + return extra; + } + + @JsonProperty("interim_results") + public Optional getInterimResults() { + return interimResults; + } + + @JsonProperty("keyterm") + public Optional getKeyterm() { + return keyterm; + } + + @JsonProperty("keywords") + public Optional getKeywords() { + return keywords; + } + + @JsonProperty("language") + public Optional getLanguage() { + return language; + } + + @JsonProperty("language_hint") + public Optional getLanguageHint() { + return languageHint; + } + + @JsonProperty("mip_opt_out") + public Optional getMipOptOut() { + return mipOptOut; + } + + /** + * @return AI model to use for the transcription + */ + @JsonProperty("model") + public ListenV1Model getModel() { + return model; + } + + @JsonProperty("multichannel") + public Optional getMultichannel() { + return multichannel; + } + + @JsonProperty("numerals") + public Optional getNumerals() { + return numerals; + } + + @JsonProperty("profanity_filter") + public Optional getProfanityFilter() { + return profanityFilter; + } + + @JsonProperty("punctuate") + public Optional getPunctuate() { + return punctuate; + } + + @JsonProperty("redact") + public Optional getRedact() { + return redact; + } + + @JsonProperty("replace") + public Optional getReplace() { + return replace; + } + + @JsonProperty("sample_rate") + public Optional getSampleRate() { + return sampleRate; + } + + @JsonProperty("search") + public Optional getSearch() { + return search; + } + + @JsonProperty("smart_format") + public Optional getSmartFormat() { + return smartFormat; + } + + @JsonProperty("tag") + public Optional getTag() { + return tag; + } + + @JsonProperty("utterance_end_ms") + public Optional getUtteranceEndMs() { + return utteranceEndMs; + } + + @JsonProperty("vad_events") + public Optional getVadEvents() { + return vadEvents; + } + + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof V1ConnectOptions && equalTo((V1ConnectOptions) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(V1ConnectOptions other) { + return callback.equals(other.callback) + && callbackMethod.equals(other.callbackMethod) + && channels.equals(other.channels) + && detectEntities.equals(other.detectEntities) + && diarize.equals(other.diarize) + && diarizeModel.equals(other.diarizeModel) + && dictation.equals(other.dictation) + && encoding.equals(other.encoding) + && endpointing.equals(other.endpointing) + && extra.equals(other.extra) + && interimResults.equals(other.interimResults) + && keyterm.equals(other.keyterm) + && keywords.equals(other.keywords) + && language.equals(other.language) + && languageHint.equals(other.languageHint) + && mipOptOut.equals(other.mipOptOut) + && model.equals(other.model) + && multichannel.equals(other.multichannel) + && numerals.equals(other.numerals) + && profanityFilter.equals(other.profanityFilter) + && punctuate.equals(other.punctuate) + && redact.equals(other.redact) + && replace.equals(other.replace) + && sampleRate.equals(other.sampleRate) + && search.equals(other.search) + && smartFormat.equals(other.smartFormat) + && tag.equals(other.tag) + && utteranceEndMs.equals(other.utteranceEndMs) + && vadEvents.equals(other.vadEvents) + && version.equals(other.version); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.callback, + this.callbackMethod, + this.channels, + this.detectEntities, + this.diarize, + this.diarizeModel, + this.dictation, + this.encoding, + this.endpointing, + this.extra, + this.interimResults, + this.keyterm, + this.keywords, + this.language, + this.languageHint, + this.mipOptOut, + this.model, + this.multichannel, + this.numerals, + this.profanityFilter, + this.punctuate, + this.redact, + this.replace, + this.sampleRate, + this.search, + this.smartFormat, + this.tag, + this.utteranceEndMs, + this.vadEvents, + this.version); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static ModelStage builder() { + return new Builder(); + } + + public interface ModelStage { + /** + *

AI model to use for the transcription

+ */ + _FinalStage model(@NotNull ListenV1Model model); + + Builder from(V1ConnectOptions other); + } + + public interface _FinalStage { + V1ConnectOptions build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage callback(Optional callback); + + _FinalStage callback(ListenV1Callback callback); + + _FinalStage callbackMethod(Optional callbackMethod); + + _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod); + + _FinalStage channels(Optional channels); + + _FinalStage channels(ListenV1Channels channels); + + _FinalStage detectEntities(Optional detectEntities); + + _FinalStage detectEntities(ListenV1DetectEntities detectEntities); + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + _FinalStage diarize(Optional diarize); + + _FinalStage diarize(ListenV1Diarize diarize); + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ */ + _FinalStage diarizeModel(Optional diarizeModel); + + _FinalStage diarizeModel(DiarizeModel diarizeModel); + + _FinalStage dictation(Optional dictation); + + _FinalStage dictation(ListenV1Dictation dictation); + + _FinalStage encoding(Optional encoding); + + _FinalStage encoding(ListenV1Encoding encoding); + + _FinalStage endpointing(Optional endpointing); + + _FinalStage endpointing(ListenV1Endpointing endpointing); + + _FinalStage extra(Optional extra); + + _FinalStage extra(ListenV1Extra extra); + + _FinalStage interimResults(Optional interimResults); + + _FinalStage interimResults(ListenV1InterimResults interimResults); + + _FinalStage keyterm(Optional keyterm); + + _FinalStage keyterm(ListenV1Keyterm keyterm); + + _FinalStage keywords(Optional keywords); + + _FinalStage keywords(ListenV1Keywords keywords); + + _FinalStage language(Optional language); + + _FinalStage language(ListenV1Language language); + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(Optional languageHint) { + return this; + } + + /** + *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

+ */ + default _FinalStage languageHint(ListenV1LanguageHint languageHint) { + return this; + } + + _FinalStage mipOptOut(Optional mipOptOut); + + _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut); + + _FinalStage multichannel(Optional multichannel); + + _FinalStage multichannel(ListenV1Multichannel multichannel); + + _FinalStage numerals(Optional numerals); + + _FinalStage numerals(ListenV1Numerals numerals); + + _FinalStage profanityFilter(Optional profanityFilter); + + _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter); + + _FinalStage punctuate(Optional punctuate); + + _FinalStage punctuate(ListenV1Punctuate punctuate); + + _FinalStage redact(Optional redact); + + _FinalStage redact(ListenV1Redact redact); + + _FinalStage replace(Optional replace); + + _FinalStage replace(ListenV1Replace replace); + + _FinalStage sampleRate(Optional sampleRate); + + _FinalStage sampleRate(ListenV1SampleRate sampleRate); + + _FinalStage search(Optional search); + + _FinalStage search(ListenV1Search search); + + _FinalStage smartFormat(Optional smartFormat); + + _FinalStage smartFormat(ListenV1SmartFormat smartFormat); + + _FinalStage tag(Optional tag); + + _FinalStage tag(ListenV1Tag tag); + + _FinalStage utteranceEndMs(Optional utteranceEndMs); + + _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs); + + _FinalStage vadEvents(Optional vadEvents); + + _FinalStage vadEvents(ListenV1VadEvents vadEvents); + + _FinalStage version(Optional version); + + _FinalStage version(ListenV1Version version); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements ModelStage, _FinalStage { + private ListenV1Model model; + + private Optional version = Optional.empty(); + + private Optional vadEvents = Optional.empty(); + + private Optional utteranceEndMs = Optional.empty(); + + private Optional tag = Optional.empty(); + + private Optional smartFormat = Optional.empty(); + + private Optional search = Optional.empty(); + + private Optional sampleRate = Optional.empty(); + + private Optional replace = Optional.empty(); + + private Optional redact = Optional.empty(); + + private Optional punctuate = Optional.empty(); + + private Optional profanityFilter = Optional.empty(); + + private Optional numerals = Optional.empty(); + + private Optional multichannel = Optional.empty(); + + private Optional mipOptOut = Optional.empty(); + + private Optional languageHint = Optional.empty(); + + private Optional language = Optional.empty(); + + private Optional keywords = Optional.empty(); + + private Optional keyterm = Optional.empty(); + + private Optional interimResults = Optional.empty(); + + private Optional extra = Optional.empty(); + + private Optional endpointing = Optional.empty(); + + private Optional encoding = Optional.empty(); + + private Optional dictation = Optional.empty(); + + private Optional diarizeModel = Optional.empty(); + + private Optional diarize = Optional.empty(); + + private Optional detectEntities = Optional.empty(); + + private Optional channels = Optional.empty(); + + private Optional callbackMethod = Optional.empty(); + + private Optional callback = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(V1ConnectOptions other) { + callback(other.getCallback()); + callbackMethod(other.getCallbackMethod()); + channels(other.getChannels()); + detectEntities(other.getDetectEntities()); + diarize(other.getDiarize()); + diarizeModel(other.getDiarizeModel()); + dictation(other.getDictation()); + encoding(other.getEncoding()); + endpointing(other.getEndpointing()); + extra(other.getExtra()); + interimResults(other.getInterimResults()); + keyterm(other.getKeyterm()); + keywords(other.getKeywords()); + language(other.getLanguage()); + languageHint(other.getLanguageHint()); + mipOptOut(other.getMipOptOut()); + model(other.getModel()); + multichannel(other.getMultichannel()); + numerals(other.getNumerals()); + profanityFilter(other.getProfanityFilter()); + punctuate(other.getPunctuate()); + redact(other.getRedact()); + replace(other.getReplace()); + sampleRate(other.getSampleRate()); + search(other.getSearch()); + smartFormat(other.getSmartFormat()); + tag(other.getTag()); + utteranceEndMs(other.getUtteranceEndMs()); + vadEvents(other.getVadEvents()); + version(other.getVersion()); + return this; + } + + /** + *

AI model to use for the transcription

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("model") + public _FinalStage model(@NotNull ListenV1Model model) { + this.model = Objects.requireNonNull(model, "model must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage version(ListenV1Version version) { + this.version = Optional.ofNullable(version); + return this; + } + + @java.lang.Override + @JsonSetter(value = "version", nulls = Nulls.SKIP) + public _FinalStage version(Optional version) { + this.version = version; + return this; + } + + @java.lang.Override + public _FinalStage vadEvents(ListenV1VadEvents vadEvents) { + this.vadEvents = Optional.ofNullable(vadEvents); + return this; + } + + @java.lang.Override + @JsonSetter(value = "vad_events", nulls = Nulls.SKIP) + public _FinalStage vadEvents(Optional vadEvents) { + this.vadEvents = vadEvents; + return this; + } + + @java.lang.Override + public _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs) { + this.utteranceEndMs = Optional.ofNullable(utteranceEndMs); + return this; + } + + @java.lang.Override + @JsonSetter(value = "utterance_end_ms", nulls = Nulls.SKIP) + public _FinalStage utteranceEndMs(Optional utteranceEndMs) { + this.utteranceEndMs = utteranceEndMs; + return this; + } + + @java.lang.Override + public _FinalStage tag(ListenV1Tag tag) { + this.tag = Optional.ofNullable(tag); + return this; + } + + @java.lang.Override + @JsonSetter(value = "tag", nulls = Nulls.SKIP) + public _FinalStage tag(Optional tag) { + this.tag = tag; + return this; + } + + @java.lang.Override + public _FinalStage smartFormat(ListenV1SmartFormat smartFormat) { + this.smartFormat = Optional.ofNullable(smartFormat); + return this; + } + + @java.lang.Override + @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) + public _FinalStage smartFormat(Optional smartFormat) { + this.smartFormat = smartFormat; + return this; + } + + @java.lang.Override + public _FinalStage search(ListenV1Search search) { + this.search = Optional.ofNullable(search); + return this; + } + + @java.lang.Override + @JsonSetter(value = "search", nulls = Nulls.SKIP) + public _FinalStage search(Optional search) { + this.search = search; + return this; + } + + @java.lang.Override + public _FinalStage sampleRate(ListenV1SampleRate sampleRate) { + this.sampleRate = Optional.ofNullable(sampleRate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "sample_rate", nulls = Nulls.SKIP) + public _FinalStage sampleRate(Optional sampleRate) { + this.sampleRate = sampleRate; + return this; + } + + @java.lang.Override + public _FinalStage replace(ListenV1Replace replace) { + this.replace = Optional.ofNullable(replace); + return this; + } + + @java.lang.Override + @JsonSetter(value = "replace", nulls = Nulls.SKIP) + public _FinalStage replace(Optional replace) { + this.replace = replace; + return this; + } + + @java.lang.Override + public _FinalStage redact(ListenV1Redact redact) { + this.redact = Optional.ofNullable(redact); + return this; + } + + @java.lang.Override + @JsonSetter(value = "redact", nulls = Nulls.SKIP) + public _FinalStage redact(Optional redact) { + this.redact = redact; + return this; + } + + @java.lang.Override + public _FinalStage punctuate(ListenV1Punctuate punctuate) { + this.punctuate = Optional.ofNullable(punctuate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) + public _FinalStage punctuate(Optional punctuate) { + this.punctuate = punctuate; + return this; + } + + @java.lang.Override + public _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter) { + this.profanityFilter = Optional.ofNullable(profanityFilter); + return this; + } + + @java.lang.Override + @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) + public _FinalStage profanityFilter(Optional profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + @java.lang.Override + public _FinalStage numerals(ListenV1Numerals numerals) { + this.numerals = Optional.ofNullable(numerals); + return this; + } + + @java.lang.Override + @JsonSetter(value = "numerals", nulls = Nulls.SKIP) + public _FinalStage numerals(Optional numerals) { + this.numerals = numerals; + return this; + } + + @java.lang.Override + public _FinalStage multichannel(ListenV1Multichannel multichannel) { + this.multichannel = Optional.ofNullable(multichannel); + return this; + } + + @java.lang.Override + @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) + public _FinalStage multichannel(Optional multichannel) { + this.multichannel = multichannel; + return this; + } + + @java.lang.Override + public _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut) { + this.mipOptOut = Optional.ofNullable(mipOptOut); + return this; + } + + @java.lang.Override + @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) + public _FinalStage mipOptOut(Optional mipOptOut) { + this.mipOptOut = mipOptOut; + return this; + } + + @java.lang.Override + public _FinalStage languageHint(ListenV1LanguageHint languageHint) { + this.languageHint = Optional.ofNullable(languageHint); + return this; + } + + @java.lang.Override + @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) + public _FinalStage languageHint(Optional languageHint) { + this.languageHint = languageHint; + return this; + } + + @java.lang.Override + public _FinalStage language(ListenV1Language language) { + this.language = Optional.ofNullable(language); + return this; + } + + @java.lang.Override + @JsonSetter(value = "language", nulls = Nulls.SKIP) + public _FinalStage language(Optional language) { + this.language = language; + return this; + } + + @java.lang.Override + public _FinalStage keywords(ListenV1Keywords keywords) { + this.keywords = Optional.ofNullable(keywords); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keywords", nulls = Nulls.SKIP) + public _FinalStage keywords(Optional keywords) { + this.keywords = keywords; + return this; + } + + @java.lang.Override + public _FinalStage keyterm(ListenV1Keyterm keyterm) { + this.keyterm = Optional.ofNullable(keyterm); + return this; + } + + @java.lang.Override + @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) + public _FinalStage keyterm(Optional keyterm) { + this.keyterm = keyterm; + return this; + } + + @java.lang.Override + public _FinalStage interimResults(ListenV1InterimResults interimResults) { + this.interimResults = Optional.ofNullable(interimResults); + return this; + } + + @java.lang.Override + @JsonSetter(value = "interim_results", nulls = Nulls.SKIP) + public _FinalStage interimResults(Optional interimResults) { + this.interimResults = interimResults; + return this; + } + + @java.lang.Override + public _FinalStage extra(ListenV1Extra extra) { + this.extra = Optional.ofNullable(extra); + return this; + } + + @java.lang.Override + @JsonSetter(value = "extra", nulls = Nulls.SKIP) + public _FinalStage extra(Optional extra) { + this.extra = extra; + return this; + } + + @java.lang.Override + public _FinalStage endpointing(ListenV1Endpointing endpointing) { + this.endpointing = Optional.ofNullable(endpointing); + return this; + } + + @java.lang.Override + @JsonSetter(value = "endpointing", nulls = Nulls.SKIP) + public _FinalStage endpointing(Optional endpointing) { + this.endpointing = endpointing; + return this; + } + + @java.lang.Override + public _FinalStage encoding(ListenV1Encoding encoding) { + this.encoding = Optional.ofNullable(encoding); + return this; + } + + @java.lang.Override + @JsonSetter(value = "encoding", nulls = Nulls.SKIP) + public _FinalStage encoding(Optional encoding) { + this.encoding = encoding; + return this; + } + + @java.lang.Override + public _FinalStage dictation(ListenV1Dictation dictation) { + this.dictation = Optional.ofNullable(dictation); + return this; + } + + @java.lang.Override + @JsonSetter(value = "dictation", nulls = Nulls.SKIP) + public _FinalStage dictation(Optional dictation) { + this.dictation = dictation; + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarizeModel(DiarizeModel diarizeModel) { + this.diarizeModel = Optional.ofNullable(diarizeModel); + return this; + } + + /** + *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) + public _FinalStage diarizeModel(Optional diarizeModel) { + this.diarizeModel = diarizeModel; + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage diarize(ListenV1Diarize diarize) { + this.diarize = Optional.ofNullable(diarize); + return this; + } + + /** + *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

+ */ + @java.lang.Override + @JsonSetter(value = "diarize", nulls = Nulls.SKIP) + public _FinalStage diarize(Optional diarize) { + this.diarize = diarize; + return this; + } + + @java.lang.Override + public _FinalStage detectEntities(ListenV1DetectEntities detectEntities) { + this.detectEntities = Optional.ofNullable(detectEntities); + return this; + } + + @java.lang.Override + @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) + public _FinalStage detectEntities(Optional detectEntities) { + this.detectEntities = detectEntities; + return this; + } + + @java.lang.Override + public _FinalStage channels(ListenV1Channels channels) { + this.channels = Optional.ofNullable(channels); + return this; + } + + @java.lang.Override + @JsonSetter(value = "channels", nulls = Nulls.SKIP) + public _FinalStage channels(Optional channels) { + this.channels = channels; + return this; + } + + @java.lang.Override + public _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod) { + this.callbackMethod = Optional.ofNullable(callbackMethod); + return this; + } + + @java.lang.Override + @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) + public _FinalStage callbackMethod(Optional callbackMethod) { + this.callbackMethod = callbackMethod; + return this; + } + + @java.lang.Override + public _FinalStage callback(ListenV1Callback callback) { + this.callback = Optional.ofNullable(callback); + return this; + } + + @java.lang.Override + @JsonSetter(value = "callback", nulls = Nulls.SKIP) + public _FinalStage callback(Optional callback) { + this.callback = callback; + return this; + } + + @java.lang.Override + public V1ConnectOptions build() { + return new V1ConnectOptions( + callback, + callbackMethod, + channels, + detectEntities, + diarize, + diarizeModel, + dictation, + encoding, + endpointing, + extra, + interimResults, + keyterm, + keywords, + language, + languageHint, + mipOptOut, + model, + multichannel, + numerals, + profanityFilter, + punctuate, + redact, + replace, + sampleRate, + search, + smartFormat, + tag, + utteranceEndMs, + vadEvents, + version, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..885f60c --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,650 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.listen.v1.types.ListenV1CloseStream; +import com.deepgram.resources.listen.v1.types.ListenV1Configure; +import com.deepgram.resources.listen.v1.types.ListenV1ConfigureFailure; +import com.deepgram.resources.listen.v1.types.ListenV1ConfigureSuccess; +import com.deepgram.resources.listen.v1.types.ListenV1Error; +import com.deepgram.resources.listen.v1.types.ListenV1Finalize; +import com.deepgram.resources.listen.v1.types.ListenV1KeepAlive; +import com.deepgram.resources.listen.v1.types.ListenV1Metadata; +import com.deepgram.resources.listen.v1.types.ListenV1Results; +import com.deepgram.resources.listen.v1.types.ListenV1SpeechStarted; +import com.deepgram.resources.listen.v1.types.ListenV1UtteranceEnd; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer resultsHandler; + + private volatile Consumer metadataHandler; + + private volatile Consumer utteranceEndHandler; + + private volatile Consumer speechStartedHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V1ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v1/listen"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + if (options.getCallback() != null && options.getCallback().isPresent()) { + urlBuilder.addQueryParameter( + "callback", String.valueOf(options.getCallback().get())); + } + if (options.getCallbackMethod() != null && options.getCallbackMethod().isPresent()) { + urlBuilder.addQueryParameter( + "callback_method", + String.valueOf(options.getCallbackMethod().get())); + } + if (options.getChannels() != null && options.getChannels().isPresent()) { + urlBuilder.addQueryParameter( + "channels", String.valueOf(options.getChannels().get())); + } + if (options.getDetectEntities() != null && options.getDetectEntities().isPresent()) { + urlBuilder.addQueryParameter( + "detect_entities", + String.valueOf(options.getDetectEntities().get())); + } + if (options.getDiarize() != null && options.getDiarize().isPresent()) { + urlBuilder.addQueryParameter( + "diarize", String.valueOf(options.getDiarize().get())); + } + if (options.getDiarizeModel() != null && options.getDiarizeModel().isPresent()) { + urlBuilder.addQueryParameter( + "diarize_model", String.valueOf(options.getDiarizeModel().get())); + } + if (options.getDictation() != null && options.getDictation().isPresent()) { + urlBuilder.addQueryParameter( + "dictation", String.valueOf(options.getDictation().get())); + } + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getEndpointing() != null && options.getEndpointing().isPresent()) { + urlBuilder.addQueryParameter( + "endpointing", String.valueOf(options.getEndpointing().get())); + } + if (options.getExtra() != null && options.getExtra().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); + } + if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { + urlBuilder.addQueryParameter( + "interim_results", + String.valueOf(options.getInterimResults().get())); + } + if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + } + if (options.getKeywords() != null && options.getKeywords().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); + } + if (options.getLanguage() != null && options.getLanguage().isPresent()) { + urlBuilder.addQueryParameter( + "language", String.valueOf(options.getLanguage().get())); + } + if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getMultichannel() != null && options.getMultichannel().isPresent()) { + urlBuilder.addQueryParameter( + "multichannel", String.valueOf(options.getMultichannel().get())); + } + if (options.getNumerals() != null && options.getNumerals().isPresent()) { + urlBuilder.addQueryParameter( + "numerals", String.valueOf(options.getNumerals().get())); + } + if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { + urlBuilder.addQueryParameter( + "profanity_filter", + String.valueOf(options.getProfanityFilter().get())); + } + if (options.getPunctuate() != null && options.getPunctuate().isPresent()) { + urlBuilder.addQueryParameter( + "punctuate", String.valueOf(options.getPunctuate().get())); + } + if (options.getRedact() != null && options.getRedact().isPresent()) { + urlBuilder.addQueryParameter( + "redact", String.valueOf(options.getRedact().get())); + } + if (options.getReplace() != null && options.getReplace().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSearch() != null && options.getSearch().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); + } + if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { + urlBuilder.addQueryParameter( + "smart_format", String.valueOf(options.getSmartFormat().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { + urlBuilder.addQueryParameter( + "utterance_end_ms", + String.valueOf(options.getUtteranceEndMs().get())); + } + if (options.getVadEvents() != null && options.getVadEvents().isPresent()) { + urlBuilder.addQueryParameter( + "vad_events", String.valueOf(options.getVadEvents().get())); + } + if (options.getVersion() != null && options.getVersion().isPresent()) { + urlBuilder.addQueryParameter( + "version", String.valueOf(options.getVersion().get())); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a ListenV1Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Sends a ListenV1Finalize message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFinalize(ListenV1Finalize message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1CloseStream message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCloseStream(ListenV1CloseStream message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1KeepAlive message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendKeepAlive(ListenV1KeepAlive message) { + return sendMessage(message); + } + + /** + * Sends a ListenV1Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(ListenV1Configure message) { + return sendMessage(message); + } + + /** + * Registers a handler for ListenV1ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for ListenV1ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for ListenV1Results messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onResults(Consumer handler) { + this.resultsHandler = handler; + } + + /** + * Registers a handler for ListenV1Metadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onMetadata(Consumer handler) { + this.metadataHandler = handler; + } + + /** + * Registers a handler for ListenV1UtteranceEnd messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onUtteranceEnd(Consumer handler) { + this.utteranceEndHandler = handler; + } + + /** + * Registers a handler for ListenV1SpeechStarted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechStarted(Consumer handler) { + this.speechStartedHandler = handler; + } + + /** + * Registers a handler for ListenV1Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("transaction_key") + && node.has("request_id") + && node.has("sha256") + && node.has("created") + && node.has("duration") + && node.has("channels") + && "Metadata".equals(node.path("type").asText())) { + ListenV1Metadata metadataHandlerEvent = null; + try { + metadataHandlerEvent = objectMapper.treeToValue(node, ListenV1Metadata.class); + } catch (Exception e) { + } + if (metadataHandlerEvent != null) { + if (metadataHandler != null) { + metadataHandler.accept(metadataHandlerEvent); + } + return; + } + } + if (node.has("channel_index") + && node.has("duration") + && node.has("start") + && node.has("channel") + && node.has("metadata") + && "Results".equals(node.path("type").asText())) { + ListenV1Results resultsHandlerEvent = null; + try { + resultsHandlerEvent = objectMapper.treeToValue(node, ListenV1Results.class); + } catch (Exception e) { + } + if (resultsHandlerEvent != null) { + if (resultsHandler != null) { + resultsHandler.accept(resultsHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("code") + && node.has("description") + && "ConfigureFailure".equals(node.path("type").asText())) { + ListenV1ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); + } + return; + } + } + if (node.has("channel") + && node.has("last_word_end") + && "UtteranceEnd".equals(node.path("type").asText())) { + ListenV1UtteranceEnd utteranceEndHandlerEvent = null; + try { + utteranceEndHandlerEvent = objectMapper.treeToValue(node, ListenV1UtteranceEnd.class); + } catch (Exception e) { + } + if (utteranceEndHandlerEvent != null) { + if (utteranceEndHandler != null) { + utteranceEndHandler.accept(utteranceEndHandlerEvent); + } + return; + } + } + if (node.has("channel") + && node.has("timestamp") + && "SpeechStarted".equals(node.path("type").asText())) { + ListenV1SpeechStarted speechStartedHandlerEvent = null; + try { + speechStartedHandlerEvent = objectMapper.treeToValue(node, ListenV1SpeechStarted.class); + } catch (Exception e) { + } + if (speechStartedHandlerEvent != null) { + if (speechStartedHandler != null) { + speechStartedHandler.accept(speechStartedHandlerEvent); + } + return; + } + } + if (node.has("variant") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + ListenV1Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, ListenV1Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); + } + return; + } + } + if (node.has("request_id") + && "ConfigureSuccess".equals(node.path("type").asText())) { + ListenV1ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak new file mode 100644 index 0000000..c9f2f35 --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV2CloseStream.Builder.class) +public final class ListenV2CloseStream { + private final Map additionalProperties; + + private ListenV2CloseStream(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "CloseStream"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV2CloseStream; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListenV2CloseStream other) { + return this; + } + + public ListenV2CloseStream build() { + return new ListenV2CloseStream(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak new file mode 100644 index 0000000..894bd3c --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ListenV2ForceEndTurn.Builder.class) +public final class ListenV2ForceEndTurn { + private final Map additionalProperties; + + private ListenV2ForceEndTurn(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "ForceEndTurn"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ListenV2ForceEndTurn; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ListenV2ForceEndTurn other) { + return this; + } + + public ListenV2ForceEndTurn build() { + return new ListenV2ForceEndTurn(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak new file mode 100644 index 0000000..5f55fea --- /dev/null +++ b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak @@ -0,0 +1,563 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.listen.v2.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.listen.v2.types.ListenV2CloseStream; +import com.deepgram.resources.listen.v2.types.ListenV2Configure; +import com.deepgram.resources.listen.v2.types.ListenV2ConfigureFailure; +import com.deepgram.resources.listen.v2.types.ListenV2ConfigureSuccess; +import com.deepgram.resources.listen.v2.types.ListenV2Connected; +import com.deepgram.resources.listen.v2.types.ListenV2FatalError; +import com.deepgram.resources.listen.v2.types.ListenV2ForceEndTurn; +import com.deepgram.resources.listen.v2.types.ListenV2TurnInfo; +import com.deepgram.resources.listen.v2.types.ListenV2Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v2 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V2WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private final AtomicReference closeStreamSocket = new AtomicReference<>(); + + private volatile Consumer connectedHandler; + + private volatile Consumer turnInfoHandler; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v2 channel. + */ + public V2WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V2ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + closeStreamSocket.set(null); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v2/listen"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getEagerEotThreshold() != null + && options.getEagerEotThreshold().isPresent()) { + urlBuilder.addQueryParameter( + "eager_eot_threshold", + String.valueOf(options.getEagerEotThreshold().get())); + } + if (options.getEotThreshold() != null && options.getEotThreshold().isPresent()) { + urlBuilder.addQueryParameter( + "eot_threshold", String.valueOf(options.getEotThreshold().get())); + } + if (options.getEotTimeoutMs() != null && options.getEotTimeoutMs().isPresent()) { + urlBuilder.addQueryParameter( + "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); + } + if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + } + if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + } + if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { + urlBuilder.addQueryParameter( + "profanity_filter", + String.valueOf(options.getProfanityFilter().get())); + } + if (options.getNumerals() != null && options.getNumerals().isPresent()) { + urlBuilder.addQueryParameter( + "numerals", String.valueOf(options.getNumerals().get())); + } + if (options.getRedact() != null && options.getRedact().isPresent()) { + urlBuilder.addQueryParameter( + "redact", String.valueOf(options.getRedact().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + closeStreamSocket.set(null); + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + + @Override + protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { + return super.shouldReconnectAfterClose(webSocket, code, reason) + && (code != 1005 || closeStreamSocket.get() != webSocket); + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a ListenV2Media message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendMedia(ByteString message) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + // Use reconnecting listener's sendBinary method which handles queuing + reconnectingListener.sendBinary(message); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); + } + return future; + } + + /** + * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does + * not suppress reconnects because it might never reach the server. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendCloseStream(ListenV2CloseStream message) { + return sendMessage(message, closeStreamSocket::set); + } + + /** + * Sends a ListenV2ForceEndTurn message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendForceEndTurn(ListenV2ForceEndTurn message) { + return sendMessage(message); + } + + /** + * Sends a ListenV2Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(ListenV2Configure message) { + return sendMessage(message); + } + + /** + * Registers a handler for ListenV2Connected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConnected(Consumer handler) { + this.connectedHandler = handler; + } + + /** + * Registers a handler for ListenV2TurnInfo messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onTurnInfo(Consumer handler) { + this.turnInfoHandler = handler; + } + + /** + * Registers a handler for ListenV2ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for ListenV2ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for ListenV2Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for ListenV2FatalError messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + return sendMessage(body, null); + } + + private CompletableFuture sendMessage(Object body, Consumer onSent) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json, onSent); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("request_id") + && node.has("sequence_id") + && node.has("event") + && node.has("turn_index") + && node.has("audio_window_start") + && node.has("audio_window_end") + && node.has("transcript") + && node.has("words") + && node.has("end_of_turn_confidence") + && "TurnInfo".equals(node.path("type").asText())) { + ListenV2TurnInfo turnInfoHandlerEvent = null; + try { + turnInfoHandlerEvent = objectMapper.treeToValue(node, ListenV2TurnInfo.class); + } catch (Exception e) { + } + if (turnInfoHandlerEvent != null) { + if (turnInfoHandler != null) { + turnInfoHandler.accept(turnInfoHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("thresholds") + && node.has("keyterms") + && node.has("sequence_id") + && "ConfigureSuccess".equals(node.path("type").asText())) { + ListenV2ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && node.has("code") + && node.has("description") + && "Warning".equals(node.path("type").asText())) { + ListenV2Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, ListenV2Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("sequence_id") + && node.has("code") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + ListenV2FatalError errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, ListenV2FatalError.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && "Connected".equals(node.path("type").asText())) { + ListenV2Connected connectedHandlerEvent = null; + try { + connectedHandlerEvent = objectMapper.treeToValue(node, ListenV2Connected.class); + } catch (Exception e) { + } + if (connectedHandlerEvent != null) { + if (connectedHandler != null) { + connectedHandler.accept(connectedHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("sequence_id") + && "ConfigureFailure".equals(node.path("type").asText())) { + ListenV2ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } + return; + } + } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak new file mode 100644 index 0000000..e6824a3 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak @@ -0,0 +1,467 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v1.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.speak.v1.types.SpeakV1Clear; +import com.deepgram.resources.speak.v1.types.SpeakV1Cleared; +import com.deepgram.resources.speak.v1.types.SpeakV1Close; +import com.deepgram.resources.speak.v1.types.SpeakV1Flush; +import com.deepgram.resources.speak.v1.types.SpeakV1Flushed; +import com.deepgram.resources.speak.v1.types.SpeakV1Metadata; +import com.deepgram.resources.speak.v1.types.SpeakV1Text; +import com.deepgram.resources.speak.v1.types.SpeakV1Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v1 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V1WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer speakV1AudioHandler; + + private volatile Consumer metadataHandler; + + private volatile Consumer flushedHandler; + + private volatile Consumer clearedHandler; + + private volatile Consumer warningHandler; + + /** + * Creates a new async WebSocket client for the v1 channel. + */ + public V1WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V1ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v1/speak"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getModel() != null && options.getModel().isPresent()) { + urlBuilder.addQueryParameter( + "model", String.valueOf(options.getModel().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSpeed() != null && options.getSpeed().isPresent()) { + urlBuilder.addQueryParameter( + "speed", String.valueOf(options.getSpeed().get())); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (speakV1AudioHandler != null) { + speakV1AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Establishes the WebSocket connection asynchronously with default options. + * @return a CompletableFuture that completes when the connection is established + */ + public CompletableFuture connect() { + return connect(V1ConnectOptions.builder().build()); + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a SpeakV1Text message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendText(SpeakV1Text message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Flush message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFlush(SpeakV1Flush message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Clear message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClear(SpeakV1Clear message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV1Close message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClose(SpeakV1Close message) { + return sendMessage(message); + } + + /** + * Registers a handler for SpeakV1Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakV1Audio(Consumer handler) { + this.speakV1AudioHandler = handler; + } + + /** + * Registers a handler for SpeakV1Metadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onMetadata(Consumer handler) { + this.metadataHandler = handler; + } + + /** + * Registers a handler for SpeakV1Flushed messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFlushed(Consumer handler) { + this.flushedHandler = handler; + } + + /** + * Registers a handler for SpeakV1Cleared messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onCleared(Consumer handler) { + this.clearedHandler = handler; + } + + /** + * Registers a handler for SpeakV1Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("request_id") + && node.has("model_name") + && node.has("model_version") + && node.has("model_uuid") + && "Metadata".equals(node.path("type").asText())) { + SpeakV1Metadata metadataHandlerEvent = null; + try { + metadataHandlerEvent = objectMapper.treeToValue(node, SpeakV1Metadata.class); + } catch (Exception e) { + } + if (metadataHandlerEvent != null) { + if (metadataHandler != null) { + metadataHandler.accept(metadataHandlerEvent); + } + return; + } + } + if (node.has("description") + && node.has("code") + && "Warning".equals(node.path("type").asText())) { + SpeakV1Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, SpeakV1Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("type") && node.has("sequence_id")) { + SpeakV1Flushed flushedHandlerEvent = null; + try { + flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Flushed.class); + } catch (Exception e) { + } + if (flushedHandlerEvent != null) { + if (flushedHandler != null) { + flushedHandler.accept(flushedHandlerEvent); + } + return; + } + } + if (node.has("type") && node.has("sequence_id")) { + SpeakV1Cleared clearedHandlerEvent = null; + try { + clearedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Cleared.class); + } catch (Exception e) { + } + if (clearedHandlerEvent != null) { + if (clearedHandler != null) { + clearedHandler.accept(clearedHandlerEvent); + } + return; + } + } + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak new file mode 100644 index 0000000..7fecd79 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SpeakV2Close.Builder.class) +public final class SpeakV2Close { + private final Map additionalProperties; + + private SpeakV2Close(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "Close"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SpeakV2Close; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SpeakV2Close other) { + return this; + } + + public SpeakV2Close build() { + return new SpeakV2Close(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak new file mode 100644 index 0000000..f678e97 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak @@ -0,0 +1,121 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SpeakV2ConfigureFailureCode { + public static final SpeakV2ConfigureFailureCode CONTROL_COMBINATION_INVALID = + new SpeakV2ConfigureFailureCode(Value.CONTROL_COMBINATION_INVALID, "CONTROL_COMBINATION_INVALID"); + + public static final SpeakV2ConfigureFailureCode SPEED_OUT_OF_RANGE = + new SpeakV2ConfigureFailureCode(Value.SPEED_OUT_OF_RANGE, "SPEED_OUT_OF_RANGE"); + + public static final SpeakV2ConfigureFailureCode SPEED_INCREMENT_INVALID = + new SpeakV2ConfigureFailureCode(Value.SPEED_INCREMENT_INVALID, "SPEED_INCREMENT_INVALID"); + + public static final SpeakV2ConfigureFailureCode INTERNAL_ERROR = + new SpeakV2ConfigureFailureCode(Value.INTERNAL_ERROR, "INTERNAL_ERROR"); + + public static final SpeakV2ConfigureFailureCode SPEED_NOT_SUPPORTED = + new SpeakV2ConfigureFailureCode(Value.SPEED_NOT_SUPPORTED, "SPEED_NOT_SUPPORTED"); + + private final Value value; + + private final String string; + + SpeakV2ConfigureFailureCode(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SpeakV2ConfigureFailureCode + && this.string.equals(((SpeakV2ConfigureFailureCode) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTROL_COMBINATION_INVALID: + return visitor.visitControlCombinationInvalid(); + case SPEED_OUT_OF_RANGE: + return visitor.visitSpeedOutOfRange(); + case SPEED_INCREMENT_INVALID: + return visitor.visitSpeedIncrementInvalid(); + case INTERNAL_ERROR: + return visitor.visitInternalError(); + case SPEED_NOT_SUPPORTED: + return visitor.visitSpeedNotSupported(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SpeakV2ConfigureFailureCode valueOf(String value) { + switch (value) { + case "CONTROL_COMBINATION_INVALID": + return CONTROL_COMBINATION_INVALID; + case "SPEED_OUT_OF_RANGE": + return SPEED_OUT_OF_RANGE; + case "SPEED_INCREMENT_INVALID": + return SPEED_INCREMENT_INVALID; + case "INTERNAL_ERROR": + return INTERNAL_ERROR; + case "SPEED_NOT_SUPPORTED": + return SPEED_NOT_SUPPORTED; + default: + return new SpeakV2ConfigureFailureCode(Value.UNKNOWN, value); + } + } + + public enum Value { + SPEED_OUT_OF_RANGE, + + SPEED_INCREMENT_INVALID, + + SPEED_NOT_SUPPORTED, + + CONTROL_COMBINATION_INVALID, + + INTERNAL_ERROR, + + UNKNOWN + } + + public interface Visitor { + T visitSpeedOutOfRange(); + + T visitSpeedIncrementInvalid(); + + T visitSpeedNotSupported(); + + default T visitControlCombinationInvalid() { + return visitUnknown("CONTROL_COMBINATION_INVALID"); + } + + T visitInternalError(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak new file mode 100644 index 0000000..130da0d --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.types; + +import com.deepgram.core.ObjectMappers; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = SpeakV2Flush.Builder.class) +public final class SpeakV2Flush { + private final Map additionalProperties; + + private SpeakV2Flush(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + /** + * @return Message type identifier + */ + @JsonProperty("type") + public String getType() { + return "Flush"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof SpeakV2Flush; + } + + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(SpeakV2Flush other) { + return this; + } + + public SpeakV2Flush build() { + return new SpeakV2Flush(additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak new file mode 100644 index 0000000..b4e01f7 --- /dev/null +++ b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak @@ -0,0 +1,630 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.resources.speak.v2.websocket; + +import com.deepgram.core.ClientOptions; +import com.deepgram.core.DisconnectReason; +import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; +import com.deepgram.core.ReconnectingWebSocketListener; +import com.deepgram.core.RequestOptions; +import com.deepgram.core.WebSocketReadyState; +import com.deepgram.resources.speak.v2.types.SpeakV2Close; +import com.deepgram.resources.speak.v2.types.SpeakV2Configure; +import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureFailure; +import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureSuccess; +import com.deepgram.resources.speak.v2.types.SpeakV2Connected; +import com.deepgram.resources.speak.v2.types.SpeakV2Error; +import com.deepgram.resources.speak.v2.types.SpeakV2Flush; +import com.deepgram.resources.speak.v2.types.SpeakV2Flushed; +import com.deepgram.resources.speak.v2.types.SpeakV2Interrupt; +import com.deepgram.resources.speak.v2.types.SpeakV2SessionMetadata; +import com.deepgram.resources.speak.v2.types.SpeakV2Speak; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechInterrupted; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechMetadata; +import com.deepgram.resources.speak.v2.types.SpeakV2SpeechStarted; +import com.deepgram.resources.speak.v2.types.SpeakV2Warning; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Consumer; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.WebSocket; +import okio.ByteString; + +/** + * WebSocket client for the v2 channel. + * Provides real-time bidirectional communication with strongly-typed messages. + */ +public class V2WebSocketClient implements AutoCloseable { + protected final ClientOptions clientOptions; + + private final ObjectMapper objectMapper; + + private final OkHttpClient okHttpClient; + + private ScheduledExecutorService timeoutExecutor; + + private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; + + private volatile Runnable onConnectedHandler; + + private volatile Consumer onDisconnectedHandler; + + private volatile Consumer onErrorHandler; + + private volatile Consumer onMessageHandler; + + private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; + + private CompletableFuture connectionFuture; + + private ReconnectingWebSocketListener reconnectingListener; + + private volatile Consumer speakV2AudioHandler; + + private volatile Consumer connectedHandler; + + private volatile Consumer speechStartedHandler; + + private volatile Consumer speechMetadataHandler; + + private volatile Consumer speechInterruptedHandler; + + private volatile Consumer flushedHandler; + + private volatile Consumer sessionMetadataHandler; + + private volatile Consumer configureSuccessHandler; + + private volatile Consumer configureFailureHandler; + + private volatile Consumer warningHandler; + + private volatile Consumer errorHandler; + + /** + * Creates a new async WebSocket client for the v2 channel. + */ + public V2WebSocketClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.objectMapper = ObjectMappers.JSON_MAPPER; + this.okHttpClient = clientOptions.httpClient(); + } + + /** + * Establishes the WebSocket connection asynchronously with automatic reconnection. + * @return a CompletableFuture that completes when the connection is established + * @param options connection options including query parameters + */ + public CompletableFuture connect(V2ConnectOptions options) { + connectionFuture = new CompletableFuture<>(); + String baseUrl = clientOptions.environment().getProductionURL(); + String fullPath = "/v2/speak"; + if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { + fullPath = fullPath.substring(1); + } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { + fullPath = "/" + fullPath; + } + // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing + if (baseUrl.startsWith("wss://")) { + baseUrl = "https://" + baseUrl.substring(6); + } else if (baseUrl.startsWith("ws://")) { + baseUrl = "http://" + baseUrl.substring(5); + } + HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); + if (parsedUrl == null) { + throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); + } + HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); + urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); + if (options.getEncoding() != null && options.getEncoding().isPresent()) { + urlBuilder.addQueryParameter( + "encoding", String.valueOf(options.getEncoding().get())); + } + if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { + urlBuilder.addQueryParameter( + "sample_rate", String.valueOf(options.getSampleRate().get())); + } + if (options.getSpeed() != null && options.getSpeed().isPresent()) { + urlBuilder.addQueryParameter( + "speed", String.valueOf(options.getSpeed().get())); + } + if (options.getExpressivity() != null && options.getExpressivity().isPresent()) { + urlBuilder.addQueryParameter( + "expressivity", String.valueOf(options.getExpressivity().get())); + } + if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { + urlBuilder.addQueryParameter( + "mip_opt_out", String.valueOf(options.getMipOptOut().get())); + } + if (options.getTag() != null && options.getTag().isPresent()) { + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } + Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); + clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); + final Request request = requestBuilder.build(); + this.readyState = WebSocketReadyState.CONNECTING; + ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null + ? this.reconnectOptions + : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); + this.reconnectingListener = + new ReconnectingWebSocketListener( + reconnectOpts, + () -> { + if (clientOptions.isClosed()) { + throw new IllegalStateException("root client has been closed"); + } + if (clientOptions.webSocketFactory().isPresent()) { + return clientOptions + .webSocketFactory() + .get() + .create(request, this.reconnectingListener); + } else { + return okHttpClient.newWebSocket(request, this.reconnectingListener); + } + }, + clientOptions::isClosed) { + @Override + protected void onWebSocketOpen(WebSocket webSocket, Response response) { + readyState = WebSocketReadyState.OPEN; + if (onConnectedHandler != null) { + onConnectedHandler.run(); + } + connectionFuture.complete(null); + } + + @Override + protected void onWebSocketMessage(WebSocket webSocket, String text) { + handleIncomingMessage(text); + } + + @Override + protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { + if (speakV2AudioHandler != null) { + speakV2AudioHandler.accept(bytes); + } + } + + @Override + protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { + readyState = WebSocketReadyState.CLOSED; + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException(t)); + } + connectionFuture.completeExceptionally(t); + } + + @Override + protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { + readyState = WebSocketReadyState.CLOSED; + if (onDisconnectedHandler != null) { + onDisconnectedHandler.accept(new DisconnectReason(code, reason)); + } + } + }; + clientOptions.registerWebSocket(this); + reconnectingListener.connect(); + return connectionFuture; + } + + /** + * Disconnects the WebSocket connection and releases resources. + */ + public void disconnect() { + clientOptions.unregisterWebSocket(this); + if (reconnectingListener != null) { + reconnectingListener.disconnect(); + } + if (timeoutExecutor != null) { + timeoutExecutor.shutdownNow(); + timeoutExecutor = null; + } + } + + /** + * Gets the current state of the WebSocket connection. + * + * This provides the actual connection state, similar to the W3C WebSocket API. + * + * @return the current WebSocket ready state + */ + public WebSocketReadyState getReadyState() { + return readyState; + } + + /** + * Sends a SpeakV2Speak message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendSpeak(SpeakV2Speak message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Flush message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendFlush(SpeakV2Flush message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Interrupt message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendInterrupt(SpeakV2Interrupt message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Configure message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendConfigure(SpeakV2Configure message) { + return sendMessage(message); + } + + /** + * Sends a SpeakV2Close message to the server asynchronously. + * @param message the message to send + * @return a CompletableFuture that completes when the message is sent + */ + public CompletableFuture sendClose(SpeakV2Close message) { + return sendMessage(message); + } + + /** + * Registers a handler for SpeakV2Audio messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeakV2Audio(Consumer handler) { + this.speakV2AudioHandler = handler; + } + + /** + * Registers a handler for SpeakV2Connected messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConnected(Consumer handler) { + this.connectedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechStarted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechStarted(Consumer handler) { + this.speechStartedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechMetadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechMetadata(Consumer handler) { + this.speechMetadataHandler = handler; + } + + /** + * Registers a handler for SpeakV2SpeechInterrupted messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSpeechInterrupted(Consumer handler) { + this.speechInterruptedHandler = handler; + } + + /** + * Registers a handler for SpeakV2Flushed messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onFlushed(Consumer handler) { + this.flushedHandler = handler; + } + + /** + * Registers a handler for SpeakV2SessionMetadata messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onSessionMetadata(Consumer handler) { + this.sessionMetadataHandler = handler; + } + + /** + * Registers a handler for SpeakV2ConfigureSuccess messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureSuccess(Consumer handler) { + this.configureSuccessHandler = handler; + } + + /** + * Registers a handler for SpeakV2ConfigureFailure messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onConfigureFailure(Consumer handler) { + this.configureFailureHandler = handler; + } + + /** + * Registers a handler for SpeakV2Warning messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onWarning(Consumer handler) { + this.warningHandler = handler; + } + + /** + * Registers a handler for SpeakV2Error messages from the server. + * @param handler the handler to invoke when a message is received + */ + public void onErrorMessage(Consumer handler) { + this.errorHandler = handler; + } + + /** + * Registers a handler called when the connection is established. + * @param handler the handler to invoke when connected + */ + public void onConnected(Runnable handler) { + this.onConnectedHandler = handler; + } + + /** + * Registers a handler called when the connection is closed. + * @param handler the handler to invoke when disconnected + */ + public void onDisconnected(Consumer handler) { + this.onDisconnectedHandler = handler; + } + + /** + * Registers a handler called when an error occurs. + * @param handler the handler to invoke on error + */ + public void onError(Consumer handler) { + this.onErrorHandler = handler; + } + + /** + * Registers a handler called for every incoming text message. + * The handler receives the raw JSON string before type-specific dispatch. + * @param handler the handler to invoke with the raw message JSON + */ + public void onMessage(Consumer handler) { + this.onMessageHandler = handler; + } + + /** + * Configures reconnection behavior. Must be called before {@link #connect}. + * + * @param options the reconnection options (backoff, retries, queue size) + */ + public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { + this.reconnectOptions = options; + } + + /** + * Closes this WebSocket client, releasing all resources. + * Equivalent to calling {@link #disconnect()}. + */ + @Override + public void close() { + disconnect(); + } + + /** + * Ensures the WebSocket is connected and ready to send messages. + * @throws IllegalStateException if the socket is not connected or not open + */ + private void assertSocketIsOpen() { + if (reconnectingListener.getWebSocket() == null) { + throw new IllegalStateException("WebSocket is not connected. Call connect() first."); + } + if (readyState != WebSocketReadyState.OPEN) { + throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); + } + } + + private CompletableFuture sendMessage(Object body) { + CompletableFuture future = new CompletableFuture<>(); + try { + assertSocketIsOpen(); + String json = objectMapper.writeValueAsString(body); + // Use reconnecting listener's send method which handles queuing + reconnectingListener.send(json); + future.complete(null); + } catch (IllegalStateException e) { + future.completeExceptionally(e); + } catch (Exception e) { + future.completeExceptionally(new RuntimeException("Failed to send message", e)); + } + return future; + } + + private void handleIncomingMessage(String json) { + try { + if (onMessageHandler != null) { + onMessageHandler.accept(json); + } + JsonNode node = objectMapper.readTree(json); + if (node == null || node.isNull()) { + throw new IllegalArgumentException("Received null or invalid JSON message"); + } + if (node.has("speech_id") + && node.has("audio_duration_ms") + && node.has("input_character_count") + && node.has("billable_character_count") + && node.has("controls_applied") + && "SpeechMetadata".equals(node.path("type").asText())) { + SpeakV2SpeechMetadata speechMetadataHandlerEvent = null; + try { + speechMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechMetadata.class); + } catch (Exception e) { + } + if (speechMetadataHandlerEvent != null) { + if (speechMetadataHandler != null) { + speechMetadataHandler.accept(speechMetadataHandlerEvent); + } + return; + } + } + if (node.has("request_id") + && node.has("model_name") + && node.has("model_version") + && node.has("model_uuids") + && "Connected".equals(node.path("type").asText())) { + SpeakV2Connected connectedHandlerEvent = null; + try { + connectedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Connected.class); + } catch (Exception e) { + } + if (connectedHandlerEvent != null) { + if (connectedHandler != null) { + connectedHandler.accept(connectedHandlerEvent); + } + return; + } + } + if (node.has("total_audio_duration_ms") + && node.has("total_input_character_count") + && node.has("total_billable_character_count") + && "SessionMetadata".equals(node.path("type").asText())) { + SpeakV2SessionMetadata sessionMetadataHandlerEvent = null; + try { + sessionMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SessionMetadata.class); + } catch (Exception e) { + } + if (sessionMetadataHandlerEvent != null) { + if (sessionMetadataHandler != null) { + sessionMetadataHandler.accept(sessionMetadataHandlerEvent); + } + return; + } + } + if (node.has("audio_played_ms") + && node.has("metadata") + && "SpeechInterrupted".equals(node.path("type").asText())) { + SpeakV2SpeechInterrupted speechInterruptedHandlerEvent = null; + try { + speechInterruptedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechInterrupted.class); + } catch (Exception e) { + } + if (speechInterruptedHandlerEvent != null) { + if (speechInterruptedHandler != null) { + speechInterruptedHandler.accept(speechInterruptedHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "ConfigureFailure".equals(node.path("type").asText())) { + SpeakV2ConfigureFailure configureFailureHandlerEvent = null; + try { + configureFailureHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureFailure.class); + } catch (Exception e) { + } + if (configureFailureHandlerEvent != null) { + if (configureFailureHandler != null) { + configureFailureHandler.accept(configureFailureHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "Warning".equals(node.path("type").asText())) { + SpeakV2Warning warningHandlerEvent = null; + try { + warningHandlerEvent = objectMapper.treeToValue(node, SpeakV2Warning.class); + } catch (Exception e) { + } + if (warningHandlerEvent != null) { + if (warningHandler != null) { + warningHandler.accept(warningHandlerEvent); + } + return; + } + } + if (node.has("code") + && node.has("description") + && "Error".equals(node.path("type").asText())) { + SpeakV2Error errorHandlerEvent = null; + try { + errorHandlerEvent = objectMapper.treeToValue(node, SpeakV2Error.class); + } catch (Exception e) { + } + if (errorHandlerEvent != null) { + if (errorHandler != null) { + errorHandler.accept(errorHandlerEvent); + } + return; + } + } + if (node.has("speech_id") + && "SpeechStarted".equals(node.path("type").asText())) { + SpeakV2SpeechStarted speechStartedHandlerEvent = null; + try { + speechStartedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechStarted.class); + } catch (Exception e) { + } + if (speechStartedHandlerEvent != null) { + if (speechStartedHandler != null) { + speechStartedHandler.accept(speechStartedHandlerEvent); + } + return; + } + } + if (node.has("speech_id") && "Flushed".equals(node.path("type").asText())) { + SpeakV2Flushed flushedHandlerEvent = null; + try { + flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Flushed.class); + } catch (Exception e) { + } + if (flushedHandlerEvent != null) { + if (flushedHandler != null) { + flushedHandler.accept(flushedHandlerEvent); + } + return; + } + } + if (node.has("applied") + && "ConfigureSuccess".equals(node.path("type").asText())) { + SpeakV2ConfigureSuccess configureSuccessHandlerEvent = null; + try { + configureSuccessHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureSuccess.class); + } catch (Exception e) { + } + if (configureSuccessHandlerEvent != null) { + if (configureSuccessHandler != null) { + configureSuccessHandler.accept(configureSuccessHandlerEvent); + } + return; + } + } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. + } catch (Exception e) { + if (onErrorHandler != null) { + onErrorHandler.accept(e); + } + } + } +} diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java.bak b/src/main/java/com/deepgram/types/DeepgramModel.java.bak new file mode 100644 index 0000000..9fa2f8b --- /dev/null +++ b/src/main/java/com/deepgram/types/DeepgramModel.java.bak @@ -0,0 +1,1081 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class DeepgramModel { + public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); + + public static final DeepgramModel AURA2HERA_EN = new DeepgramModel(Value.AURA2HERA_EN, "aura-2-hera-en"); + + public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); + + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); + + public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); + + public static final DeepgramModel AURA2HARMONIA_EN = + new DeepgramModel(Value.AURA2HARMONIA_EN, "aura-2-harmonia-en"); + + public static final DeepgramModel AURA2CARINA_ES = new DeepgramModel(Value.AURA2CARINA_ES, "aura-2-carina-es"); + + public static final DeepgramModel FLUX_MEENA_EN = new DeepgramModel(Value.FLUX_MEENA_EN, "flux-meena-en"); + + public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); + + public static final DeepgramModel AURA_ZEUS_EN = new DeepgramModel(Value.AURA_ZEUS_EN, "aura-zeus-en"); + + public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); + + public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); + + public static final DeepgramModel AURA2NEPTUNE_EN = new DeepgramModel(Value.AURA2NEPTUNE_EN, "aura-2-neptune-en"); + + public static final DeepgramModel FLUX_BROOKE_EN = new DeepgramModel(Value.FLUX_BROOKE_EN, "flux-brooke-en"); + + public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); + + public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); + + public static final DeepgramModel AURA2CALLISTA_EN = + new DeepgramModel(Value.AURA2CALLISTA_EN, "aura-2-callista-en"); + + public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); + + public static final DeepgramModel AURA2OPHELIA_EN = new DeepgramModel(Value.AURA2OPHELIA_EN, "aura-2-ophelia-en"); + + public static final DeepgramModel FLUX_BRUCE_EN = new DeepgramModel(Value.FLUX_BRUCE_EN, "flux-bruce-en"); + + public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); + + public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); + + public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); + + public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); + + public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); + + public static final DeepgramModel FLUX_MARCUS_EN = new DeepgramModel(Value.FLUX_MARCUS_EN, "flux-marcus-en"); + + public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); + + public static final DeepgramModel FLUX_PAIGE_EN = new DeepgramModel(Value.FLUX_PAIGE_EN, "flux-paige-en"); + + public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); + + public static final DeepgramModel FLUX_DREW_EN = new DeepgramModel(Value.FLUX_DREW_EN, "flux-drew-en"); + + public static final DeepgramModel AURA2JAVIER_ES = new DeepgramModel(Value.AURA2JAVIER_ES, "aura-2-javier-es"); + + public static final DeepgramModel AURA2ANDROMEDA_EN = + new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); + + public static final DeepgramModel AURA2SATURN_EN = new DeepgramModel(Value.AURA2SATURN_EN, "aura-2-saturn-en"); + + public static final DeepgramModel AURA2IRIS_EN = new DeepgramModel(Value.AURA2IRIS_EN, "aura-2-iris-en"); + + public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); + + public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); + + public static final DeepgramModel FLUX_BRITTANY_EN = new DeepgramModel(Value.FLUX_BRITTANY_EN, "flux-brittany-en"); + + public static final DeepgramModel FLUX_SEAN_EN = new DeepgramModel(Value.FLUX_SEAN_EN, "flux-sean-en"); + + public static final DeepgramModel AURA2HELENA_EN = new DeepgramModel(Value.AURA2HELENA_EN, "aura-2-helena-en"); + + public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); + + public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); + + public static final DeepgramModel FLUX_JACK_EN = new DeepgramModel(Value.FLUX_JACK_EN, "flux-jack-en"); + + public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); + + public static final DeepgramModel FLUX_PRIYA_EN = new DeepgramModel(Value.FLUX_PRIYA_EN, "flux-priya-en"); + + public static final DeepgramModel AURA_HELIOS_EN = new DeepgramModel(Value.AURA_HELIOS_EN, "aura-helios-en"); + + public static final DeepgramModel AURA2JANUS_EN = new DeepgramModel(Value.AURA2JANUS_EN, "aura-2-janus-en"); + + public static final DeepgramModel AURA2NESTOR_ES = new DeepgramModel(Value.AURA2NESTOR_ES, "aura-2-nestor-es"); + + public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); + + public static final DeepgramModel AURA2MINERVA_EN = new DeepgramModel(Value.AURA2MINERVA_EN, "aura-2-minerva-en"); + + public static final DeepgramModel AURA2ALVARO_ES = new DeepgramModel(Value.AURA2ALVARO_ES, "aura-2-alvaro-es"); + + public static final DeepgramModel AURA_PERSEUS_EN = new DeepgramModel(Value.AURA_PERSEUS_EN, "aura-perseus-en"); + + public static final DeepgramModel AURA2VESTA_EN = new DeepgramModel(Value.AURA2VESTA_EN, "aura-2-vesta-en"); + + public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); + + public static final DeepgramModel AURA2ZEUS_EN = new DeepgramModel(Value.AURA2ZEUS_EN, "aura-2-zeus-en"); + + public static final DeepgramModel AURA2ORPHEUS_EN = new DeepgramModel(Value.AURA2ORPHEUS_EN, "aura-2-orpheus-en"); + + public static final DeepgramModel AURA2THALIA_EN = new DeepgramModel(Value.AURA2THALIA_EN, "aura-2-thalia-en"); + + public static final DeepgramModel FLUX_NAVEEN_EN = new DeepgramModel(Value.FLUX_NAVEEN_EN, "flux-naveen-en"); + + public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); + + public static final DeepgramModel AURA2SELENA_ES = new DeepgramModel(Value.AURA2SELENA_ES, "aura-2-selena-es"); + + public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); + + public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); + + public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); + + public static final DeepgramModel AURA_LUNA_EN = new DeepgramModel(Value.AURA_LUNA_EN, "aura-luna-en"); + + public static final DeepgramModel AURA_ORPHEUS_EN = new DeepgramModel(Value.AURA_ORPHEUS_EN, "aura-orpheus-en"); + + public static final DeepgramModel AURA2AMALTHEA_EN = + new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); + + public static final DeepgramModel FLUX_DONOVAN_EN = new DeepgramModel(Value.FLUX_DONOVAN_EN, "flux-donovan-en"); + + public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); + + public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); + + public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); + + public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); + + public static final DeepgramModel AURA2PHOEBE_EN = new DeepgramModel(Value.AURA2PHOEBE_EN, "aura-2-phoebe-en"); + + public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); + + public static final DeepgramModel AURA2DIANA_ES = new DeepgramModel(Value.AURA2DIANA_ES, "aura-2-diana-es"); + + public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); + + public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); + + public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); + + public static final DeepgramModel AURA2THEIA_EN = new DeepgramModel(Value.AURA2THEIA_EN, "aura-2-theia-en"); + + public static final DeepgramModel FLUX_WADE_EN = new DeepgramModel(Value.FLUX_WADE_EN, "flux-wade-en"); + + public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); + + public static final DeepgramModel FLUX_CLIFF_EN = new DeepgramModel(Value.FLUX_CLIFF_EN, "flux-cliff-en"); + + public static final DeepgramModel AURA2JUPITER_EN = new DeepgramModel(Value.AURA2JUPITER_EN, "aura-2-jupiter-en"); + + public static final DeepgramModel FLUX_KIT_EN = new DeepgramModel(Value.FLUX_KIT_EN, "flux-kit-en"); + + public static final DeepgramModel AURA2AQUILA_ES = new DeepgramModel(Value.AURA2AQUILA_ES, "aura-2-aquila-es"); + + public static final DeepgramModel AURA2CORA_EN = new DeepgramModel(Value.AURA2CORA_EN, "aura-2-cora-en"); + + public static final DeepgramModel AURA2CORDELIA_EN = + new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); + + public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); + + public static final DeepgramModel AURA2HYPERION_EN = + new DeepgramModel(Value.AURA2HYPERION_EN, "aura-2-hyperion-en"); + + public static final DeepgramModel AURA2CELESTE_ES = new DeepgramModel(Value.AURA2CELESTE_ES, "aura-2-celeste-es"); + + public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); + + public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); + + public static final DeepgramModel AURA2ARCAS_EN = new DeepgramModel(Value.AURA2ARCAS_EN, "aura-2-arcas-en"); + + public static final DeepgramModel FLUX_COLIN_EN = new DeepgramModel(Value.FLUX_COLIN_EN, "flux-colin-en"); + + public static final DeepgramModel AURA_ATHENA_EN = new DeepgramModel(Value.AURA_ATHENA_EN, "aura-athena-en"); + + public static final DeepgramModel AURA2ODYSSEUS_EN = + new DeepgramModel(Value.AURA2ODYSSEUS_EN, "aura-2-odysseus-en"); + + public static final DeepgramModel AURA2PANDORA_EN = new DeepgramModel(Value.AURA2PANDORA_EN, "aura-2-pandora-en"); + + public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); + + public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); + + public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); + + public static final DeepgramModel FLUX_GEMMA_EN = new DeepgramModel(Value.FLUX_GEMMA_EN, "flux-gemma-en"); + + public static final DeepgramModel AURA2ESTRELLA_ES = + new DeepgramModel(Value.AURA2ESTRELLA_ES, "aura-2-estrella-es"); + + private final Value value; + + private final String string; + + DeepgramModel(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof DeepgramModel && this.string.equals(((DeepgramModel) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case AURA2SIRIO_ES: + return visitor.visitAura2SirioEs(); + case AURA2HERA_EN: + return visitor.visitAura2HeraEn(); + case FLUX_KELSEY_EN: + return visitor.visitFluxKelseyEn(); + case FLUX_RENEE_EN: + return visitor.visitFluxReneeEn(); + case FLUX_SIENNA_EN: + return visitor.visitFluxSiennaEn(); + case AURA2HARMONIA_EN: + return visitor.visitAura2HarmoniaEn(); + case AURA2CARINA_ES: + return visitor.visitAura2CarinaEs(); + case FLUX_MEENA_EN: + return visitor.visitFluxMeenaEn(); + case FLUX_MEGHAN_EN: + return visitor.visitFluxMeghanEn(); + case AURA_ZEUS_EN: + return visitor.visitAuraZeusEn(); + case AURA2HERMES_EN: + return visitor.visitAura2HermesEn(); + case FLUX_CONOR_EN: + return visitor.visitFluxConorEn(); + case AURA2NEPTUNE_EN: + return visitor.visitAura2NeptuneEn(); + case FLUX_BROOKE_EN: + return visitor.visitFluxBrookeEn(); + case FLUX_RUFUS_EN: + return visitor.visitFluxRufusEn(); + case FLUX_WES_EN: + return visitor.visitFluxWesEn(); + case AURA2CALLISTA_EN: + return visitor.visitAura2CallistaEn(); + case AURA2AURORA_EN: + return visitor.visitAura2AuroraEn(); + case AURA2OPHELIA_EN: + return visitor.visitAura2OpheliaEn(); + case FLUX_BRUCE_EN: + return visitor.visitFluxBruceEn(); + case AURA2APOLLO_EN: + return visitor.visitAura2ApolloEn(); + case AURA2DELIA_EN: + return visitor.visitAura2DeliaEn(); + case AURA2MARS_EN: + return visitor.visitAura2MarsEn(); + case AURA_HERA_EN: + return visitor.visitAuraHeraEn(); + case FLUX_MAEVE_EN: + return visitor.visitFluxMaeveEn(); + case FLUX_MARCUS_EN: + return visitor.visitFluxMarcusEn(); + case AURA2ARIES_EN: + return visitor.visitAura2AriesEn(); + case FLUX_PAIGE_EN: + return visitor.visitFluxPaigeEn(); + case AURA2JUNO_EN: + return visitor.visitAura2JunoEn(); + case FLUX_DREW_EN: + return visitor.visitFluxDrewEn(); + case AURA2JAVIER_ES: + return visitor.visitAura2JavierEs(); + case AURA2ANDROMEDA_EN: + return visitor.visitAura2AndromedaEn(); + case AURA2SATURN_EN: + return visitor.visitAura2SaturnEn(); + case AURA2IRIS_EN: + return visitor.visitAura2IrisEn(); + case AURA_ANGUS_EN: + return visitor.visitAuraAngusEn(); + case FLUX_KAI_EN: + return visitor.visitFluxKaiEn(); + case FLUX_BRITTANY_EN: + return visitor.visitFluxBrittanyEn(); + case FLUX_SEAN_EN: + return visitor.visitFluxSeanEn(); + case AURA2HELENA_EN: + return visitor.visitAura2HelenaEn(); + case FLUX_HALEY_EN: + return visitor.visitFluxHaleyEn(); + case AURA_STELLA_EN: + return visitor.visitAuraStellaEn(); + case FLUX_JACK_EN: + return visitor.visitFluxJackEn(); + case AURA2DRACO_EN: + return visitor.visitAura2DracoEn(); + case FLUX_PRIYA_EN: + return visitor.visitFluxPriyaEn(); + case AURA_HELIOS_EN: + return visitor.visitAuraHeliosEn(); + case AURA2JANUS_EN: + return visitor.visitAura2JanusEn(); + case AURA2NESTOR_ES: + return visitor.visitAura2NestorEs(); + case AURA2ORION_EN: + return visitor.visitAura2OrionEn(); + case AURA2MINERVA_EN: + return visitor.visitAura2MinervaEn(); + case AURA2ALVARO_ES: + return visitor.visitAura2AlvaroEs(); + case AURA_PERSEUS_EN: + return visitor.visitAuraPerseusEn(); + case AURA2VESTA_EN: + return visitor.visitAura2VestaEn(); + case FLUX_COLE_EN: + return visitor.visitFluxColeEn(); + case AURA2ZEUS_EN: + return visitor.visitAura2ZeusEn(); + case AURA2ORPHEUS_EN: + return visitor.visitAura2OrpheusEn(); + case AURA2THALIA_EN: + return visitor.visitAura2ThaliaEn(); + case FLUX_NAVEEN_EN: + return visitor.visitFluxNaveenEn(); + case AURA2ASTERIA_EN: + return visitor.visitAura2AsteriaEn(); + case AURA2SELENA_ES: + return visitor.visitAura2SelenaEs(); + case FLUX_MARCELO_EN: + return visitor.visitFluxMarceloEn(); + case FLUX_ELISE_EN: + return visitor.visitFluxEliseEn(); + case FLUX_ALEXIS_EN: + return visitor.visitFluxAlexisEn(); + case AURA_LUNA_EN: + return visitor.visitAuraLunaEn(); + case AURA_ORPHEUS_EN: + return visitor.visitAuraOrpheusEn(); + case AURA2AMALTHEA_EN: + return visitor.visitAura2AmaltheaEn(); + case FLUX_DONOVAN_EN: + return visitor.visitFluxDonovanEn(); + case AURA2SELENE_EN: + return visitor.visitAura2SeleneEn(); + case FLUX_TANNER_EN: + return visitor.visitFluxTannerEn(); + case FLUX_SHARON_EN: + return visitor.visitFluxSharonEn(); + case AURA2LUNA_EN: + return visitor.visitAura2LunaEn(); + case AURA2PHOEBE_EN: + return visitor.visitAura2PhoebeEn(); + case FLUX_HANNAH_EN: + return visitor.visitFluxHannahEn(); + case AURA2DIANA_ES: + return visitor.visitAura2DianaEs(); + case AURA_ORION_EN: + return visitor.visitAuraOrionEn(); + case AURA2ATHENA_EN: + return visitor.visitAura2AthenaEn(); + case AURA_ARCAS_EN: + return visitor.visitAuraArcasEn(); + case AURA2THEIA_EN: + return visitor.visitAura2TheiaEn(); + case FLUX_WADE_EN: + return visitor.visitFluxWadeEn(); + case FLUX_HEATHER_EN: + return visitor.visitFluxHeatherEn(); + case FLUX_CLIFF_EN: + return visitor.visitFluxCliffEn(); + case AURA2JUPITER_EN: + return visitor.visitAura2JupiterEn(); + case FLUX_KIT_EN: + return visitor.visitFluxKitEn(); + case AURA2AQUILA_ES: + return visitor.visitAura2AquilaEs(); + case AURA2CORA_EN: + return visitor.visitAura2CoraEn(); + case AURA2CORDELIA_EN: + return visitor.visitAura2CordeliaEn(); + case AURA2ATLAS_EN: + return visitor.visitAura2AtlasEn(); + case AURA2HYPERION_EN: + return visitor.visitAura2HyperionEn(); + case AURA2CELESTE_ES: + return visitor.visitAura2CelesteEs(); + case AURA2PLUTO_EN: + return visitor.visitAura2PlutoEn(); + case FLUX_BREE_EN: + return visitor.visitFluxBreeEn(); + case AURA2ARCAS_EN: + return visitor.visitAura2ArcasEn(); + case FLUX_COLIN_EN: + return visitor.visitFluxColinEn(); + case AURA_ATHENA_EN: + return visitor.visitAuraAthenaEn(); + case AURA2ODYSSEUS_EN: + return visitor.visitAura2OdysseusEn(); + case AURA2PANDORA_EN: + return visitor.visitAura2PandoraEn(); + case FLUX_MILES_EN: + return visitor.visitFluxMilesEn(); + case AURA_ASTERIA_EN: + return visitor.visitAuraAsteriaEn(); + case AURA2ELECTRA_EN: + return visitor.visitAura2ElectraEn(); + case FLUX_GEMMA_EN: + return visitor.visitFluxGemmaEn(); + case AURA2ESTRELLA_ES: + return visitor.visitAura2EstrellaEs(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static DeepgramModel valueOf(String value) { + switch (value) { + case "aura-2-sirio-es": + return AURA2SIRIO_ES; + case "aura-2-hera-en": + return AURA2HERA_EN; + case "flux-kelsey-en": + return FLUX_KELSEY_EN; + case "flux-renee-en": + return FLUX_RENEE_EN; + case "flux-sienna-en": + return FLUX_SIENNA_EN; + case "aura-2-harmonia-en": + return AURA2HARMONIA_EN; + case "aura-2-carina-es": + return AURA2CARINA_ES; + case "flux-meena-en": + return FLUX_MEENA_EN; + case "flux-meghan-en": + return FLUX_MEGHAN_EN; + case "aura-zeus-en": + return AURA_ZEUS_EN; + case "aura-2-hermes-en": + return AURA2HERMES_EN; + case "flux-conor-en": + return FLUX_CONOR_EN; + case "aura-2-neptune-en": + return AURA2NEPTUNE_EN; + case "flux-brooke-en": + return FLUX_BROOKE_EN; + case "flux-rufus-en": + return FLUX_RUFUS_EN; + case "flux-wes-en": + return FLUX_WES_EN; + case "aura-2-callista-en": + return AURA2CALLISTA_EN; + case "aura-2-aurora-en": + return AURA2AURORA_EN; + case "aura-2-ophelia-en": + return AURA2OPHELIA_EN; + case "flux-bruce-en": + return FLUX_BRUCE_EN; + case "aura-2-apollo-en": + return AURA2APOLLO_EN; + case "aura-2-delia-en": + return AURA2DELIA_EN; + case "aura-2-mars-en": + return AURA2MARS_EN; + case "aura-hera-en": + return AURA_HERA_EN; + case "flux-maeve-en": + return FLUX_MAEVE_EN; + case "flux-marcus-en": + return FLUX_MARCUS_EN; + case "aura-2-aries-en": + return AURA2ARIES_EN; + case "flux-paige-en": + return FLUX_PAIGE_EN; + case "aura-2-juno-en": + return AURA2JUNO_EN; + case "flux-drew-en": + return FLUX_DREW_EN; + case "aura-2-javier-es": + return AURA2JAVIER_ES; + case "aura-2-andromeda-en": + return AURA2ANDROMEDA_EN; + case "aura-2-saturn-en": + return AURA2SATURN_EN; + case "aura-2-iris-en": + return AURA2IRIS_EN; + case "aura-angus-en": + return AURA_ANGUS_EN; + case "flux-kai-en": + return FLUX_KAI_EN; + case "flux-brittany-en": + return FLUX_BRITTANY_EN; + case "flux-sean-en": + return FLUX_SEAN_EN; + case "aura-2-helena-en": + return AURA2HELENA_EN; + case "flux-haley-en": + return FLUX_HALEY_EN; + case "aura-stella-en": + return AURA_STELLA_EN; + case "flux-jack-en": + return FLUX_JACK_EN; + case "aura-2-draco-en": + return AURA2DRACO_EN; + case "flux-priya-en": + return FLUX_PRIYA_EN; + case "aura-helios-en": + return AURA_HELIOS_EN; + case "aura-2-janus-en": + return AURA2JANUS_EN; + case "aura-2-nestor-es": + return AURA2NESTOR_ES; + case "aura-2-orion-en": + return AURA2ORION_EN; + case "aura-2-minerva-en": + return AURA2MINERVA_EN; + case "aura-2-alvaro-es": + return AURA2ALVARO_ES; + case "aura-perseus-en": + return AURA_PERSEUS_EN; + case "aura-2-vesta-en": + return AURA2VESTA_EN; + case "flux-cole-en": + return FLUX_COLE_EN; + case "aura-2-zeus-en": + return AURA2ZEUS_EN; + case "aura-2-orpheus-en": + return AURA2ORPHEUS_EN; + case "aura-2-thalia-en": + return AURA2THALIA_EN; + case "flux-naveen-en": + return FLUX_NAVEEN_EN; + case "aura-2-asteria-en": + return AURA2ASTERIA_EN; + case "aura-2-selena-es": + return AURA2SELENA_ES; + case "flux-marcelo-en": + return FLUX_MARCELO_EN; + case "flux-elise-en": + return FLUX_ELISE_EN; + case "flux-alexis-en": + return FLUX_ALEXIS_EN; + case "aura-luna-en": + return AURA_LUNA_EN; + case "aura-orpheus-en": + return AURA_ORPHEUS_EN; + case "aura-2-amalthea-en": + return AURA2AMALTHEA_EN; + case "flux-donovan-en": + return FLUX_DONOVAN_EN; + case "aura-2-selene-en": + return AURA2SELENE_EN; + case "flux-tanner-en": + return FLUX_TANNER_EN; + case "flux-sharon-en": + return FLUX_SHARON_EN; + case "aura-2-luna-en": + return AURA2LUNA_EN; + case "aura-2-phoebe-en": + return AURA2PHOEBE_EN; + case "flux-hannah-en": + return FLUX_HANNAH_EN; + case "aura-2-diana-es": + return AURA2DIANA_ES; + case "aura-orion-en": + return AURA_ORION_EN; + case "aura-2-athena-en": + return AURA2ATHENA_EN; + case "aura-arcas-en": + return AURA_ARCAS_EN; + case "aura-2-theia-en": + return AURA2THEIA_EN; + case "flux-wade-en": + return FLUX_WADE_EN; + case "flux-heather-en": + return FLUX_HEATHER_EN; + case "flux-cliff-en": + return FLUX_CLIFF_EN; + case "aura-2-jupiter-en": + return AURA2JUPITER_EN; + case "flux-kit-en": + return FLUX_KIT_EN; + case "aura-2-aquila-es": + return AURA2AQUILA_ES; + case "aura-2-cora-en": + return AURA2CORA_EN; + case "aura-2-cordelia-en": + return AURA2CORDELIA_EN; + case "aura-2-atlas-en": + return AURA2ATLAS_EN; + case "aura-2-hyperion-en": + return AURA2HYPERION_EN; + case "aura-2-celeste-es": + return AURA2CELESTE_ES; + case "aura-2-pluto-en": + return AURA2PLUTO_EN; + case "flux-bree-en": + return FLUX_BREE_EN; + case "aura-2-arcas-en": + return AURA2ARCAS_EN; + case "flux-colin-en": + return FLUX_COLIN_EN; + case "aura-athena-en": + return AURA_ATHENA_EN; + case "aura-2-odysseus-en": + return AURA2ODYSSEUS_EN; + case "aura-2-pandora-en": + return AURA2PANDORA_EN; + case "flux-miles-en": + return FLUX_MILES_EN; + case "aura-asteria-en": + return AURA_ASTERIA_EN; + case "aura-2-electra-en": + return AURA2ELECTRA_EN; + case "flux-gemma-en": + return FLUX_GEMMA_EN; + case "aura-2-estrella-es": + return AURA2ESTRELLA_ES; + default: + return new DeepgramModel(Value.UNKNOWN, value); + } + } + + public enum Value { + AURA_ASTERIA_EN, + + AURA_LUNA_EN, + + AURA_STELLA_EN, + + AURA_ATHENA_EN, + + AURA_HERA_EN, + + AURA_ORION_EN, + + AURA_ARCAS_EN, + + AURA_PERSEUS_EN, + + AURA_ANGUS_EN, + + AURA_ORPHEUS_EN, + + AURA_HELIOS_EN, + + AURA_ZEUS_EN, + + AURA2AMALTHEA_EN, + + AURA2ANDROMEDA_EN, + + AURA2APOLLO_EN, + + AURA2ARCAS_EN, + + AURA2ARIES_EN, + + AURA2ASTERIA_EN, + + AURA2ATHENA_EN, + + AURA2ATLAS_EN, + + AURA2AURORA_EN, + + AURA2CALLISTA_EN, + + AURA2CORA_EN, + + AURA2CORDELIA_EN, + + AURA2DELIA_EN, + + AURA2DRACO_EN, + + AURA2ELECTRA_EN, + + AURA2HARMONIA_EN, + + AURA2HELENA_EN, + + AURA2HERA_EN, + + AURA2HERMES_EN, + + AURA2HYPERION_EN, + + AURA2IRIS_EN, + + AURA2JANUS_EN, + + AURA2JUNO_EN, + + AURA2JUPITER_EN, + + AURA2LUNA_EN, + + AURA2MARS_EN, + + AURA2MINERVA_EN, + + AURA2NEPTUNE_EN, + + AURA2ODYSSEUS_EN, + + AURA2OPHELIA_EN, + + AURA2ORION_EN, + + AURA2ORPHEUS_EN, + + AURA2PANDORA_EN, + + AURA2PHOEBE_EN, + + AURA2PLUTO_EN, + + AURA2SATURN_EN, + + AURA2SELENE_EN, + + AURA2THALIA_EN, + + AURA2THEIA_EN, + + AURA2VESTA_EN, + + AURA2ZEUS_EN, + + AURA2SIRIO_ES, + + AURA2NESTOR_ES, + + AURA2CARINA_ES, + + AURA2CELESTE_ES, + + AURA2ALVARO_ES, + + AURA2DIANA_ES, + + AURA2AQUILA_ES, + + AURA2SELENA_ES, + + AURA2ESTRELLA_ES, + + AURA2JAVIER_ES, + + FLUX_ALEXIS_EN, + + FLUX_BREE_EN, + + FLUX_BRITTANY_EN, + + FLUX_BROOKE_EN, + + FLUX_BRUCE_EN, + + FLUX_CLIFF_EN, + + FLUX_COLE_EN, + + FLUX_COLIN_EN, + + FLUX_CONOR_EN, + + FLUX_DONOVAN_EN, + + FLUX_DREW_EN, + + FLUX_ELISE_EN, + + FLUX_GEMMA_EN, + + FLUX_HALEY_EN, + + FLUX_HANNAH_EN, + + FLUX_HEATHER_EN, + + FLUX_JACK_EN, + + FLUX_KAI_EN, + + FLUX_KELSEY_EN, + + FLUX_RENEE_EN, + + FLUX_KIT_EN, + + FLUX_MAEVE_EN, + + FLUX_MARCELO_EN, + + FLUX_MARCUS_EN, + + FLUX_MEENA_EN, + + FLUX_MEGHAN_EN, + + FLUX_MILES_EN, + + FLUX_NAVEEN_EN, + + FLUX_PAIGE_EN, + + FLUX_PRIYA_EN, + + FLUX_RUFUS_EN, + + FLUX_SEAN_EN, + + FLUX_SHARON_EN, + + FLUX_SIENNA_EN, + + FLUX_TANNER_EN, + + FLUX_WADE_EN, + + FLUX_WES_EN, + + UNKNOWN + } + + public interface Visitor { + T visitAuraAsteriaEn(); + + T visitAuraLunaEn(); + + T visitAuraStellaEn(); + + T visitAuraAthenaEn(); + + T visitAuraHeraEn(); + + T visitAuraOrionEn(); + + T visitAuraArcasEn(); + + T visitAuraPerseusEn(); + + T visitAuraAngusEn(); + + T visitAuraOrpheusEn(); + + T visitAuraHeliosEn(); + + T visitAuraZeusEn(); + + T visitAura2AmaltheaEn(); + + T visitAura2AndromedaEn(); + + T visitAura2ApolloEn(); + + T visitAura2ArcasEn(); + + T visitAura2AriesEn(); + + T visitAura2AsteriaEn(); + + T visitAura2AthenaEn(); + + T visitAura2AtlasEn(); + + T visitAura2AuroraEn(); + + T visitAura2CallistaEn(); + + T visitAura2CoraEn(); + + T visitAura2CordeliaEn(); + + T visitAura2DeliaEn(); + + T visitAura2DracoEn(); + + T visitAura2ElectraEn(); + + T visitAura2HarmoniaEn(); + + T visitAura2HelenaEn(); + + T visitAura2HeraEn(); + + T visitAura2HermesEn(); + + T visitAura2HyperionEn(); + + T visitAura2IrisEn(); + + T visitAura2JanusEn(); + + T visitAura2JunoEn(); + + T visitAura2JupiterEn(); + + T visitAura2LunaEn(); + + T visitAura2MarsEn(); + + T visitAura2MinervaEn(); + + T visitAura2NeptuneEn(); + + T visitAura2OdysseusEn(); + + T visitAura2OpheliaEn(); + + T visitAura2OrionEn(); + + T visitAura2OrpheusEn(); + + T visitAura2PandoraEn(); + + T visitAura2PhoebeEn(); + + T visitAura2PlutoEn(); + + T visitAura2SaturnEn(); + + T visitAura2SeleneEn(); + + T visitAura2ThaliaEn(); + + T visitAura2TheiaEn(); + + T visitAura2VestaEn(); + + T visitAura2ZeusEn(); + + T visitAura2SirioEs(); + + T visitAura2NestorEs(); + + T visitAura2CarinaEs(); + + T visitAura2CelesteEs(); + + T visitAura2AlvaroEs(); + + T visitAura2DianaEs(); + + T visitAura2AquilaEs(); + + T visitAura2SelenaEs(); + + T visitAura2EstrellaEs(); + + T visitAura2JavierEs(); + + T visitFluxAlexisEn(); + + T visitFluxBreeEn(); + + T visitFluxBrittanyEn(); + + T visitFluxBrookeEn(); + + T visitFluxBruceEn(); + + T visitFluxCliffEn(); + + T visitFluxColeEn(); + + T visitFluxColinEn(); + + T visitFluxConorEn(); + + T visitFluxDonovanEn(); + + T visitFluxDrewEn(); + + T visitFluxEliseEn(); + + T visitFluxGemmaEn(); + + T visitFluxHaleyEn(); + + T visitFluxHannahEn(); + + T visitFluxHeatherEn(); + + T visitFluxJackEn(); + + T visitFluxKaiEn(); + + T visitFluxKelseyEn(); + + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + T visitFluxReneeEn(); + + T visitFluxKitEn(); + + T visitFluxMaeveEn(); + + T visitFluxMarceloEn(); + + T visitFluxMarcusEn(); + + T visitFluxMeenaEn(); + + T visitFluxMeghanEn(); + + T visitFluxMilesEn(); + + T visitFluxNaveenEn(); + + T visitFluxPaigeEn(); + + T visitFluxPriyaEn(); + + T visitFluxRufusEn(); + + T visitFluxSeanEn(); + + T visitFluxSharonEn(); + + T visitFluxSiennaEn(); + + T visitFluxTannerEn(); + + T visitFluxWadeEn(); + + T visitFluxWesEn(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak new file mode 100644 index 0000000..d093a02 --- /dev/null +++ b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak @@ -0,0 +1,458 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Objects; +import java.util.Optional; + +public final class ThinkSettingsV1Provider { + private final Value value; + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + private ThinkSettingsV1Provider(Value value) { + this.value = value; + } + + public T visit(Visitor visitor) { + return value.visit(visitor); + } + + public static ThinkSettingsV1Provider openAi(OpenAiThinkProvider value) { + return new ThinkSettingsV1Provider(new OpenAiValue(value)); + } + + public static ThinkSettingsV1Provider awsBedrock(AwsBedrockThinkProvider value) { + return new ThinkSettingsV1Provider(new AwsBedrockValue(value)); + } + + public static ThinkSettingsV1Provider anthropic(Anthropic value) { + return new ThinkSettingsV1Provider(new AnthropicValue(value)); + } + + public static ThinkSettingsV1Provider google(Google value) { + return new ThinkSettingsV1Provider(new GoogleValue(value)); + } + + public static ThinkSettingsV1Provider groq(Groq value) { + return new ThinkSettingsV1Provider(new GroqValue(value)); + } + + public static ThinkSettingsV1Provider deepgram(DeepgramThinkProvider value) { + return new ThinkSettingsV1Provider(new DeepgramValue(value)); + } + + public boolean isOpenAi() { + return value instanceof OpenAiValue; + } + + public boolean isAwsBedrock() { + return value instanceof AwsBedrockValue; + } + + public boolean isAnthropic() { + return value instanceof AnthropicValue; + } + + public boolean isGoogle() { + return value instanceof GoogleValue; + } + + public boolean isGroq() { + return value instanceof GroqValue; + } + + public boolean isDeepgram() { + return value instanceof DeepgramValue; + } + + public boolean _isUnknown() { + return value instanceof _UnknownValue; + } + + public Optional getOpenAi() { + if (isOpenAi()) { + return Optional.of(((OpenAiValue) value).value); + } + return Optional.empty(); + } + + public Optional getAwsBedrock() { + if (isAwsBedrock()) { + return Optional.of(((AwsBedrockValue) value).value); + } + return Optional.empty(); + } + + public Optional getAnthropic() { + if (isAnthropic()) { + return Optional.of(((AnthropicValue) value).value); + } + return Optional.empty(); + } + + public Optional getGoogle() { + if (isGoogle()) { + return Optional.of(((GoogleValue) value).value); + } + return Optional.empty(); + } + + public Optional getGroq() { + if (isGroq()) { + return Optional.of(((GroqValue) value).value); + } + return Optional.empty(); + } + + public Optional getDeepgram() { + if (isDeepgram()) { + return Optional.of(((DeepgramValue) value).value); + } + return Optional.empty(); + } + + public Optional _getUnknown() { + if (_isUnknown()) { + return Optional.of(((_UnknownValue) value).value); + } + return Optional.empty(); + } + + @Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ThinkSettingsV1Provider && value.equals(((ThinkSettingsV1Provider) other).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value.toString(); + } + + @JsonValue + private Value getValue() { + return this.value; + } + + public interface Visitor { + T visitOpenAi(OpenAiThinkProvider openAi); + + T visitAwsBedrock(AwsBedrockThinkProvider awsBedrock); + + T visitAnthropic(Anthropic anthropic); + + T visitGoogle(Google google); + + T visitGroq(Groq groq); + + default T visitDeepgram(DeepgramThinkProvider deepgram) { + return _visitUnknown(deepgram); + } + + T _visitUnknown(Object unknownType); + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) + @JsonSubTypes({ + @JsonSubTypes.Type(OpenAiValue.class), + @JsonSubTypes.Type(AwsBedrockValue.class), + @JsonSubTypes.Type(AnthropicValue.class), + @JsonSubTypes.Type(GoogleValue.class), + @JsonSubTypes.Type(GroqValue.class), + @JsonSubTypes.Type(DeepgramValue.class) + }) + @JsonIgnoreProperties(ignoreUnknown = true) + private interface Value { + T visit(Visitor visitor); + } + + @JsonTypeName("open_ai") + @JsonIgnoreProperties("type") + private static final class OpenAiValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private OpenAiThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private OpenAiValue() {} + + private OpenAiValue(OpenAiThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitOpenAi(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OpenAiValue && equalTo((OpenAiValue) other); + } + + private boolean equalTo(OpenAiValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("aws_bedrock") + @JsonIgnoreProperties("type") + private static final class AwsBedrockValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private AwsBedrockThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AwsBedrockValue() {} + + private AwsBedrockValue(AwsBedrockThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAwsBedrock(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AwsBedrockValue && equalTo((AwsBedrockValue) other); + } + + private boolean equalTo(AwsBedrockValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("anthropic") + @JsonIgnoreProperties("type") + private static final class AnthropicValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Anthropic value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private AnthropicValue() {} + + private AnthropicValue(Anthropic value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitAnthropic(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AnthropicValue && equalTo((AnthropicValue) other); + } + + private boolean equalTo(AnthropicValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("google") + @JsonIgnoreProperties("type") + private static final class GoogleValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Google value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private GoogleValue() {} + + private GoogleValue(Google value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitGoogle(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GoogleValue && equalTo((GoogleValue) other); + } + + private boolean equalTo(GoogleValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("groq") + @JsonIgnoreProperties("type") + private static final class GroqValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private Groq value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private GroqValue() {} + + private GroqValue(Groq value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitGroq(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GroqValue && equalTo((GroqValue) other); + } + + private boolean equalTo(GroqValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonTypeName("deepgram") + @JsonIgnoreProperties("type") + private static final class DeepgramValue implements Value { + @JsonUnwrapped + @JsonIgnoreProperties(value = "type", allowSetters = true) + private DeepgramThinkProvider value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private DeepgramValue() {} + + private DeepgramValue(DeepgramThinkProvider value) { + this.value = value; + } + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor.visitDeepgram(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof DeepgramValue && equalTo((DeepgramValue) other); + } + + private boolean equalTo(DeepgramValue other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "value: " + value + "}"; + } + } + + @JsonIgnoreProperties("type") + private static final class _UnknownValue implements Value { + private String type; + + @JsonValue + private Object value; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + private _UnknownValue(@JsonProperty("value") Object value) {} + + @java.lang.Override + public T visit(Visitor visitor) { + return visitor._visitUnknown(value); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof _UnknownValue && equalTo((_UnknownValue) other); + } + + private boolean equalTo(_UnknownValue other) { + return type.equals(other.type) && value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.type, this.value); + } + + @java.lang.Override + public String toString() { + return "ThinkSettingsV1Provider{" + "type: " + type + ", value: " + value + "}"; + } + } +} From 0bd65538bb458e0ffd2f52acc32f2f7ac4919785 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:05:05 +0000 Subject: [PATCH 3/8] SDK regeneration --- .fern/metadata.json | 6 +- .../java/com/deepgram/core/ClientOptions.java | 17 +- .../core/ReconnectingWebSocketListener.java | 61 +- .../agent/v1/types/AgentV1AgentAudioDone.java | 5 - .../v1/types/AgentV1ConversationText.java | 30 +- .../agent/v1/types/AgentV1ForceEndTurn.java | 5 - .../agent/v1/types/AgentV1KeepAlive.java | 5 - .../agent/v1/types/AgentV1ListenUpdated.java | 5 - .../agent/v1/types/AgentV1PromptUpdated.java | 5 - ...tV1SettingsAgentContextListenProvider.java | 2 +- .../AgentV1SettingsAgentListenProvider.java | 2 +- .../v1/types/AgentV1SettingsApplied.java | 5 - .../agent/v1/types/AgentV1SpeakUpdated.java | 5 - .../v1/types/AgentV1ThinkLiveUpdated.java | 5 - .../agent/v1/types/AgentV1ThinkUpdated.java | 5 - .../AgentV1UpdateListenListenProvider.java | 2 +- .../v1/types/AgentV1UserStartedSpeaking.java | 5 - .../agent/v1/websocket/V1WebSocketClient.java | 7 +- .../listen/v1/media/AsyncRawMediaClient.java | 8 + .../listen/v1/media/RawMediaClient.java | 8 + .../v1/media/requests/ListenV1RequestUrl.java | 57 +- .../MediaTranscribeRequestOctetStream.java | 57 +- .../listen/v1/websocket/V1ConnectOptions.java | 47 +- .../v1/websocket/V1WebSocketClient.java | 37 +- .../listen/v2/types/ListenV2CloseStream.java | 5 - .../listen/v2/types/ListenV2Configure.java | 31 +- .../v2/types/ListenV2ConfigureSuccess.java | 60 +- .../listen/v2/types/ListenV2ForceEndTurn.java | 5 - .../listen/v2/websocket/V2ConnectOptions.java | 33 + .../v2/websocket/V2WebSocketClient.java | 51 +- .../speak/v1/websocket/V1WebSocketClient.java | 8 - .../speak/v2/audio/AsyncRawAudioClient.java | 4 + .../speak/v2/audio/RawAudioClient.java | 4 + .../v2/audio/requests/SpeakV2Request.java | 45 + .../speak/v2/types/SpeakV2Close.java | 5 - .../v2/types/SpeakV2ConfigureFailureCode.java | 4 +- .../speak/v2/types/SpeakV2Flush.java | 5 - .../speak/v2/websocket/V2ConnectOptions.java | 50 +- .../speak/v2/websocket/V2WebSocketClient.java | 22 +- .../com/deepgram/types/DeepgramModel.java | 2843 +++++++++++++++-- .../deepgram/types/DeepgramThinkProvider.java | 93 +- .../types/DeepgramThinkProviderModel.java | 10 +- .../deepgram/types/ListenV1RedactUsage.java | 83 + .../deepgram/types/ListenV2RedactUsage.java | 83 + .../types/SpeakV2NormalizeVolume.java | 84 + .../types/ThinkSettingsV1Provider.java | 4 +- 46 files changed, 3359 insertions(+), 564 deletions(-) create mode 100644 src/main/java/com/deepgram/types/ListenV1RedactUsage.java create mode 100644 src/main/java/com/deepgram/types/ListenV2RedactUsage.java create mode 100644 src/main/java/com/deepgram/types/SpeakV2NormalizeVolume.java diff --git a/.fern/metadata.json b/.fern/metadata.json index 4fa1a91..889baac 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -12,8 +12,8 @@ "enable-wire-tests": true, "runtime-version": true }, - "originGitCommit": "596e7bdfa377f40f3301b1d394c9f0215af5f6d4", + "originGitCommit": "229defd4c32f220af07902c24efca5e94b4c47a4", "originGitCommitIsDirty": true, "invokedBy": "manual", - "sdkVersion": "0.11.4" -} + "sdkVersion": "0.11.5" +} \ No newline at end of file diff --git a/src/main/java/com/deepgram/core/ClientOptions.java b/src/main/java/com/deepgram/core/ClientOptions.java index 8369b24..63b6d66 100644 --- a/src/main/java/com/deepgram/core/ClientOptions.java +++ b/src/main/java/com/deepgram/core/ClientOptions.java @@ -63,10 +63,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.4"); // x-release-please-version + put("User-Agent", "com.deepgram.deepgram-java-sdk/" + getSdkVersion()); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); - put("X-Fern-SDK-Version", "0.11.4"); // x-release-please-version + put("X-Fern-SDK-Version", getSdkVersion()); } }); this.headerSuppliers = headerSuppliers; @@ -98,6 +98,11 @@ public Map headers(RequestOptions requestOptions) { return values; } + private static String getSdkVersion() { + String version = ClientOptions.class.getPackage().getImplementationVersion(); + return version != null ? version : "0.11.5"; + } + public int timeout(RequestOptions requestOptions) { if (requestOptions == null) { return this.timeout; @@ -144,12 +149,10 @@ public Optional retryJitterFactor() { * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the * caller owns its lifecycle. *

- * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later - * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous - * requests may still run. Options derived from this one via + * In-flight calls are not cancelled or awaited, and any request issued after this method + * returns fails with a {@code RejectedExecutionException}. Options derived from this one via * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either - * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method - * more than once has no further effect. + * releases them for both. Calling this method more than once has no further effect. *

* WebSocket clients created from this client that are still connected are disconnected * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java index b51aacc..dc32da2 100644 --- a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java +++ b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java @@ -27,7 +27,13 @@ * Provides production-ready resilience for WebSocket connections. */ public abstract class ReconnectingWebSocketListener extends WebSocketListener { - private volatile ReconnectOptions activeOptions; + private final long minReconnectionDelayMs; + + private final long maxReconnectionDelayMs; + + private final double reconnectionDelayGrowFactor; + + private final int maxRetries; private final int maxEnqueuedMessages; @@ -75,30 +81,22 @@ public ReconnectingWebSocketListener( ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier, BooleanSupplier closedCheck) { - this.activeOptions = options; + this.minReconnectionDelayMs = options.minReconnectionDelayMs; + this.maxReconnectionDelayMs = options.maxReconnectionDelayMs; + this.reconnectionDelayGrowFactor = options.reconnectionDelayGrowFactor; + this.maxRetries = options.maxRetries; this.maxEnqueuedMessages = options.maxEnqueuedMessages; this.connectionSupplier = connectionSupplier; this.closedCheck = closedCheck; } - /** - * Replaces option-derived reconnect settings without rebuilding generated clients. - * - * @param options replacement options; {@code null} is a no-op - */ - public void applyOptionsOverride(ReconnectOptions options) { - if (options != null) { - this.activeOptions = options; - } - } - /** * Initiates a WebSocket connection with automatic reconnection enabled. * * Connection behavior: - * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) + * - Times out after 4000 milliseconds * - Thread-safe via atomic lock (returns immediately if connection in progress) - * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry + * - Retry count not incremented for initial connection attempt * * Error handling: * - TimeoutException: Includes retry attempt context @@ -116,20 +114,18 @@ public void connect() { onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); return; } - ReconnectOptions options = this.activeOptions; - if (retryCount.get() > options.maxRetries) { + if (retryCount.get() >= maxRetries) { connectLock.set(false); return; } try { CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); try { - webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); + webSocket = connectionFuture.get(4000, MILLISECONDS); } catch (TimeoutException e) { connectionFuture.cancel(true); TimeoutException timeoutError = - new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs - + " milliseconds" + new TimeoutException("WebSocket connection timeout after " + 4000 + " milliseconds" + (retryCount.get() > 0 ? " (retry attempt #" + retryCount.get() + ")" : " (initial connection attempt)")); @@ -419,12 +415,10 @@ protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, Strin */ private long getNextDelay() { if (retryCount.get() == 1) { - return activeOptions.minReconnectionDelayMs; + return minReconnectionDelayMs; } - ReconnectOptions options = this.activeOptions; - long delay = (long) - (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); - return Math.min(delay, options.maxReconnectionDelayMs); + long delay = (long) (minReconnectionDelayMs * Math.pow(reconnectionDelayGrowFactor, retryCount.get() - 1)); + return Math.min(delay, maxReconnectionDelayMs); } /** @@ -510,15 +504,12 @@ public static final class ReconnectOptions { public final int maxEnqueuedMessages; - public final long connectionTimeoutMs; - private ReconnectOptions(Builder builder) { this.minReconnectionDelayMs = builder.minReconnectionDelayMs; this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; this.maxRetries = builder.maxRetries; this.maxEnqueuedMessages = builder.maxEnqueuedMessages; - this.connectionTimeoutMs = builder.connectionTimeoutMs; } public static Builder builder() { @@ -536,15 +527,12 @@ public static final class Builder { private int maxEnqueuedMessages; - private long connectionTimeoutMs; - public Builder() { this.minReconnectionDelayMs = 1000; this.maxReconnectionDelayMs = 10000; this.reconnectionDelayGrowFactor = 1.3; this.maxRetries = 2147483647; this.maxEnqueuedMessages = 1000; - this.connectionTimeoutMs = 4000; } public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { @@ -572,14 +560,6 @@ public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { return this; } - /** - * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. - */ - public Builder connectionTimeoutMs(long connectionTimeoutMs) { - this.connectionTimeoutMs = connectionTimeoutMs; - return this; - } - /** * Builds the ReconnectOptions with validation. * @@ -612,9 +592,6 @@ public ReconnectOptions build() { if (maxEnqueuedMessages < 0) { throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); } - if (connectionTimeoutMs <= 0) { - throw new IllegalArgumentException("connectionTimeoutMs must be positive"); - } return new ReconnectOptions(this); } } diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java index 5962f4b..71825ed 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1AgentAudioDone; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java index ef4f56a..56ebeab 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java @@ -77,8 +77,8 @@ public String getContent() { * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off */ @JsonProperty("conversational_behavior") - public Optional getConversationalBehavior() { - return Optional.of(conversationalBehavior); + public AgentV1ConversationTextConversationalBehavior getConversationalBehavior() { + return conversationalBehavior; } /** @@ -143,7 +143,7 @@ public interface ContentStage { /** *

The actual statement that was spoken

*/ - _FinalStage content(@NotNull String content); + ConversationalBehaviorStage content(@NotNull String content); } public interface ConversationalBehaviorStage { @@ -161,16 +161,6 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); - default _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { - return this; - } - - default _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - return this; - } - /** *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

*/ @@ -192,8 +182,7 @@ public static final class Builder implements RoleStage, ContentStage, Conversati private String content; - private AgentV1ConversationTextConversationalBehavior conversationalBehavior = - AgentV1ConversationTextConversationalBehavior.DEFAULT; + private AgentV1ConversationTextConversationalBehavior conversationalBehavior; private Optional> languages = Optional.empty(); @@ -231,7 +220,7 @@ public ContentStage role(@NotNull AgentV1ConversationTextRole role) { */ @java.lang.Override @JsonSetter("content") - public _FinalStage content(@NotNull String content) { + public ConversationalBehaviorStage content(@NotNull String content) { this.content = Objects.requireNonNull(content, "content must not be null"); return this; } @@ -241,7 +230,7 @@ public _FinalStage content(@NotNull String content) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) + @JsonSetter("conversational_behavior") public _FinalStage conversationalBehavior( @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { this.conversationalBehavior = @@ -249,13 +238,6 @@ public _FinalStage conversationalBehavior( return this; } - public _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - this.conversationalBehavior = conversationalBehavior.orElse( - AgentV1ConversationTextConversationalBehavior.DEFAULT); - return this; - } - /** *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

* @return Reference to {@code this} so that method calls can be chained together. diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java index 9bd5f76..1672d2d 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1ForceEndTurn; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java index f82f59e..7842266 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1KeepAlive; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java index 43b8628..65878c9 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1ListenUpdated; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java index e6efced..68d71cc 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1PromptUpdated; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java index 393f1f9..eea1585 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java index 345ba2f..4309ec0 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java index ad1fdb2..0d60b72 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1SettingsApplied; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java index 8b134b5..747aa9d 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1SpeakUpdated; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java index 98eaf74..8b15579 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1ThinkLiveUpdated; } - @java.lang.Override - public int hashCode() { - return 1; - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java index 2d67cad..5668a71 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1ThinkUpdated; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java index e739aec..e693a04 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java index 3556d31..edb80f8 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof AgentV1UserStartedSpeaking; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java index b648a3e..15b883e 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java @@ -664,7 +664,10 @@ private void handleIncomingMessage(String json) { if (node == null || node.isNull()) { throw new IllegalArgumentException("Received null or invalid JSON message"); } - if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { + if (node.has("role") + && node.has("content") + && node.has("conversational_behavior") + && "ConversationText".equals(node.path("type").asText())) { AgentV1ConversationText conversationTextHandlerEvent = null; try { conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); @@ -967,7 +970,7 @@ private void handleIncomingMessage(String json) { } return; } - if (onMessageHandler == null && onErrorHandler != null) { + if (onErrorHandler != null) { onErrorHandler.accept(new RuntimeException( "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + "... Update your SDK version to support new message types.")); diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/AsyncRawMediaClient.java b/src/main/java/com/deepgram/resources/listen/v1/media/AsyncRawMediaClient.java index d1bf59f..8ad0f18 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/AsyncRawMediaClient.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/AsyncRawMediaClient.java @@ -152,6 +152,10 @@ public CompletableFuture> trans QueryStringMapper.addQueryParameter( httpUrl, "redact", request.getRedact().get(), false); } + if (request.getRedactUsage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redact_usage", request.getRedactUsage().get(), false); + } if (request.getSmartFormat().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "smart_format", request.getSmartFormat().get(), false); @@ -409,6 +413,10 @@ public CompletableFuture> trans QueryStringMapper.addQueryParameter( httpUrl, "redact", request.getRedact().get(), false); } + if (request.getRedactUsage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redact_usage", request.getRedactUsage().get(), false); + } if (request.getSmartFormat().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "smart_format", request.getSmartFormat().get(), false); diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/RawMediaClient.java b/src/main/java/com/deepgram/resources/listen/v1/media/RawMediaClient.java index 1572611..bb88a38 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/RawMediaClient.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/RawMediaClient.java @@ -147,6 +147,10 @@ public DeepgramApiHttpResponse transcribeUrl( QueryStringMapper.addQueryParameter( httpUrl, "redact", request.getRedact().get(), false); } + if (request.getRedactUsage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redact_usage", request.getRedactUsage().get(), false); + } if (request.getSmartFormat().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "smart_format", request.getSmartFormat().get(), false); @@ -387,6 +391,10 @@ public DeepgramApiHttpResponse transcribeFile( QueryStringMapper.addQueryParameter( httpUrl, "redact", request.getRedact().get(), false); } + if (request.getRedactUsage().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "redact_usage", request.getRedactUsage().get(), false); + } if (request.getSmartFormat().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "smart_format", request.getSmartFormat().get(), false); diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java index 448c459..da7a868 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java @@ -98,6 +98,8 @@ public final class ListenV1RequestUrl { private final Optional redact; + private final Optional redactUsage; + private final Optional smartFormat; private final Optional utterances; @@ -146,6 +148,7 @@ private ListenV1RequestUrl( Optional profanityFilter, Optional punctuate, Optional redact, + Optional redactUsage, Optional smartFormat, Optional utterances, Optional uttSplit, @@ -186,6 +189,7 @@ private ListenV1RequestUrl( this.profanityFilter = profanityFilter; this.punctuate = punctuate; this.redact = redact; + this.redactUsage = redactUsage; this.smartFormat = smartFormat; this.utterances = utterances; this.uttSplit = uttSplit; @@ -461,6 +465,14 @@ public Optional getRedact() { return redact; } + /** + * @return Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage + */ + @JsonIgnore + public Optional getRedactUsage() { + return redactUsage; + } + /** * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability */ @@ -551,6 +563,7 @@ private boolean equalTo(ListenV1RequestUrl other) { && profanityFilter.equals(other.profanityFilter) && punctuate.equals(other.punctuate) && redact.equals(other.redact) + && redactUsage.equals(other.redactUsage) && smartFormat.equals(other.smartFormat) && utterances.equals(other.utterances) && uttSplit.equals(other.uttSplit) @@ -595,6 +608,7 @@ public int hashCode() { this.profanityFilter, this.punctuate, this.redact, + this.redactUsage, this.smartFormat, this.utterances, this.uttSplit, @@ -684,17 +698,11 @@ public interface _FinalStage { /** *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

*/ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } + _FinalStage languageHint(Optional> languageHint); - default _FinalStage languageHint(List languageHint) { - return this; - } + _FinalStage languageHint(List languageHint); - default _FinalStage languageHint(String languageHint) { - return this; - } + _FinalStage languageHint(String languageHint); /** *

Search for terms or phrases in submitted audio and replaces them

@@ -882,6 +890,13 @@ default _FinalStage languageHint(String languageHint) { _FinalStage redact(String redact); + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ */ + _FinalStage redactUsage(Optional redactUsage); + + _FinalStage redactUsage(Boolean redactUsage); + /** *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

*/ @@ -932,6 +947,8 @@ public static final class Builder implements UrlStage, _FinalStage { private Optional smartFormat = Optional.empty(); + private Optional redactUsage = Optional.empty(); + private Optional redact = Optional.empty(); private Optional punctuate = Optional.empty(); @@ -1038,6 +1055,7 @@ public Builder from(ListenV1RequestUrl other) { profanityFilter(other.getProfanityFilter()); punctuate(other.getPunctuate()); redact(other.getRedact()); + redactUsage(other.getRedactUsage()); smartFormat(other.getSmartFormat()); utterances(other.getUtterances()); uttSplit(other.getUttSplit()); @@ -1154,6 +1172,26 @@ public _FinalStage smartFormat(Optional smartFormat) { return this; } + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redactUsage(Boolean redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ */ + @java.lang.Override + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public _FinalStage redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + /** *

Redaction removes sensitive information from your transcripts

* @return Reference to {@code this} so that method calls can be chained together. @@ -1908,6 +1946,7 @@ public ListenV1RequestUrl build() { profanityFilter, punctuate, redact, + redactUsage, smartFormat, utterances, uttSplit, diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java index f094b06..5008aca 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java @@ -97,6 +97,8 @@ public final class MediaTranscribeRequestOctetStream { private final Optional redact; + private final Optional redactUsage; + private final Optional smartFormat; private final Optional utterances; @@ -145,6 +147,7 @@ private MediaTranscribeRequestOctetStream( Optional profanityFilter, Optional punctuate, Optional redact, + Optional redactUsage, Optional smartFormat, Optional utterances, Optional uttSplit, @@ -185,6 +188,7 @@ private MediaTranscribeRequestOctetStream( this.profanityFilter = profanityFilter; this.punctuate = punctuate; this.redact = redact; + this.redactUsage = redactUsage; this.smartFormat = smartFormat; this.utterances = utterances; this.uttSplit = uttSplit; @@ -460,6 +464,14 @@ public Optional getRedact() { return redact; } + /** + * @return Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage + */ + @JsonProperty("redact_usage") + public Optional getRedactUsage() { + return redactUsage; + } + /** * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability */ @@ -550,6 +562,7 @@ private boolean equalTo(MediaTranscribeRequestOctetStream other) { && profanityFilter.equals(other.profanityFilter) && punctuate.equals(other.punctuate) && redact.equals(other.redact) + && redactUsage.equals(other.redactUsage) && smartFormat.equals(other.smartFormat) && utterances.equals(other.utterances) && uttSplit.equals(other.uttSplit) @@ -594,6 +607,7 @@ public int hashCode() { this.profanityFilter, this.punctuate, this.redact, + this.redactUsage, this.smartFormat, this.utterances, this.uttSplit, @@ -683,17 +697,11 @@ public interface _FinalStage { /** *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

*/ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } + _FinalStage languageHint(Optional> languageHint); - default _FinalStage languageHint(List languageHint) { - return this; - } + _FinalStage languageHint(List languageHint); - default _FinalStage languageHint(String languageHint) { - return this; - } + _FinalStage languageHint(String languageHint); /** *

Search for terms or phrases in submitted audio and replaces them

@@ -881,6 +889,13 @@ default _FinalStage languageHint(String languageHint) { _FinalStage redact(String redact); + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ */ + _FinalStage redactUsage(Optional redactUsage); + + _FinalStage redactUsage(Boolean redactUsage); + /** *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

*/ @@ -931,6 +946,8 @@ public static final class Builder implements BodyStage, _FinalStage { private Optional smartFormat = Optional.empty(); + private Optional redactUsage = Optional.empty(); + private Optional redact = Optional.empty(); private Optional punctuate = Optional.empty(); @@ -1037,6 +1054,7 @@ public Builder from(MediaTranscribeRequestOctetStream other) { profanityFilter(other.getProfanityFilter()); punctuate(other.getPunctuate()); redact(other.getRedact()); + redactUsage(other.getRedactUsage()); smartFormat(other.getSmartFormat()); utterances(other.getUtterances()); uttSplit(other.getUttSplit()); @@ -1153,6 +1171,26 @@ public _FinalStage smartFormat(Optional smartFormat) { return this; } + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redactUsage(Boolean redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + + /** + *

Replaces the values of user-supplied text parameters (keyterm, keywords, replace, search, extra, custom_topic, and custom_intent) with [REDACTED] in this request's usage records. Does not affect transcription, the response, tag, or callback. Independent of mip_opt_out. https://developers.deepgram.com/docs/redact-usage

+ */ + @java.lang.Override + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public _FinalStage redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + /** *

Redaction removes sensitive information from your transcripts

* @return Reference to {@code this} so that method calls can be chained together. @@ -1907,6 +1945,7 @@ public MediaTranscribeRequestOctetStream build() { profanityFilter, punctuate, redact, + redactUsage, smartFormat, utterances, uttSplit, diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java index 2694721..7ac9aa5 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java @@ -26,6 +26,7 @@ import com.deepgram.types.ListenV1ProfanityFilter; import com.deepgram.types.ListenV1Punctuate; import com.deepgram.types.ListenV1Redact; +import com.deepgram.types.ListenV1RedactUsage; import com.deepgram.types.ListenV1Replace; import com.deepgram.types.ListenV1SampleRate; import com.deepgram.types.ListenV1Search; @@ -95,6 +96,8 @@ public final class V1ConnectOptions { private final Optional redact; + private final Optional redactUsage; + private final Optional replace; private final Optional sampleRate; @@ -136,6 +139,7 @@ private V1ConnectOptions( Optional profanityFilter, Optional punctuate, Optional redact, + Optional redactUsage, Optional replace, Optional sampleRate, Optional search, @@ -167,6 +171,7 @@ private V1ConnectOptions( this.profanityFilter = profanityFilter; this.punctuate = punctuate; this.redact = redact; + this.redactUsage = redactUsage; this.replace = replace; this.sampleRate = sampleRate; this.search = search; @@ -297,6 +302,11 @@ public Optional getRedact() { return redact; } + @JsonProperty("redact_usage") + public Optional getRedactUsage() { + return redactUsage; + } + @JsonProperty("replace") public Optional getReplace() { return replace; @@ -371,6 +381,7 @@ private boolean equalTo(V1ConnectOptions other) { && profanityFilter.equals(other.profanityFilter) && punctuate.equals(other.punctuate) && redact.equals(other.redact) + && redactUsage.equals(other.redactUsage) && replace.equals(other.replace) && sampleRate.equals(other.sampleRate) && search.equals(other.search) @@ -406,6 +417,7 @@ public int hashCode() { this.profanityFilter, this.punctuate, this.redact, + this.redactUsage, this.replace, this.sampleRate, this.search, @@ -503,19 +515,9 @@ public interface _FinalStage { _FinalStage language(ListenV1Language language); - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional languageHint) { - return this; - } + _FinalStage languageHint(Optional languageHint); - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(ListenV1LanguageHint languageHint) { - return this; - } + _FinalStage languageHint(ListenV1LanguageHint languageHint); _FinalStage mipOptOut(Optional mipOptOut); @@ -541,6 +543,10 @@ default _FinalStage languageHint(ListenV1LanguageHint languageHint) { _FinalStage redact(ListenV1Redact redact); + _FinalStage redactUsage(Optional redactUsage); + + _FinalStage redactUsage(ListenV1RedactUsage redactUsage); + _FinalStage replace(Optional replace); _FinalStage replace(ListenV1Replace replace); @@ -594,6 +600,8 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional replace = Optional.empty(); + private Optional redactUsage = Optional.empty(); + private Optional redact = Optional.empty(); private Optional punctuate = Optional.empty(); @@ -665,6 +673,7 @@ public Builder from(V1ConnectOptions other) { profanityFilter(other.getProfanityFilter()); punctuate(other.getPunctuate()); redact(other.getRedact()); + redactUsage(other.getRedactUsage()); replace(other.getReplace()); sampleRate(other.getSampleRate()); search(other.getSearch()); @@ -791,6 +800,19 @@ public _FinalStage replace(Optional replace) { return this; } + @java.lang.Override + public _FinalStage redactUsage(ListenV1RedactUsage redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public _FinalStage redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + @java.lang.Override public _FinalStage redact(ListenV1Redact redact) { this.redact = Optional.ofNullable(redact); @@ -1103,6 +1125,7 @@ public V1ConnectOptions build() { profanityFilter, punctuate, redact, + redactUsage, replace, sampleRate, search, diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java index 885f60c..9100a5b 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java @@ -6,7 +6,6 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -149,7 +148,8 @@ public CompletableFuture connect(V1ConnectOptions options) { "endpointing", String.valueOf(options.getEndpointing().get())); } if (options.getExtra() != null && options.getExtra().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); + urlBuilder.addQueryParameter( + "extra", String.valueOf(options.getExtra().get())); } if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { urlBuilder.addQueryParameter( @@ -157,18 +157,20 @@ public CompletableFuture connect(V1ConnectOptions options) { String.valueOf(options.getInterimResults().get())); } if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + urlBuilder.addQueryParameter( + "keyterm", String.valueOf(options.getKeyterm().get())); } if (options.getKeywords() != null && options.getKeywords().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); + urlBuilder.addQueryParameter( + "keywords", String.valueOf(options.getKeywords().get())); } if (options.getLanguage() != null && options.getLanguage().isPresent()) { urlBuilder.addQueryParameter( "language", String.valueOf(options.getLanguage().get())); } if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + urlBuilder.addQueryParameter( + "language_hint", String.valueOf(options.getLanguageHint().get())); } if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { urlBuilder.addQueryParameter( @@ -196,22 +198,28 @@ public CompletableFuture connect(V1ConnectOptions options) { urlBuilder.addQueryParameter( "redact", String.valueOf(options.getRedact().get())); } + if (options.getRedactUsage() != null && options.getRedactUsage().isPresent()) { + urlBuilder.addQueryParameter( + "redact_usage", String.valueOf(options.getRedactUsage().get())); + } if (options.getReplace() != null && options.getReplace().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); + urlBuilder.addQueryParameter( + "replace", String.valueOf(options.getReplace().get())); } if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { urlBuilder.addQueryParameter( "sample_rate", String.valueOf(options.getSampleRate().get())); } if (options.getSearch() != null && options.getSearch().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); + urlBuilder.addQueryParameter( + "search", String.valueOf(options.getSearch().get())); } if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { urlBuilder.addQueryParameter( "smart_format", String.valueOf(options.getSmartFormat().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); } if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { urlBuilder.addQueryParameter( @@ -226,13 +234,6 @@ public CompletableFuture connect(V1ConnectOptions options) { urlBuilder.addQueryParameter( "version", String.valueOf(options.getVersion().get())); } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); final Request request = requestBuilder.build(); @@ -569,8 +570,6 @@ private void handleIncomingMessage(String json) { if (configureFailureHandlerEvent != null) { if (configureFailureHandler != null) { configureFailureHandler.accept(configureFailureHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); } return; } @@ -616,8 +615,6 @@ private void handleIncomingMessage(String json) { if (errorHandlerEvent != null) { if (errorHandler != null) { errorHandler.accept(errorHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); } return; } diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java index c9f2f35..e6308e2 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof ListenV2CloseStream; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2Configure.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2Configure.java index 8574084..1a62186 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2Configure.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2Configure.java @@ -30,6 +30,8 @@ public final class ListenV2Configure { private final Optional numerals; + private final Optional redactUsage; + private final Map additionalProperties; private ListenV2Configure( @@ -37,11 +39,13 @@ private ListenV2Configure( Optional keyterms, Optional> languageHints, Optional numerals, + Optional redactUsage, Map additionalProperties) { this.thresholds = thresholds; this.keyterms = keyterms; this.languageHints = languageHints; this.numerals = numerals; + this.redactUsage = redactUsage; this.additionalProperties = additionalProperties; } @@ -82,6 +86,11 @@ public Optional getNumerals() { return numerals; } + @JsonProperty("redact_usage") + public Optional getRedactUsage() { + return redactUsage; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -97,12 +106,13 @@ private boolean equalTo(ListenV2Configure other) { return thresholds.equals(other.thresholds) && keyterms.equals(other.keyterms) && languageHints.equals(other.languageHints) - && numerals.equals(other.numerals); + && numerals.equals(other.numerals) + && redactUsage.equals(other.redactUsage); } @java.lang.Override public int hashCode() { - return Objects.hash(this.thresholds, this.keyterms, this.languageHints, this.numerals); + return Objects.hash(this.thresholds, this.keyterms, this.languageHints, this.numerals, this.redactUsage); } @java.lang.Override @@ -124,6 +134,8 @@ public static final class Builder { private Optional numerals = Optional.empty(); + private Optional redactUsage = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -134,6 +146,7 @@ public Builder from(ListenV2Configure other) { keyterms(other.getKeyterms()); languageHints(other.getLanguageHints()); numerals(other.getNumerals()); + redactUsage(other.getRedactUsage()); return this; } @@ -190,8 +203,20 @@ public Builder numerals(Boolean numerals) { return this; } + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public Builder redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + + public Builder redactUsage(Boolean redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + public ListenV2Configure build() { - return new ListenV2Configure(thresholds, keyterms, languageHints, numerals, additionalProperties); + return new ListenV2Configure( + thresholds, keyterms, languageHints, numerals, redactUsage, additionalProperties); } public Builder additionalProperty(String key, Object value) { diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ConfigureSuccess.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ConfigureSuccess.java index a714b95..3625f06 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ConfigureSuccess.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ConfigureSuccess.java @@ -33,6 +33,8 @@ public final class ListenV2ConfigureSuccess { private final Optional numerals; + private final Optional redactUsage; + private final int sequenceId; private final Map additionalProperties; @@ -43,6 +45,7 @@ private ListenV2ConfigureSuccess( ListenV2Keyterm keyterms, Optional> languageHints, Optional numerals, + Optional redactUsage, int sequenceId, Map additionalProperties) { this.requestId = requestId; @@ -50,6 +53,7 @@ private ListenV2ConfigureSuccess( this.keyterms = keyterms; this.languageHints = languageHints; this.numerals = numerals; + this.redactUsage = redactUsage; this.sequenceId = sequenceId; this.additionalProperties = additionalProperties; } @@ -100,6 +104,14 @@ public Optional getNumerals() { return numerals; } + /** + * @return Whether usage redaction is on for this connection. + */ + @JsonProperty("redact_usage") + public Optional getRedactUsage() { + return redactUsage; + } + /** * @return Starts at 0 and increments for each message the server sends * to the client. This includes messages of other types, like @@ -127,13 +139,20 @@ private boolean equalTo(ListenV2ConfigureSuccess other) { && keyterms.equals(other.keyterms) && languageHints.equals(other.languageHints) && numerals.equals(other.numerals) + && redactUsage.equals(other.redactUsage) && sequenceId == other.sequenceId; } @java.lang.Override public int hashCode() { return Objects.hash( - this.requestId, this.thresholds, this.keyterms, this.languageHints, this.numerals, this.sequenceId); + this.requestId, + this.thresholds, + this.keyterms, + this.languageHints, + this.numerals, + this.redactUsage, + this.sequenceId); } @java.lang.Override @@ -195,6 +214,13 @@ public interface _FinalStage { _FinalStage numerals(Optional numerals); _FinalStage numerals(Boolean numerals); + + /** + *

Whether usage redaction is on for this connection.

+ */ + _FinalStage redactUsage(Optional redactUsage); + + _FinalStage redactUsage(Boolean redactUsage); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -208,6 +234,8 @@ public static final class Builder private int sequenceId; + private Optional redactUsage = Optional.empty(); + private Optional numerals = Optional.empty(); private Optional> languageHints = Optional.empty(); @@ -224,6 +252,7 @@ public Builder from(ListenV2ConfigureSuccess other) { keyterms(other.getKeyterms()); languageHints(other.getLanguageHints()); numerals(other.getNumerals()); + redactUsage(other.getRedactUsage()); sequenceId(other.getSequenceId()); return this; } @@ -271,6 +300,26 @@ public _FinalStage sequenceId(int sequenceId) { return this; } + /** + *

Whether usage redaction is on for this connection.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage redactUsage(Boolean redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + + /** + *

Whether usage redaction is on for this connection.

+ */ + @java.lang.Override + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public _FinalStage redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + /** *

Whether numeral formatting is enabled for transcripts Flux STT sends after it processes the update.

* @return Reference to {@code this} so that method calls can be chained together. @@ -314,7 +363,14 @@ public _FinalStage languageHints(Optional> languageHints) { @java.lang.Override public ListenV2ConfigureSuccess build() { return new ListenV2ConfigureSuccess( - requestId, thresholds, keyterms, languageHints, numerals, sequenceId, additionalProperties); + requestId, + thresholds, + keyterms, + languageHints, + numerals, + redactUsage, + sequenceId, + additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java index 894bd3c..c3dbd38 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof ListenV2ForceEndTurn; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2ConnectOptions.java b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2ConnectOptions.java index 5cc78b9..9ae605c 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2ConnectOptions.java +++ b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2ConnectOptions.java @@ -15,6 +15,7 @@ import com.deepgram.types.ListenV2Numerals; import com.deepgram.types.ListenV2ProfanityFilter; import com.deepgram.types.ListenV2Redact; +import com.deepgram.types.ListenV2RedactUsage; import com.deepgram.types.ListenV2SampleRate; import com.deepgram.types.ListenV2Tag; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -56,6 +57,8 @@ public final class V2ConnectOptions { private final Optional redact; + private final Optional redactUsage; + private final Optional mipOptOut; private final Optional tag; @@ -74,6 +77,7 @@ private V2ConnectOptions( Optional profanityFilter, Optional numerals, Optional redact, + Optional redactUsage, Optional mipOptOut, Optional tag, Map additionalProperties) { @@ -88,6 +92,7 @@ private V2ConnectOptions( this.profanityFilter = profanityFilter; this.numerals = numerals; this.redact = redact; + this.redactUsage = redactUsage; this.mipOptOut = mipOptOut; this.tag = tag; this.additionalProperties = additionalProperties; @@ -148,6 +153,11 @@ public Optional getRedact() { return redact; } + @JsonProperty("redact_usage") + public Optional getRedactUsage() { + return redactUsage; + } + @JsonProperty("mip_opt_out") public Optional getMipOptOut() { return mipOptOut; @@ -181,6 +191,7 @@ private boolean equalTo(V2ConnectOptions other) { && profanityFilter.equals(other.profanityFilter) && numerals.equals(other.numerals) && redact.equals(other.redact) + && redactUsage.equals(other.redactUsage) && mipOptOut.equals(other.mipOptOut) && tag.equals(other.tag); } @@ -199,6 +210,7 @@ public int hashCode() { this.profanityFilter, this.numerals, this.redact, + this.redactUsage, this.mipOptOut, this.tag); } @@ -265,6 +277,10 @@ public interface _FinalStage { _FinalStage redact(ListenV2Redact redact); + _FinalStage redactUsage(Optional redactUsage); + + _FinalStage redactUsage(ListenV2RedactUsage redactUsage); + _FinalStage mipOptOut(Optional mipOptOut); _FinalStage mipOptOut(ListenV2MipOptOut mipOptOut); @@ -282,6 +298,8 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional mipOptOut = Optional.empty(); + private Optional redactUsage = Optional.empty(); + private Optional redact = Optional.empty(); private Optional numerals = Optional.empty(); @@ -320,6 +338,7 @@ public Builder from(V2ConnectOptions other) { profanityFilter(other.getProfanityFilter()); numerals(other.getNumerals()); redact(other.getRedact()); + redactUsage(other.getRedactUsage()); mipOptOut(other.getMipOptOut()); tag(other.getTag()); return this; @@ -358,6 +377,19 @@ public _FinalStage mipOptOut(Optional mipOptOut) { return this; } + @java.lang.Override + public _FinalStage redactUsage(ListenV2RedactUsage redactUsage) { + this.redactUsage = Optional.ofNullable(redactUsage); + return this; + } + + @java.lang.Override + @JsonSetter(value = "redact_usage", nulls = Nulls.SKIP) + public _FinalStage redactUsage(Optional redactUsage) { + this.redactUsage = redactUsage; + return this; + } + @java.lang.Override public _FinalStage redact(ListenV2Redact redact) { this.redact = Optional.ofNullable(redact); @@ -502,6 +534,7 @@ public V2ConnectOptions build() { profanityFilter, numerals, redact, + redactUsage, mipOptOut, tag, additionalProperties); diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java index 5f55fea..d2cc476 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java @@ -6,7 +6,6 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -23,7 +22,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -61,8 +59,6 @@ public class V2WebSocketClient implements AutoCloseable { private ReconnectingWebSocketListener reconnectingListener; - private final AtomicReference closeStreamSocket = new AtomicReference<>(); - private volatile Consumer connectedHandler; private volatile Consumer turnInfoHandler; @@ -91,7 +87,6 @@ public V2WebSocketClient(ClientOptions clientOptions) { */ public CompletableFuture connect(V2ConnectOptions options) { connectionFuture = new CompletableFuture<>(); - closeStreamSocket.set(null); String baseUrl = clientOptions.environment().getProductionURL(); String fullPath = "/v2/listen"; if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { @@ -134,12 +129,12 @@ public CompletableFuture connect(V2ConnectOptions options) { "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); } if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "keyterm", options.getKeyterm().get().get(), true); + urlBuilder.addQueryParameter( + "keyterm", String.valueOf(options.getKeyterm().get())); } if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); + urlBuilder.addQueryParameter( + "language_hint", String.valueOf(options.getLanguageHint().get())); } if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { urlBuilder.addQueryParameter( @@ -154,19 +149,16 @@ public CompletableFuture connect(V2ConnectOptions options) { urlBuilder.addQueryParameter( "redact", String.valueOf(options.getRedact().get())); } + if (options.getRedactUsage() != null && options.getRedactUsage().isPresent()) { + urlBuilder.addQueryParameter( + "redact_usage", String.valueOf(options.getRedactUsage().get())); + } if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { urlBuilder.addQueryParameter( "mip_opt_out", String.valueOf(options.getMipOptOut().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); + urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); @@ -194,7 +186,6 @@ public CompletableFuture connect(V2ConnectOptions options) { clientOptions::isClosed) { @Override protected void onWebSocketOpen(WebSocket webSocket, Response response) { - closeStreamSocket.set(null); readyState = WebSocketReadyState.OPEN; if (onConnectedHandler != null) { onConnectedHandler.run(); @@ -226,12 +217,6 @@ protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { onDisconnectedHandler.accept(new DisconnectReason(code, reason)); } } - - @Override - protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { - return super.shouldReconnectAfterClose(webSocket, code, reason) - && (code != 1005 || closeStreamSocket.get() != webSocket); - } }; clientOptions.registerWebSocket(this); reconnectingListener.connect(); @@ -282,13 +267,12 @@ public CompletableFuture sendMedia(ByteString message) { } /** - * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does - * not suppress reconnects because it might never reach the server. + * Sends a ListenV2CloseStream message to the server asynchronously. * @param message the message to send * @return a CompletableFuture that completes when the message is sent */ public CompletableFuture sendCloseStream(ListenV2CloseStream message) { - return sendMessage(message, closeStreamSocket::set); + return sendMessage(message); } /** @@ -422,16 +406,12 @@ private void assertSocketIsOpen() { } private CompletableFuture sendMessage(Object body) { - return sendMessage(body, null); - } - - private CompletableFuture sendMessage(Object body, Consumer onSent) { CompletableFuture future = new CompletableFuture<>(); try { assertSocketIsOpen(); String json = objectMapper.writeValueAsString(body); // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json, onSent); + reconnectingListener.send(json); future.complete(null); } catch (IllegalStateException e) { future.completeExceptionally(e); @@ -552,8 +532,11 @@ private void handleIncomingMessage(String json) { return; } } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } } catch (Exception e) { if (onErrorHandler != null) { onErrorHandler.accept(e); diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java index e6824a3..6dd298a 100644 --- a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java @@ -6,7 +6,6 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -123,13 +122,6 @@ public CompletableFuture connect(V1ConnectOptions options) { urlBuilder.addQueryParameter( "speed", String.valueOf(options.getSpeed().get())); } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); final Request request = requestBuilder.build(); diff --git a/src/main/java/com/deepgram/resources/speak/v2/audio/AsyncRawAudioClient.java b/src/main/java/com/deepgram/resources/speak/v2/audio/AsyncRawAudioClient.java index a840a77..686316d 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/audio/AsyncRawAudioClient.java +++ b/src/main/java/com/deepgram/resources/speak/v2/audio/AsyncRawAudioClient.java @@ -81,6 +81,10 @@ public CompletableFuture> generate( httpUrl, "expressivity", request.getExpressivity().get(), false); } QueryStringMapper.addQueryParameter(httpUrl, "model", request.getModel(), false); + if (request.getNormalizeVolume().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "normalize_volume", request.getNormalizeVolume().get(), false); + } if (request.getSampleRate().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "sample_rate", request.getSampleRate().get(), false); diff --git a/src/main/java/com/deepgram/resources/speak/v2/audio/RawAudioClient.java b/src/main/java/com/deepgram/resources/speak/v2/audio/RawAudioClient.java index 6fc9ae1..0a0fccc 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/audio/RawAudioClient.java +++ b/src/main/java/com/deepgram/resources/speak/v2/audio/RawAudioClient.java @@ -76,6 +76,10 @@ public DeepgramApiHttpResponse generate(SpeakV2Request request, Req httpUrl, "expressivity", request.getExpressivity().get(), false); } QueryStringMapper.addQueryParameter(httpUrl, "model", request.getModel(), false); + if (request.getNormalizeVolume().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "normalize_volume", request.getNormalizeVolume().get(), false); + } if (request.getSampleRate().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "sample_rate", request.getSampleRate().get(), false); diff --git a/src/main/java/com/deepgram/resources/speak/v2/audio/requests/SpeakV2Request.java b/src/main/java/com/deepgram/resources/speak/v2/audio/requests/SpeakV2Request.java index e38279c..87f89c5 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/audio/requests/SpeakV2Request.java +++ b/src/main/java/com/deepgram/resources/speak/v2/audio/requests/SpeakV2Request.java @@ -45,6 +45,8 @@ public final class SpeakV2Request { private final String model; + private final Optional normalizeVolume; + private final Optional sampleRate; private final Optional speed; @@ -65,6 +67,7 @@ private SpeakV2Request( Optional encoding, Optional expressivity, String model, + Optional normalizeVolume, Optional sampleRate, Optional speed, Optional priority, @@ -79,6 +82,7 @@ private SpeakV2Request( this.encoding = encoding; this.expressivity = expressivity; this.model = model; + this.normalizeVolume = normalizeVolume; this.sampleRate = sampleRate; this.speed = speed; this.priority = priority; @@ -158,6 +162,14 @@ public String getModel() { return model; } + /** + * @return Normalizes the loudness of the generated speech to a consistent level across voices and requests. On by default; set to false to opt out. Peak limiting is applied either way. + */ + @JsonIgnore + public Optional getNormalizeVolume() { + return normalizeVolume; + } + /** * @return Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable */ @@ -211,6 +223,7 @@ private boolean equalTo(SpeakV2Request other) { && encoding.equals(other.encoding) && expressivity.equals(other.expressivity) && model.equals(other.model) + && normalizeVolume.equals(other.normalizeVolume) && sampleRate.equals(other.sampleRate) && speed.equals(other.speed) && priority.equals(other.priority) @@ -229,6 +242,7 @@ public int hashCode() { this.encoding, this.expressivity, this.model, + this.normalizeVolume, this.sampleRate, this.speed, this.priority, @@ -325,6 +339,13 @@ public interface _FinalStage { _FinalStage expressivity(Integer expressivity); + /** + *

Normalizes the loudness of the generated speech to a consistent level across voices and requests. On by default; set to false to opt out. Peak limiting is applied either way.

+ */ + _FinalStage normalizeVolume(Optional normalizeVolume); + + _FinalStage normalizeVolume(Boolean normalizeVolume); + /** *

Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

*/ @@ -359,6 +380,8 @@ public static final class Builder implements ModelStage, TextStage, _FinalStage private Optional sampleRate = Optional.empty(); + private Optional normalizeVolume = Optional.empty(); + private Optional expressivity = Optional.empty(); private Optional encoding = Optional.empty(); @@ -391,6 +414,7 @@ public Builder from(SpeakV2Request other) { encoding(other.getEncoding()); expressivity(other.getExpressivity()); model(other.getModel()); + normalizeVolume(other.getNormalizeVolume()); sampleRate(other.getSampleRate()); speed(other.getSpeed()); priority(other.getPriority()); @@ -480,6 +504,26 @@ public _FinalStage sampleRate(Optional sampleRate) { return this; } + /** + *

Normalizes the loudness of the generated speech to a consistent level across voices and requests. On by default; set to false to opt out. Peak limiting is applied either way.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage normalizeVolume(Boolean normalizeVolume) { + this.normalizeVolume = Optional.ofNullable(normalizeVolume); + return this; + } + + /** + *

Normalizes the loudness of the generated speech to a consistent level across voices and requests. On by default; set to false to opt out. Peak limiting is applied either way.

+ */ + @java.lang.Override + @JsonSetter(value = "normalize_volume", nulls = Nulls.SKIP) + public _FinalStage normalizeVolume(Optional normalizeVolume) { + this.normalizeVolume = normalizeVolume; + return this; + } + /** *

Expressive range of the generated speech, on a calm-to-animated axis. Accepted values: -2, -1, 0, 1, 2. 0 (the default) is the voice's tuned delivery and the production-validated setting, with -2 the calm end of the range and 2 the animated end. Supported on all Flux voices; applies to the whole request. Beta: behavior may change in future model versions, and non-default values increase the risk of hallucinations and pronunciation errors; audition before shipping. An invalid value is rejected with a 400 — EXPRESSIVITY_OUT_OF_RANGE for a value outside the range, EXPRESSIVITY_INCREMENT_INVALID for a fractional value. See Expressivity.

* @return Reference to {@code this} so that method calls can be chained together. @@ -658,6 +702,7 @@ public SpeakV2Request build() { encoding, expressivity, model, + normalizeVolume, sampleRate, speed, priority, diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java index 7fecd79..2e96a5c 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof SpeakV2Close; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java index f678e97..63ec45a 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java @@ -110,9 +110,7 @@ public interface Visitor { T visitSpeedNotSupported(); - default T visitControlCombinationInvalid() { - return visitUnknown("CONTROL_COMBINATION_INVALID"); - } + T visitControlCombinationInvalid(); T visitInternalError(); diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java index 130da0d..acd717d 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java @@ -36,11 +36,6 @@ public boolean equals(Object other) { return other instanceof SpeakV2Flush; } - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2ConnectOptions.java b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2ConnectOptions.java index 1173c8a..260946b 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2ConnectOptions.java +++ b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2ConnectOptions.java @@ -6,6 +6,7 @@ import com.deepgram.core.ObjectMappers; import com.deepgram.types.SpeakV2Encoding; import com.deepgram.types.SpeakV2MipOptOut; +import com.deepgram.types.SpeakV2NormalizeVolume; import com.deepgram.types.SpeakV2SampleRate; import com.deepgram.types.SpeakV2Tag; import com.fasterxml.jackson.annotation.JsonAnyGetter; @@ -35,6 +36,8 @@ public final class V2ConnectOptions { private final Optional expressivity; + private final Optional normalizeVolume; + private final Optional mipOptOut; private final Optional tag; @@ -47,6 +50,7 @@ private V2ConnectOptions( Optional sampleRate, Optional speed, Optional expressivity, + Optional normalizeVolume, Optional mipOptOut, Optional tag, Map additionalProperties) { @@ -55,6 +59,7 @@ private V2ConnectOptions( this.sampleRate = sampleRate; this.speed = speed; this.expressivity = expressivity; + this.normalizeVolume = normalizeVolume; this.mipOptOut = mipOptOut; this.tag = tag; this.additionalProperties = additionalProperties; @@ -85,6 +90,11 @@ public Optional getExpressivity() { return expressivity; } + @JsonProperty("normalize_volume") + public Optional getNormalizeVolume() { + return normalizeVolume; + } + @JsonProperty("mip_opt_out") public Optional getMipOptOut() { return mipOptOut; @@ -112,6 +122,7 @@ private boolean equalTo(V2ConnectOptions other) { && sampleRate.equals(other.sampleRate) && speed.equals(other.speed) && expressivity.equals(other.expressivity) + && normalizeVolume.equals(other.normalizeVolume) && mipOptOut.equals(other.mipOptOut) && tag.equals(other.tag); } @@ -119,7 +130,14 @@ private boolean equalTo(V2ConnectOptions other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.model, this.encoding, this.sampleRate, this.speed, this.expressivity, this.mipOptOut, this.tag); + this.model, + this.encoding, + this.sampleRate, + this.speed, + this.expressivity, + this.normalizeVolume, + this.mipOptOut, + this.tag); } @java.lang.Override @@ -160,6 +178,10 @@ public interface _FinalStage { _FinalStage expressivity(Integer expressivity); + _FinalStage normalizeVolume(Optional normalizeVolume); + + _FinalStage normalizeVolume(SpeakV2NormalizeVolume normalizeVolume); + _FinalStage mipOptOut(Optional mipOptOut); _FinalStage mipOptOut(SpeakV2MipOptOut mipOptOut); @@ -177,6 +199,8 @@ public static final class Builder implements ModelStage, _FinalStage { private Optional mipOptOut = Optional.empty(); + private Optional normalizeVolume = Optional.empty(); + private Optional expressivity = Optional.empty(); private Optional speed = Optional.empty(); @@ -197,6 +221,7 @@ public Builder from(V2ConnectOptions other) { sampleRate(other.getSampleRate()); speed(other.getSpeed()); expressivity(other.getExpressivity()); + normalizeVolume(other.getNormalizeVolume()); mipOptOut(other.getMipOptOut()); tag(other.getTag()); return this; @@ -235,6 +260,19 @@ public _FinalStage mipOptOut(Optional mipOptOut) { return this; } + @java.lang.Override + public _FinalStage normalizeVolume(SpeakV2NormalizeVolume normalizeVolume) { + this.normalizeVolume = Optional.ofNullable(normalizeVolume); + return this; + } + + @java.lang.Override + @JsonSetter(value = "normalize_volume", nulls = Nulls.SKIP) + public _FinalStage normalizeVolume(Optional normalizeVolume) { + this.normalizeVolume = normalizeVolume; + return this; + } + @java.lang.Override public _FinalStage expressivity(Integer expressivity) { this.expressivity = Optional.ofNullable(expressivity); @@ -290,7 +328,15 @@ public _FinalStage encoding(Optional encoding) { @java.lang.Override public V2ConnectOptions build() { return new V2ConnectOptions( - model, encoding, sampleRate, speed, expressivity, mipOptOut, tag, additionalProperties); + model, + encoding, + sampleRate, + speed, + expressivity, + normalizeVolume, + mipOptOut, + tag, + additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java index b4e01f7..b18eaa5 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java @@ -6,7 +6,6 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -139,19 +138,17 @@ public CompletableFuture connect(V2ConnectOptions options) { urlBuilder.addQueryParameter( "expressivity", String.valueOf(options.getExpressivity().get())); } + if (options.getNormalizeVolume() != null && options.getNormalizeVolume().isPresent()) { + urlBuilder.addQueryParameter( + "normalize_volume", + String.valueOf(options.getNormalizeVolume().get())); + } if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { urlBuilder.addQueryParameter( "mip_opt_out", String.valueOf(options.getMipOptOut().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); + urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); @@ -619,8 +616,11 @@ private void handleIncomingMessage(String json) { return; } } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. + if (onErrorHandler != null) { + onErrorHandler.accept(new RuntimeException( + "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + + "... Update your SDK version to support new message types.")); + } } catch (Exception e) { if (onErrorHandler != null) { onErrorHandler.accept(e); diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java b/src/main/java/com/deepgram/types/DeepgramModel.java index 9fa2f8b..66a7093 100644 --- a/src/main/java/com/deepgram/types/DeepgramModel.java +++ b/src/main/java/com/deepgram/types/DeepgramModel.java @@ -7,20 +7,13 @@ import com.fasterxml.jackson.annotation.JsonValue; public final class DeepgramModel { - public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); - public static final DeepgramModel AURA2HERA_EN = new DeepgramModel(Value.AURA2HERA_EN, "aura-2-hera-en"); - public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); + public static final DeepgramModel FLUX_RITU_HI = new DeepgramModel(Value.FLUX_RITU_HI, "flux-ritu-hi"); - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); + public static final DeepgramModel FLUX_TOMAS_ES = new DeepgramModel(Value.FLUX_TOMAS_ES, "flux-tomas-es"); - public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); + public static final DeepgramModel FLUX_OLGA_RU = new DeepgramModel(Value.FLUX_OLGA_RU, "flux-olga-ru"); public static final DeepgramModel AURA2HARMONIA_EN = new DeepgramModel(Value.AURA2HARMONIA_EN, "aura-2-harmonia-en"); @@ -29,179 +22,640 @@ public final class DeepgramModel { public static final DeepgramModel FLUX_MEENA_EN = new DeepgramModel(Value.FLUX_MEENA_EN, "flux-meena-en"); - public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); + public static final DeepgramModel FLUX_POLINA_RU = new DeepgramModel(Value.FLUX_POLINA_RU, "flux-polina-ru"); public static final DeepgramModel AURA_ZEUS_EN = new DeepgramModel(Value.AURA_ZEUS_EN, "aura-zeus-en"); - public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); + public static final DeepgramModel FLUX_SRAVANI_TE = new DeepgramModel(Value.FLUX_SRAVANI_TE, "flux-sravani-te"); - public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); + public static final DeepgramModel FLUX_KONRAD_PL = new DeepgramModel(Value.FLUX_KONRAD_PL, "flux-konrad-pl"); public static final DeepgramModel AURA2NEPTUNE_EN = new DeepgramModel(Value.AURA2NEPTUNE_EN, "aura-2-neptune-en"); public static final DeepgramModel FLUX_BROOKE_EN = new DeepgramModel(Value.FLUX_BROOKE_EN, "flux-brooke-en"); - public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); - - public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); - public static final DeepgramModel AURA2CALLISTA_EN = new DeepgramModel(Value.AURA2CALLISTA_EN, "aura-2-callista-en"); - public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); + public static final DeepgramModel FLUX_JAKUB_CS = new DeepgramModel(Value.FLUX_JAKUB_CS, "flux-jakub-cs"); public static final DeepgramModel AURA2OPHELIA_EN = new DeepgramModel(Value.AURA2OPHELIA_EN, "aura-2-ophelia-en"); + public static final DeepgramModel FLUX_SABBIR_BN = new DeepgramModel(Value.FLUX_SABBIR_BN, "flux-sabbir-bn"); + public static final DeepgramModel FLUX_BRUCE_EN = new DeepgramModel(Value.FLUX_BRUCE_EN, "flux-bruce-en"); - public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); + public static final DeepgramModel FLUX_SUMAIYA_BN = new DeepgramModel(Value.FLUX_SUMAIYA_BN, "flux-sumaiya-bn"); - public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); + public static final DeepgramModel FLUX_ANJALI_HI = new DeepgramModel(Value.FLUX_ANJALI_HI, "flux-anjali-hi"); - public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); + public static final DeepgramModel FLUX_MAURICIO_ES = new DeepgramModel(Value.FLUX_MAURICIO_ES, "flux-mauricio-es"); - public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); + public static final DeepgramModel FLUX_CHRISTIAN_DE = + new DeepgramModel(Value.FLUX_CHRISTIAN_DE, "flux-christian-de"); - public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); + public static final DeepgramModel FLUX_GERGANA_BG = new DeepgramModel(Value.FLUX_GERGANA_BG, "flux-gergana-bg"); + + public static final DeepgramModel FLUX_IDA_NO = new DeepgramModel(Value.FLUX_IDA_NO, "flux-ida-no"); + + public static final DeepgramModel FLUX_JYOTI_HI = new DeepgramModel(Value.FLUX_JYOTI_HI, "flux-jyoti-hi"); + + public static final DeepgramModel FLUX_TRIIN_ET = new DeepgramModel(Value.FLUX_TRIIN_ET, "flux-triin-et"); public static final DeepgramModel FLUX_MARCUS_EN = new DeepgramModel(Value.FLUX_MARCUS_EN, "flux-marcus-en"); - public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); + public static final DeepgramModel FLUX_WENBO_ZH = new DeepgramModel(Value.FLUX_WENBO_ZH, "flux-wenbo-zh"); + + public static final DeepgramModel FLUX_SHUFEN_ZH = new DeepgramModel(Value.FLUX_SHUFEN_ZH, "flux-shufen-zh"); public static final DeepgramModel FLUX_PAIGE_EN = new DeepgramModel(Value.FLUX_PAIGE_EN, "flux-paige-en"); - public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); + public static final DeepgramModel FLUX_VINOTH_TA = new DeepgramModel(Value.FLUX_VINOTH_TA, "flux-vinoth-ta"); public static final DeepgramModel FLUX_DREW_EN = new DeepgramModel(Value.FLUX_DREW_EN, "flux-drew-en"); + public static final DeepgramModel FLUX_CHARLOTTA_SV = + new DeepgramModel(Value.FLUX_CHARLOTTA_SV, "flux-charlotta-sv"); + public static final DeepgramModel AURA2JAVIER_ES = new DeepgramModel(Value.AURA2JAVIER_ES, "aura-2-javier-es"); - public static final DeepgramModel AURA2ANDROMEDA_EN = - new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); + public static final DeepgramModel FLUX_CHLOE_FR = new DeepgramModel(Value.FLUX_CHLOE_FR, "flux-chloe-fr"); + + public static final DeepgramModel FLUX_FIORELLA_ES = new DeepgramModel(Value.FLUX_FIORELLA_ES, "flux-fiorella-es"); public static final DeepgramModel AURA2SATURN_EN = new DeepgramModel(Value.AURA2SATURN_EN, "aura-2-saturn-en"); + public static final DeepgramModel FLUX_PALLAVI_HI = new DeepgramModel(Value.FLUX_PALLAVI_HI, "flux-pallavi-hi"); + public static final DeepgramModel AURA2IRIS_EN = new DeepgramModel(Value.AURA2IRIS_EN, "aura-2-iris-en"); - public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); + public static final DeepgramModel FLUX_AINA_ES = new DeepgramModel(Value.FLUX_AINA_ES, "flux-aina-es"); - public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); + public static final DeepgramModel FLUX_MAXIM_RU = new DeepgramModel(Value.FLUX_MAXIM_RU, "flux-maxim-ru"); + + public static final DeepgramModel FLUX_ROLF_DE = new DeepgramModel(Value.FLUX_ROLF_DE, "flux-rolf-de"); + + public static final DeepgramModel FLUX_VEGARD_NO = new DeepgramModel(Value.FLUX_VEGARD_NO, "flux-vegard-no"); + + public static final DeepgramModel FLUX_HAZIQ_MS = new DeepgramModel(Value.FLUX_HAZIQ_MS, "flux-haziq-ms"); + + public static final DeepgramModel FLUX_LUUK_NL = new DeepgramModel(Value.FLUX_LUUK_NL, "flux-luuk-nl"); + + public static final DeepgramModel FLUX_PILAR_ES = new DeepgramModel(Value.FLUX_PILAR_ES, "flux-pilar-es"); + + public static final DeepgramModel FLUX_MEHMET_TR = new DeepgramModel(Value.FLUX_MEHMET_TR, "flux-mehmet-tr"); + + public static final DeepgramModel FLUX_RAHUL_HI = new DeepgramModel(Value.FLUX_RAHUL_HI, "flux-rahul-hi"); public static final DeepgramModel FLUX_BRITTANY_EN = new DeepgramModel(Value.FLUX_BRITTANY_EN, "flux-brittany-en"); public static final DeepgramModel FLUX_SEAN_EN = new DeepgramModel(Value.FLUX_SEAN_EN, "flux-sean-en"); + public static final DeepgramModel FLUX_EUNJI_KO = new DeepgramModel(Value.FLUX_EUNJI_KO, "flux-eunji-ko"); + + public static final DeepgramModel FLUX_SILJE_NO = new DeepgramModel(Value.FLUX_SILJE_NO, "flux-silje-no"); + + public static final DeepgramModel FLUX_NOEL_TL = new DeepgramModel(Value.FLUX_NOEL_TL, "flux-noel-tl"); + public static final DeepgramModel AURA2HELENA_EN = new DeepgramModel(Value.AURA2HELENA_EN, "aura-2-helena-en"); - public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); + public static final DeepgramModel FLUX_JULIEN_FR = new DeepgramModel(Value.FLUX_JULIEN_FR, "flux-julien-fr"); - public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); + public static final DeepgramModel FLUX_AYUMI_JA = new DeepgramModel(Value.FLUX_AYUMI_JA, "flux-ayumi-ja"); public static final DeepgramModel FLUX_JACK_EN = new DeepgramModel(Value.FLUX_JACK_EN, "flux-jack-en"); - public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); - public static final DeepgramModel FLUX_PRIYA_EN = new DeepgramModel(Value.FLUX_PRIYA_EN, "flux-priya-en"); public static final DeepgramModel AURA_HELIOS_EN = new DeepgramModel(Value.AURA_HELIOS_EN, "aura-helios-en"); + public static final DeepgramModel FLUX_KIRSI_FI = new DeepgramModel(Value.FLUX_KIRSI_FI, "flux-kirsi-fi"); + + public static final DeepgramModel FLUX_WILMA_SV = new DeepgramModel(Value.FLUX_WILMA_SV, "flux-wilma-sv"); + + public static final DeepgramModel FLUX_LEANDRO_PT = new DeepgramModel(Value.FLUX_LEANDRO_PT, "flux-leandro-pt"); + public static final DeepgramModel AURA2JANUS_EN = new DeepgramModel(Value.AURA2JANUS_EN, "aura-2-janus-en"); public static final DeepgramModel AURA2NESTOR_ES = new DeepgramModel(Value.AURA2NESTOR_ES, "aura-2-nestor-es"); - public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); + public static final DeepgramModel FLUX_BRAM_NL = new DeepgramModel(Value.FLUX_BRAM_NL, "flux-bram-nl"); + + public static final DeepgramModel FLUX_FEDERICO_IT = new DeepgramModel(Value.FLUX_FEDERICO_IT, "flux-federico-it"); + + public static final DeepgramModel FLUX_TIBOR_HU = new DeepgramModel(Value.FLUX_TIBOR_HU, "flux-tibor-hu"); + + public static final DeepgramModel FLUX_EDGARS_LV = new DeepgramModel(Value.FLUX_EDGARS_LV, "flux-edgars-lv"); + + public static final DeepgramModel FLUX_MANJUNATH_KN = + new DeepgramModel(Value.FLUX_MANJUNATH_KN, "flux-manjunath-kn"); + + public static final DeepgramModel FLUX_ZUZANNA_PL = new DeepgramModel(Value.FLUX_ZUZANNA_PL, "flux-zuzanna-pl"); public static final DeepgramModel AURA2MINERVA_EN = new DeepgramModel(Value.AURA2MINERVA_EN, "aura-2-minerva-en"); + public static final DeepgramModel FLUX_PONTUS_SV = new DeepgramModel(Value.FLUX_PONTUS_SV, "flux-pontus-sv"); + public static final DeepgramModel AURA2ALVARO_ES = new DeepgramModel(Value.AURA2ALVARO_ES, "aura-2-alvaro-es"); + public static final DeepgramModel FLUX_AXEL_SV = new DeepgramModel(Value.FLUX_AXEL_SV, "flux-axel-sv"); + + public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); + + public static final DeepgramModel FLUX_VEDRAN_HR = new DeepgramModel(Value.FLUX_VEDRAN_HR, "flux-vedran-hr"); + + public static final DeepgramModel FLUX_DUVAN_ES = new DeepgramModel(Value.FLUX_DUVAN_ES, "flux-duvan-es"); + + public static final DeepgramModel FLUX_JIE_ZH = new DeepgramModel(Value.FLUX_JIE_ZH, "flux-jie-zh"); + + public static final DeepgramModel FLUX_MORITZ_DE = new DeepgramModel(Value.FLUX_MORITZ_DE, "flux-moritz-de"); + + public static final DeepgramModel FLUX_JUDIT_CA = new DeepgramModel(Value.FLUX_JUDIT_CA, "flux-judit-ca"); + + public static final DeepgramModel FLUX_KINGA_HU = new DeepgramModel(Value.FLUX_KINGA_HU, "flux-kinga-hu"); + + public static final DeepgramModel FLUX_HOA_VI = new DeepgramModel(Value.FLUX_HOA_VI, "flux-hoa-vi"); + + public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); + + public static final DeepgramModel FLUX_ANOUK_NL = new DeepgramModel(Value.FLUX_ANOUK_NL, "flux-anouk-nl"); + + public static final DeepgramModel FLUX_NIKHIL_HI = new DeepgramModel(Value.FLUX_NIKHIL_HI, "flux-nikhil-hi"); + + public static final DeepgramModel FLUX_YSABEL_ES = new DeepgramModel(Value.FLUX_YSABEL_ES, "flux-ysabel-es"); + + public static final DeepgramModel FLUX_POOJA_MR = new DeepgramModel(Value.FLUX_POOJA_MR, "flux-pooja-mr"); + + public static final DeepgramModel FLUX_NERINGA_LT = new DeepgramModel(Value.FLUX_NERINGA_LT, "flux-neringa-lt"); + + public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); + + public static final DeepgramModel FLUX_MARIANA_PT = new DeepgramModel(Value.FLUX_MARIANA_PT, "flux-mariana-pt"); + + public static final DeepgramModel FLUX_MIHAELA_HR = new DeepgramModel(Value.FLUX_MIHAELA_HR, "flux-mihaela-hr"); + + public static final DeepgramModel FLUX_KOSTAS_EL = new DeepgramModel(Value.FLUX_KOSTAS_EL, "flux-kostas-el"); + + public static final DeepgramModel FLUX_ISHRAT_BN = new DeepgramModel(Value.FLUX_ISHRAT_BN, "flux-ishrat-bn"); + + public static final DeepgramModel FLUX_VITO_IT = new DeepgramModel(Value.FLUX_VITO_IT, "flux-vito-it"); + + public static final DeepgramModel FLUX_DEWI_ID = new DeepgramModel(Value.FLUX_DEWI_ID, "flux-dewi-id"); + + public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); + + public static final DeepgramModel FLUX_TEEMU_FI = new DeepgramModel(Value.FLUX_TEEMU_FI, "flux-teemu-fi"); + + public static final DeepgramModel FLUX_SOWMYA_TA = new DeepgramModel(Value.FLUX_SOWMYA_TA, "flux-sowmya-ta"); + + public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); + + public static final DeepgramModel FLUX_HAORAN_ZH = new DeepgramModel(Value.FLUX_HAORAN_ZH, "flux-haoran-zh"); + + public static final DeepgramModel AURA2AMALTHEA_EN = + new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); + + public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); + + public static final DeepgramModel FLUX_ROBERTO_PT = new DeepgramModel(Value.FLUX_ROBERTO_PT, "flux-roberto-pt"); + + public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); + + public static final DeepgramModel FLUX_JEROME_TL = new DeepgramModel(Value.FLUX_JEROME_TL, "flux-jerome-tl"); + + public static final DeepgramModel FLUX_BENOIT_FR = new DeepgramModel(Value.FLUX_BENOIT_FR, "flux-benoit-fr"); + + public static final DeepgramModel FLUX_SOFIA_IT = new DeepgramModel(Value.FLUX_SOFIA_IT, "flux-sofia-it"); + + public static final DeepgramModel FLUX_WENJING_ZH = new DeepgramModel(Value.FLUX_WENJING_ZH, "flux-wenjing-zh"); + + public static final DeepgramModel FLUX_SERKAN_TR = new DeepgramModel(Value.FLUX_SERKAN_TR, "flux-serkan-tr"); + + public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); + + public static final DeepgramModel FLUX_LIEZEL_TL = new DeepgramModel(Value.FLUX_LIEZEL_TL, "flux-liezel-tl"); + + public static final DeepgramModel FLUX_TEGUH_ID = new DeepgramModel(Value.FLUX_TEGUH_ID, "flux-teguh-id"); + + public static final DeepgramModel FLUX_MARTA_PT = new DeepgramModel(Value.FLUX_MARTA_PT, "flux-marta-pt"); + + public static final DeepgramModel FLUX_RIZKY_ID = new DeepgramModel(Value.FLUX_RIZKY_ID, "flux-rizky-id"); + + public static final DeepgramModel FLUX_RASMUS_DA = new DeepgramModel(Value.FLUX_RASMUS_DA, "flux-rasmus-da"); + + public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); + + public static final DeepgramModel FLUX_FLORIAN_FR = new DeepgramModel(Value.FLUX_FLORIAN_FR, "flux-florian-fr"); + + public static final DeepgramModel FLUX_ERLEND_NO = new DeepgramModel(Value.FLUX_ERLEND_NO, "flux-erlend-no"); + + public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); + + public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); + + public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); + + public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); + + public static final DeepgramModel FLUX_ECEM_TR = new DeepgramModel(Value.FLUX_ECEM_TR, "flux-ecem-tr"); + + public static final DeepgramModel FLUX_SANNE_NL = new DeepgramModel(Value.FLUX_SANNE_NL, "flux-sanne-nl"); + + public static final DeepgramModel FLUX_BIANCA_PT = new DeepgramModel(Value.FLUX_BIANCA_PT, "flux-bianca-pt"); + + public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); + + public static final DeepgramModel FLUX_SUNITA_HI = new DeepgramModel(Value.FLUX_SUNITA_HI, "flux-sunita-hi"); + + public static final DeepgramModel FLUX_OSKAR_SV = new DeepgramModel(Value.FLUX_OSKAR_SV, "flux-oskar-sv"); + + public static final DeepgramModel FLUX_FAJAR_ID = new DeepgramModel(Value.FLUX_FAJAR_ID, "flux-fajar-id"); + + public static final DeepgramModel FLUX_VINCENZO_IT = new DeepgramModel(Value.FLUX_VINCENZO_IT, "flux-vincenzo-it"); + + public static final DeepgramModel FLUX_CATARINA_PT = new DeepgramModel(Value.FLUX_CATARINA_PT, "flux-catarina-pt"); + + public static final DeepgramModel FLUX_KATJA_SL = new DeepgramModel(Value.FLUX_KATJA_SL, "flux-katja-sl"); + + public static final DeepgramModel FLUX_JASNA_HR = new DeepgramModel(Value.FLUX_JASNA_HR, "flux-jasna-hr"); + + public static final DeepgramModel FLUX_BRIGITTE_FR = new DeepgramModel(Value.FLUX_BRIGITTE_FR, "flux-brigitte-fr"); + + public static final DeepgramModel FLUX_MATEUS_PT = new DeepgramModel(Value.FLUX_MATEUS_PT, "flux-mateus-pt"); + + public static final DeepgramModel FLUX_GIORGIO_IT = new DeepgramModel(Value.FLUX_GIORGIO_IT, "flux-giorgio-it"); + + public static final DeepgramModel AURA2CORDELIA_EN = + new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); + + public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); + + public static final DeepgramModel FLUX_DIRK_NL = new DeepgramModel(Value.FLUX_DIRK_NL, "flux-dirk-nl"); + + public static final DeepgramModel FLUX_DILEK_TR = new DeepgramModel(Value.FLUX_DILEK_TR, "flux-dilek-tr"); + + public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); + + public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); + + public static final DeepgramModel FLUX_BHAVNA_GU = new DeepgramModel(Value.FLUX_BHAVNA_GU, "flux-bhavna-gu"); + + public static final DeepgramModel FLUX_AJAY_HI = new DeepgramModel(Value.FLUX_AJAY_HI, "flux-ajay-hi"); + + public static final DeepgramModel FLUX_BRUNO_PT = new DeepgramModel(Value.FLUX_BRUNO_PT, "flux-bruno-pt"); + + public static final DeepgramModel FLUX_HUGO_PT = new DeepgramModel(Value.FLUX_HUGO_PT, "flux-hugo-pt"); + + public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); + + public static final DeepgramModel FLUX_JIAN_ZH = new DeepgramModel(Value.FLUX_JIAN_ZH, "flux-jian-zh"); + + public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); + + public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); + + public static final DeepgramModel FLUX_IOANA_RO = new DeepgramModel(Value.FLUX_IOANA_RO, "flux-ioana-ro"); + + public static final DeepgramModel FLUX_DENYS_UK = new DeepgramModel(Value.FLUX_DENYS_UK, "flux-denys-uk"); + + public static final DeepgramModel FLUX_YASMINE_FR = new DeepgramModel(Value.FLUX_YASMINE_FR, "flux-yasmine-fr"); + + public static final DeepgramModel FLUX_NATALIA_RU = new DeepgramModel(Value.FLUX_NATALIA_RU, "flux-natalia-ru"); + + public static final DeepgramModel FLUX_BARTOSZ_PL = new DeepgramModel(Value.FLUX_BARTOSZ_PL, "flux-bartosz-pl"); + + public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); + + public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); + + public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); + + public static final DeepgramModel FLUX_IRENE_NL = new DeepgramModel(Value.FLUX_IRENE_NL, "flux-irene-nl"); + + public static final DeepgramModel FLUX_GIZEM_TR = new DeepgramModel(Value.FLUX_GIZEM_TR, "flux-gizem-tr"); + + public static final DeepgramModel FLUX_PERNILLE_DA = new DeepgramModel(Value.FLUX_PERNILLE_DA, "flux-pernille-da"); + + public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); + + public static final DeepgramModel FLUX_MATTEO_IT = new DeepgramModel(Value.FLUX_MATTEO_IT, "flux-matteo-it"); + + public static final DeepgramModel FLUX_FRIDA_SV = new DeepgramModel(Value.FLUX_FRIDA_SV, "flux-frida-sv"); + + public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); + + public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); + + public static final DeepgramModel FLUX_MAMUN_BN = new DeepgramModel(Value.FLUX_MAMUN_BN, "flux-mamun-bn"); + + public static final DeepgramModel FLUX_CLAUDIA_PT = new DeepgramModel(Value.FLUX_CLAUDIA_PT, "flux-claudia-pt"); + + public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); + + public static final DeepgramModel FLUX_BO_ZH = new DeepgramModel(Value.FLUX_BO_ZH, "flux-bo-zh"); + + public static final DeepgramModel FLUX_HETAL_GU = new DeepgramModel(Value.FLUX_HETAL_GU, "flux-hetal-gu"); + + public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); + + public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); + + public static final DeepgramModel FLUX_ZHEN_ZH = new DeepgramModel(Value.FLUX_ZHEN_ZH, "flux-zhen-zh"); + + public static final DeepgramModel FLUX_BENEDITA_PT = new DeepgramModel(Value.FLUX_BENEDITA_PT, "flux-benedita-pt"); + + public static final DeepgramModel FLUX_SHREYA_HI = new DeepgramModel(Value.FLUX_SHREYA_HI, "flux-shreya-hi"); + + public static final DeepgramModel FLUX_MINH_VI = new DeepgramModel(Value.FLUX_MINH_VI, "flux-minh-vi"); + + public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); + + public static final DeepgramModel FLUX_ZEYNEP_TR = new DeepgramModel(Value.FLUX_ZEYNEP_TR, "flux-zeynep-tr"); + + public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); + + public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); + + public static final DeepgramModel FLUX_CAMILLE_FR = new DeepgramModel(Value.FLUX_CAMILLE_FR, "flux-camille-fr"); + + public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); + + public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); + + public static final DeepgramModel FLUX_TOBIAS_DE = new DeepgramModel(Value.FLUX_TOBIAS_DE, "flux-tobias-de"); + + public static final DeepgramModel FLUX_KUANYU_ZH = new DeepgramModel(Value.FLUX_KUANYU_ZH, "flux-kuanyu-zh"); + + public static final DeepgramModel FLUX_EWA_PL = new DeepgramModel(Value.FLUX_EWA_PL, "flux-ewa-pl"); + + public static final DeepgramModel FLUX_SONJA_DE = new DeepgramModel(Value.FLUX_SONJA_DE, "flux-sonja-de"); + + public static final DeepgramModel FLUX_ANGELA_IT = new DeepgramModel(Value.FLUX_ANGELA_IT, "flux-angela-it"); + + public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); + + public static final DeepgramModel FLUX_BENJAMIN_DE = new DeepgramModel(Value.FLUX_BENJAMIN_DE, "flux-benjamin-de"); + + public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); + + public static final DeepgramModel FLUX_TRISHA_TL = new DeepgramModel(Value.FLUX_TRISHA_TL, "flux-trisha-tl"); + + public static final DeepgramModel FLUX_RENATO_PT = new DeepgramModel(Value.FLUX_RENATO_PT, "flux-renato-pt"); + + public static final DeepgramModel FLUX_PAVAN_TE = new DeepgramModel(Value.FLUX_PAVAN_TE, "flux-pavan-te"); + + public static final DeepgramModel AURA2ANDROMEDA_EN = + new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); + + public static final DeepgramModel FLUX_SIGNE_NO = new DeepgramModel(Value.FLUX_SIGNE_NO, "flux-signe-no"); + + public static final DeepgramModel FLUX_KACPER_PL = new DeepgramModel(Value.FLUX_KACPER_PL, "flux-kacper-pl"); + + public static final DeepgramModel FLUX_RAVI_TE = new DeepgramModel(Value.FLUX_RAVI_TE, "flux-ravi-te"); + + public static final DeepgramModel FLUX_KAVYA_TA = new DeepgramModel(Value.FLUX_KAVYA_TA, "flux-kavya-ta"); + + public static final DeepgramModel FLUX_JOMAR_TL = new DeepgramModel(Value.FLUX_JOMAR_TL, "flux-jomar-tl"); + + public static final DeepgramModel FLUX_DIVYA_HI = new DeepgramModel(Value.FLUX_DIVYA_HI, "flux-divya-hi"); + + public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); + + public static final DeepgramModel FLUX_VEERLE_NL = new DeepgramModel(Value.FLUX_VEERLE_NL, "flux-veerle-nl"); + + public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); + + public static final DeepgramModel FLUX_MARTIN_ES = new DeepgramModel(Value.FLUX_MARTIN_ES, "flux-martin-es"); + + public static final DeepgramModel FLUX_DOMINIKA_SK = new DeepgramModel(Value.FLUX_DOMINIKA_SK, "flux-dominika-sk"); + + public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); + + public static final DeepgramModel FLUX_ESPEN_NO = new DeepgramModel(Value.FLUX_ESPEN_NO, "flux-espen-no"); + + public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); + + public static final DeepgramModel FLUX_MIKYUNG_KO = new DeepgramModel(Value.FLUX_MIKYUNG_KO, "flux-mikyung-ko"); + + public static final DeepgramModel FLUX_PEDRO_PT = new DeepgramModel(Value.FLUX_PEDRO_PT, "flux-pedro-pt"); + + public static final DeepgramModel FLUX_JUSTYNA_PL = new DeepgramModel(Value.FLUX_JUSTYNA_PL, "flux-justyna-pl"); + + public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); + + public static final DeepgramModel FLUX_AMBREEN_UR = new DeepgramModel(Value.FLUX_AMBREEN_UR, "flux-ambreen-ur"); + + public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); + + public static final DeepgramModel FLUX_GUSTAVO_ES = new DeepgramModel(Value.FLUX_GUSTAVO_ES, "flux-gustavo-es"); + + public static final DeepgramModel FLUX_SNEHA_MR = new DeepgramModel(Value.FLUX_SNEHA_MR, "flux-sneha-mr"); + + public static final DeepgramModel FLUX_LUDVIG_SV = new DeepgramModel(Value.FLUX_LUDVIG_SV, "flux-ludvig-sv"); + + public static final DeepgramModel FLUX_MONIQUE_NL = new DeepgramModel(Value.FLUX_MONIQUE_NL, "flux-monique-nl"); + public static final DeepgramModel AURA_PERSEUS_EN = new DeepgramModel(Value.AURA_PERSEUS_EN, "aura-perseus-en"); public static final DeepgramModel AURA2VESTA_EN = new DeepgramModel(Value.AURA2VESTA_EN, "aura-2-vesta-en"); - public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); + public static final DeepgramModel FLUX_ARTUR_PT = new DeepgramModel(Value.FLUX_ARTUR_PT, "flux-artur-pt"); + + public static final DeepgramModel FLUX_FITRI_ID = new DeepgramModel(Value.FLUX_FITRI_ID, "flux-fitri-id"); public static final DeepgramModel AURA2ZEUS_EN = new DeepgramModel(Value.AURA2ZEUS_EN, "aura-2-zeus-en"); + public static final DeepgramModel FLUX_CECILIA_ES = new DeepgramModel(Value.FLUX_CECILIA_ES, "flux-cecilia-es"); + + public static final DeepgramModel FLUX_FERNANDA_ES = new DeepgramModel(Value.FLUX_FERNANDA_ES, "flux-fernanda-es"); + public static final DeepgramModel AURA2ORPHEUS_EN = new DeepgramModel(Value.AURA2ORPHEUS_EN, "aura-2-orpheus-en"); + public static final DeepgramModel FLUX_PRACHI_HI = new DeepgramModel(Value.FLUX_PRACHI_HI, "flux-prachi-hi"); + + public static final DeepgramModel FLUX_MANLOK_ZH = new DeepgramModel(Value.FLUX_MANLOK_ZH, "flux-manlok-zh"); + + public static final DeepgramModel FLUX_HYUNWOO_KO = new DeepgramModel(Value.FLUX_HYUNWOO_KO, "flux-hyunwoo-ko"); + public static final DeepgramModel AURA2THALIA_EN = new DeepgramModel(Value.AURA2THALIA_EN, "aura-2-thalia-en"); public static final DeepgramModel FLUX_NAVEEN_EN = new DeepgramModel(Value.FLUX_NAVEEN_EN, "flux-naveen-en"); - public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); + public static final DeepgramModel FLUX_STEFANO_IT = new DeepgramModel(Value.FLUX_STEFANO_IT, "flux-stefano-it"); + + public static final DeepgramModel FLUX_LOTTE_NL = new DeepgramModel(Value.FLUX_LOTTE_NL, "flux-lotte-nl"); + + public static final DeepgramModel FLUX_LEONIE_DE = new DeepgramModel(Value.FLUX_LEONIE_DE, "flux-leonie-de"); + + public static final DeepgramModel FLUX_JANINE_DE = new DeepgramModel(Value.FLUX_JANINE_DE, "flux-janine-de"); + + public static final DeepgramModel FLUX_AGNESE_LV = new DeepgramModel(Value.FLUX_AGNESE_LV, "flux-agnese-lv"); + + public static final DeepgramModel FLUX_VERENA_DE = new DeepgramModel(Value.FLUX_VERENA_DE, "flux-verena-de"); public static final DeepgramModel AURA2SELENA_ES = new DeepgramModel(Value.AURA2SELENA_ES, "aura-2-selena-es"); - public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); + public static final DeepgramModel FLUX_RICARDO_PT = new DeepgramModel(Value.FLUX_RICARDO_PT, "flux-ricardo-pt"); - public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); + public static final DeepgramModel FLUX_AFSANA_BN = new DeepgramModel(Value.FLUX_AFSANA_BN, "flux-afsana-bn"); - public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); + public static final DeepgramModel FLUX_NADINE_DE = new DeepgramModel(Value.FLUX_NADINE_DE, "flux-nadine-de"); + + public static final DeepgramModel FLUX_DESISLAVA_BG = + new DeepgramModel(Value.FLUX_DESISLAVA_BG, "flux-desislava-bg"); + + public static final DeepgramModel FLUX_MIKHAIL_RU = new DeepgramModel(Value.FLUX_MIKHAIL_RU, "flux-mikhail-ru"); + + public static final DeepgramModel FLUX_YAWEN_ZH = new DeepgramModel(Value.FLUX_YAWEN_ZH, "flux-yawen-zh"); + + public static final DeepgramModel FLUX_VALENTINA_ES = + new DeepgramModel(Value.FLUX_VALENTINA_ES, "flux-valentina-es"); + + public static final DeepgramModel FLUX_YUTING_ZH = new DeepgramModel(Value.FLUX_YUTING_ZH, "flux-yuting-zh"); + + public static final DeepgramModel FLUX_MIGUEL_PT = new DeepgramModel(Value.FLUX_MIGUEL_PT, "flux-miguel-pt"); + + public static final DeepgramModel FLUX_DALIBOR_HR = new DeepgramModel(Value.FLUX_DALIBOR_HR, "flux-dalibor-hr"); public static final DeepgramModel AURA_LUNA_EN = new DeepgramModel(Value.AURA_LUNA_EN, "aura-luna-en"); public static final DeepgramModel AURA_ORPHEUS_EN = new DeepgramModel(Value.AURA_ORPHEUS_EN, "aura-orpheus-en"); - public static final DeepgramModel AURA2AMALTHEA_EN = - new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); + public static final DeepgramModel FLUX_PATRICIA_ES = new DeepgramModel(Value.FLUX_PATRICIA_ES, "flux-patricia-es"); + + public static final DeepgramModel FLUX_RODRIGO_PT = new DeepgramModel(Value.FLUX_RODRIGO_PT, "flux-rodrigo-pt"); + + public static final DeepgramModel FLUX_GOKUL_TA = new DeepgramModel(Value.FLUX_GOKUL_TA, "flux-gokul-ta"); public static final DeepgramModel FLUX_DONOVAN_EN = new DeepgramModel(Value.FLUX_DONOVAN_EN, "flux-donovan-en"); - public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); + public static final DeepgramModel FLUX_THIERRY_FR = new DeepgramModel(Value.FLUX_THIERRY_FR, "flux-thierry-fr"); - public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); + public static final DeepgramModel FLUX_PAOLA_IT = new DeepgramModel(Value.FLUX_PAOLA_IT, "flux-paola-it"); - public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); + public static final DeepgramModel FLUX_CHIAYING_ZH = new DeepgramModel(Value.FLUX_CHIAYING_ZH, "flux-chiaying-zh"); - public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); + public static final DeepgramModel FLUX_MATHIEU_FR = new DeepgramModel(Value.FLUX_MATHIEU_FR, "flux-mathieu-fr"); + + public static final DeepgramModel FLUX_ALFREDO_ES = new DeepgramModel(Value.FLUX_ALFREDO_ES, "flux-alfredo-es"); + + public static final DeepgramModel FLUX_GREGOR_SL = new DeepgramModel(Value.FLUX_GREGOR_SL, "flux-gregor-sl"); + + public static final DeepgramModel FLUX_HAYATO_JA = new DeepgramModel(Value.FLUX_HAYATO_JA, "flux-hayato-ja"); + + public static final DeepgramModel FLUX_SHUVO_BN = new DeepgramModel(Value.FLUX_SHUVO_BN, "flux-shuvo-bn"); + + public static final DeepgramModel FLUX_NIELS_NL = new DeepgramModel(Value.FLUX_NIELS_NL, "flux-niels-nl"); + + public static final DeepgramModel FLUX_ARJUN_HI = new DeepgramModel(Value.FLUX_ARJUN_HI, "flux-arjun-hi"); + + public static final DeepgramModel FLUX_ROCCO_IT = new DeepgramModel(Value.FLUX_ROCCO_IT, "flux-rocco-it"); + + public static final DeepgramModel FLUX_CARMEN_ES = new DeepgramModel(Value.FLUX_CARMEN_ES, "flux-carmen-es"); public static final DeepgramModel AURA2PHOEBE_EN = new DeepgramModel(Value.AURA2PHOEBE_EN, "aura-2-phoebe-en"); - public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); + public static final DeepgramModel FLUX_ESZTER_HU = new DeepgramModel(Value.FLUX_ESZTER_HU, "flux-eszter-hu"); + + public static final DeepgramModel FLUX_PRATIK_MR = new DeepgramModel(Value.FLUX_PRATIK_MR, "flux-pratik-mr"); + + public static final DeepgramModel FLUX_FLEUR_NL = new DeepgramModel(Value.FLUX_FLEUR_NL, "flux-fleur-nl"); + + public static final DeepgramModel FLUX_RAFAEL_ES = new DeepgramModel(Value.FLUX_RAFAEL_ES, "flux-rafael-es"); public static final DeepgramModel AURA2DIANA_ES = new DeepgramModel(Value.AURA2DIANA_ES, "aura-2-diana-es"); - public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); + public static final DeepgramModel FLUX_CHIARA_IT = new DeepgramModel(Value.FLUX_CHIARA_IT, "flux-chiara-it"); - public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); + public static final DeepgramModel FLUX_ANDREI_RU = new DeepgramModel(Value.FLUX_ANDREI_RU, "flux-andrei-ru"); - public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); + public static final DeepgramModel FLUX_JOSIPA_HR = new DeepgramModel(Value.FLUX_JOSIPA_HR, "flux-josipa-hr"); public static final DeepgramModel AURA2THEIA_EN = new DeepgramModel(Value.AURA2THEIA_EN, "aura-2-theia-en"); + public static final DeepgramModel FLUX_VERONIQUE_FR = + new DeepgramModel(Value.FLUX_VERONIQUE_FR, "flux-veronique-fr"); + public static final DeepgramModel FLUX_WADE_EN = new DeepgramModel(Value.FLUX_WADE_EN, "flux-wade-en"); - public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); + public static final DeepgramModel FLUX_JAIME_ES = new DeepgramModel(Value.FLUX_JAIME_ES, "flux-jaime-es"); + + public static final DeepgramModel FLUX_NOZOMI_JA = new DeepgramModel(Value.FLUX_NOZOMI_JA, "flux-nozomi-ja"); + + public static final DeepgramModel FLUX_DOMAGOJ_HR = new DeepgramModel(Value.FLUX_DOMAGOJ_HR, "flux-domagoj-hr"); + + public static final DeepgramModel FLUX_VIKRAM_HI = new DeepgramModel(Value.FLUX_VIKRAM_HI, "flux-vikram-hi"); + + public static final DeepgramModel FLUX_SOLOMIYA_UK = new DeepgramModel(Value.FLUX_SOLOMIYA_UK, "flux-solomiya-uk"); + + public static final DeepgramModel FLUX_MARCIA_PT = new DeepgramModel(Value.FLUX_MARCIA_PT, "flux-marcia-pt"); + + public static final DeepgramModel FLUX_RIKKE_DA = new DeepgramModel(Value.FLUX_RIKKE_DA, "flux-rikke-da"); + + public static final DeepgramModel FLUX_ARNAUD_FR = new DeepgramModel(Value.FLUX_ARNAUD_FR, "flux-arnaud-fr"); + + public static final DeepgramModel FLUX_SVEN_DE = new DeepgramModel(Value.FLUX_SVEN_DE, "flux-sven-de"); + + public static final DeepgramModel FLUX_RAJESH_HI = new DeepgramModel(Value.FLUX_RAJESH_HI, "flux-rajesh-hi"); public static final DeepgramModel FLUX_CLIFF_EN = new DeepgramModel(Value.FLUX_CLIFF_EN, "flux-cliff-en"); + public static final DeepgramModel FLUX_YVONNE_NL = new DeepgramModel(Value.FLUX_YVONNE_NL, "flux-yvonne-nl"); + + public static final DeepgramModel FLUX_ERNESTO_ES = new DeepgramModel(Value.FLUX_ERNESTO_ES, "flux-ernesto-es"); + + public static final DeepgramModel FLUX_MAGDALENA_DE = + new DeepgramModel(Value.FLUX_MAGDALENA_DE, "flux-magdalena-de"); + public static final DeepgramModel AURA2JUPITER_EN = new DeepgramModel(Value.AURA2JUPITER_EN, "aura-2-jupiter-en"); + public static final DeepgramModel FLUX_JURAJ_SK = new DeepgramModel(Value.FLUX_JURAJ_SK, "flux-juraj-sk"); + public static final DeepgramModel FLUX_KIT_EN = new DeepgramModel(Value.FLUX_KIT_EN, "flux-kit-en"); + public static final DeepgramModel FLUX_MINJUN_KO = new DeepgramModel(Value.FLUX_MINJUN_KO, "flux-minjun-ko"); + + public static final DeepgramModel FLUX_KIRILL_RU = new DeepgramModel(Value.FLUX_KIRILL_RU, "flux-kirill-ru"); + public static final DeepgramModel AURA2AQUILA_ES = new DeepgramModel(Value.AURA2AQUILA_ES, "aura-2-aquila-es"); public static final DeepgramModel AURA2CORA_EN = new DeepgramModel(Value.AURA2CORA_EN, "aura-2-cora-en"); - public static final DeepgramModel AURA2CORDELIA_EN = - new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); + public static final DeepgramModel FLUX_DANIJELA_HR = new DeepgramModel(Value.FLUX_DANIJELA_HR, "flux-danijela-hr"); - public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); + public static final DeepgramModel FLUX_NIKOLAI_RU = new DeepgramModel(Value.FLUX_NIKOLAI_RU, "flux-nikolai-ru"); + + public static final DeepgramModel FLUX_LIJUAN_ZH = new DeepgramModel(Value.FLUX_LIJUAN_ZH, "flux-lijuan-zh"); + + public static final DeepgramModel FLUX_SUNGMIN_KO = new DeepgramModel(Value.FLUX_SUNGMIN_KO, "flux-sungmin-ko"); + + public static final DeepgramModel FLUX_YANNICK_DE = new DeepgramModel(Value.FLUX_YANNICK_DE, "flux-yannick-de"); + + public static final DeepgramModel FLUX_EDUARDO_ES = new DeepgramModel(Value.FLUX_EDUARDO_ES, "flux-eduardo-es"); + + public static final DeepgramModel FLUX_JORDI_CA = new DeepgramModel(Value.FLUX_JORDI_CA, "flux-jordi-ca"); + + public static final DeepgramModel FLUX_GODA_LT = new DeepgramModel(Value.FLUX_GODA_LT, "flux-goda-lt"); + + public static final DeepgramModel FLUX_BENCE_HU = new DeepgramModel(Value.FLUX_BENCE_HU, "flux-bence-hu"); + + public static final DeepgramModel FLUX_COSMIN_RO = new DeepgramModel(Value.FLUX_COSMIN_RO, "flux-cosmin-ro"); + + public static final DeepgramModel FLUX_EMRE_TR = new DeepgramModel(Value.FLUX_EMRE_TR, "flux-emre-tr"); public static final DeepgramModel AURA2HYPERION_EN = new DeepgramModel(Value.AURA2HYPERION_EN, "aura-2-hyperion-en"); public static final DeepgramModel AURA2CELESTE_ES = new DeepgramModel(Value.AURA2CELESTE_ES, "aura-2-celeste-es"); - public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); - - public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); + public static final DeepgramModel FLUX_RUBEN_NL = new DeepgramModel(Value.FLUX_RUBEN_NL, "flux-ruben-nl"); public static final DeepgramModel AURA2ARCAS_EN = new DeepgramModel(Value.AURA2ARCAS_EN, "aura-2-arcas-en"); public static final DeepgramModel FLUX_COLIN_EN = new DeepgramModel(Value.FLUX_COLIN_EN, "flux-colin-en"); + public static final DeepgramModel FLUX_SOOJIN_KO = new DeepgramModel(Value.FLUX_SOOJIN_KO, "flux-soojin-ko"); + public static final DeepgramModel AURA_ATHENA_EN = new DeepgramModel(Value.AURA_ATHENA_EN, "aura-athena-en"); public static final DeepgramModel AURA2ODYSSEUS_EN = @@ -209,17 +663,23 @@ public final class DeepgramModel { public static final DeepgramModel AURA2PANDORA_EN = new DeepgramModel(Value.AURA2PANDORA_EN, "aura-2-pandora-en"); - public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); + public static final DeepgramModel FLUX_PIERRE_FR = new DeepgramModel(Value.FLUX_PIERRE_FR, "flux-pierre-fr"); - public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); + public static final DeepgramModel FLUX_JIGNESH_GU = new DeepgramModel(Value.FLUX_JIGNESH_GU, "flux-jignesh-gu"); - public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); + public static final DeepgramModel FLUX_IZZAH_MS = new DeepgramModel(Value.FLUX_IZZAH_MS, "flux-izzah-ms"); + + public static final DeepgramModel FLUX_USMAN_UR = new DeepgramModel(Value.FLUX_USMAN_UR, "flux-usman-ur"); + + public static final DeepgramModel FLUX_SAYAKA_JA = new DeepgramModel(Value.FLUX_SAYAKA_JA, "flux-sayaka-ja"); public static final DeepgramModel FLUX_GEMMA_EN = new DeepgramModel(Value.FLUX_GEMMA_EN, "flux-gemma-en"); public static final DeepgramModel AURA2ESTRELLA_ES = new DeepgramModel(Value.AURA2ESTRELLA_ES, "aura-2-estrella-es"); + public static final DeepgramModel FLUX_VLADIMIR_RU = new DeepgramModel(Value.FLUX_VLADIMIR_RU, "flux-vladimir-ru"); + private final Value value; private final String string; @@ -252,206 +712,664 @@ public int hashCode() { public T visit(Visitor visitor) { switch (value) { - case AURA2SIRIO_ES: - return visitor.visitAura2SirioEs(); case AURA2HERA_EN: return visitor.visitAura2HeraEn(); - case FLUX_KELSEY_EN: - return visitor.visitFluxKelseyEn(); - case FLUX_RENEE_EN: - return visitor.visitFluxReneeEn(); - case FLUX_SIENNA_EN: - return visitor.visitFluxSiennaEn(); + case FLUX_RITU_HI: + return visitor.visitFluxRituHi(); + case FLUX_TOMAS_ES: + return visitor.visitFluxTomasEs(); + case FLUX_OLGA_RU: + return visitor.visitFluxOlgaRu(); case AURA2HARMONIA_EN: return visitor.visitAura2HarmoniaEn(); case AURA2CARINA_ES: return visitor.visitAura2CarinaEs(); case FLUX_MEENA_EN: return visitor.visitFluxMeenaEn(); - case FLUX_MEGHAN_EN: - return visitor.visitFluxMeghanEn(); + case FLUX_POLINA_RU: + return visitor.visitFluxPolinaRu(); case AURA_ZEUS_EN: return visitor.visitAuraZeusEn(); - case AURA2HERMES_EN: - return visitor.visitAura2HermesEn(); - case FLUX_CONOR_EN: - return visitor.visitFluxConorEn(); + case FLUX_SRAVANI_TE: + return visitor.visitFluxSravaniTe(); + case FLUX_KONRAD_PL: + return visitor.visitFluxKonradPl(); case AURA2NEPTUNE_EN: return visitor.visitAura2NeptuneEn(); case FLUX_BROOKE_EN: return visitor.visitFluxBrookeEn(); + case AURA2CALLISTA_EN: + return visitor.visitAura2CallistaEn(); + case FLUX_JAKUB_CS: + return visitor.visitFluxJakubCs(); + case AURA2OPHELIA_EN: + return visitor.visitAura2OpheliaEn(); + case FLUX_SABBIR_BN: + return visitor.visitFluxSabbirBn(); + case FLUX_BRUCE_EN: + return visitor.visitFluxBruceEn(); + case FLUX_SUMAIYA_BN: + return visitor.visitFluxSumaiyaBn(); + case FLUX_ANJALI_HI: + return visitor.visitFluxAnjaliHi(); + case FLUX_MAURICIO_ES: + return visitor.visitFluxMauricioEs(); + case FLUX_CHRISTIAN_DE: + return visitor.visitFluxChristianDe(); + case FLUX_GERGANA_BG: + return visitor.visitFluxGerganaBg(); + case FLUX_IDA_NO: + return visitor.visitFluxIdaNo(); + case FLUX_JYOTI_HI: + return visitor.visitFluxJyotiHi(); + case FLUX_TRIIN_ET: + return visitor.visitFluxTriinEt(); + case FLUX_MARCUS_EN: + return visitor.visitFluxMarcusEn(); + case FLUX_WENBO_ZH: + return visitor.visitFluxWenboZh(); + case FLUX_SHUFEN_ZH: + return visitor.visitFluxShufenZh(); + case FLUX_PAIGE_EN: + return visitor.visitFluxPaigeEn(); + case FLUX_VINOTH_TA: + return visitor.visitFluxVinothTa(); + case FLUX_DREW_EN: + return visitor.visitFluxDrewEn(); + case FLUX_CHARLOTTA_SV: + return visitor.visitFluxCharlottaSv(); + case AURA2JAVIER_ES: + return visitor.visitAura2JavierEs(); + case FLUX_CHLOE_FR: + return visitor.visitFluxChloeFr(); + case FLUX_FIORELLA_ES: + return visitor.visitFluxFiorellaEs(); + case AURA2SATURN_EN: + return visitor.visitAura2SaturnEn(); + case FLUX_PALLAVI_HI: + return visitor.visitFluxPallaviHi(); + case AURA2IRIS_EN: + return visitor.visitAura2IrisEn(); + case FLUX_AINA_ES: + return visitor.visitFluxAinaEs(); + case FLUX_MAXIM_RU: + return visitor.visitFluxMaximRu(); + case FLUX_ROLF_DE: + return visitor.visitFluxRolfDe(); + case FLUX_VEGARD_NO: + return visitor.visitFluxVegardNo(); + case FLUX_HAZIQ_MS: + return visitor.visitFluxHaziqMs(); + case FLUX_LUUK_NL: + return visitor.visitFluxLuukNl(); + case FLUX_PILAR_ES: + return visitor.visitFluxPilarEs(); + case FLUX_MEHMET_TR: + return visitor.visitFluxMehmetTr(); + case FLUX_RAHUL_HI: + return visitor.visitFluxRahulHi(); + case FLUX_BRITTANY_EN: + return visitor.visitFluxBrittanyEn(); + case FLUX_SEAN_EN: + return visitor.visitFluxSeanEn(); + case FLUX_EUNJI_KO: + return visitor.visitFluxEunjiKo(); + case FLUX_SILJE_NO: + return visitor.visitFluxSiljeNo(); + case FLUX_NOEL_TL: + return visitor.visitFluxNoelTl(); + case AURA2HELENA_EN: + return visitor.visitAura2HelenaEn(); + case FLUX_JULIEN_FR: + return visitor.visitFluxJulienFr(); + case FLUX_AYUMI_JA: + return visitor.visitFluxAyumiJa(); + case FLUX_JACK_EN: + return visitor.visitFluxJackEn(); + case FLUX_PRIYA_EN: + return visitor.visitFluxPriyaEn(); + case AURA_HELIOS_EN: + return visitor.visitAuraHeliosEn(); + case FLUX_KIRSI_FI: + return visitor.visitFluxKirsiFi(); + case FLUX_WILMA_SV: + return visitor.visitFluxWilmaSv(); + case FLUX_LEANDRO_PT: + return visitor.visitFluxLeandroPt(); + case AURA2JANUS_EN: + return visitor.visitAura2JanusEn(); + case AURA2NESTOR_ES: + return visitor.visitAura2NestorEs(); + case FLUX_BRAM_NL: + return visitor.visitFluxBramNl(); + case FLUX_FEDERICO_IT: + return visitor.visitFluxFedericoIt(); + case FLUX_TIBOR_HU: + return visitor.visitFluxTiborHu(); + case FLUX_EDGARS_LV: + return visitor.visitFluxEdgarsLv(); + case FLUX_MANJUNATH_KN: + return visitor.visitFluxManjunathKn(); + case FLUX_ZUZANNA_PL: + return visitor.visitFluxZuzannaPl(); + case AURA2MINERVA_EN: + return visitor.visitAura2MinervaEn(); + case FLUX_PONTUS_SV: + return visitor.visitFluxPontusSv(); + case AURA2ALVARO_ES: + return visitor.visitAura2AlvaroEs(); + case FLUX_AXEL_SV: + return visitor.visitFluxAxelSv(); + case FLUX_COLE_EN: + return visitor.visitFluxColeEn(); + case FLUX_VEDRAN_HR: + return visitor.visitFluxVedranHr(); + case FLUX_DUVAN_ES: + return visitor.visitFluxDuvanEs(); + case FLUX_JIE_ZH: + return visitor.visitFluxJieZh(); + case FLUX_MORITZ_DE: + return visitor.visitFluxMoritzDe(); + case FLUX_JUDIT_CA: + return visitor.visitFluxJuditCa(); + case FLUX_KINGA_HU: + return visitor.visitFluxKingaHu(); + case FLUX_HOA_VI: + return visitor.visitFluxHoaVi(); + case AURA2ASTERIA_EN: + return visitor.visitAura2AsteriaEn(); + case FLUX_ANOUK_NL: + return visitor.visitFluxAnoukNl(); + case FLUX_NIKHIL_HI: + return visitor.visitFluxNikhilHi(); + case FLUX_YSABEL_ES: + return visitor.visitFluxYsabelEs(); + case FLUX_POOJA_MR: + return visitor.visitFluxPoojaMr(); + case FLUX_NERINGA_LT: + return visitor.visitFluxNeringaLt(); + case FLUX_MARCELO_EN: + return visitor.visitFluxMarceloEn(); + case FLUX_MARIANA_PT: + return visitor.visitFluxMarianaPt(); + case FLUX_MIHAELA_HR: + return visitor.visitFluxMihaelaHr(); + case FLUX_KOSTAS_EL: + return visitor.visitFluxKostasEl(); + case FLUX_ISHRAT_BN: + return visitor.visitFluxIshratBn(); + case FLUX_VITO_IT: + return visitor.visitFluxVitoIt(); + case FLUX_DEWI_ID: + return visitor.visitFluxDewiId(); + case FLUX_ELISE_EN: + return visitor.visitFluxEliseEn(); + case FLUX_TEEMU_FI: + return visitor.visitFluxTeemuFi(); + case FLUX_SOWMYA_TA: + return visitor.visitFluxSowmyaTa(); + case FLUX_ALEXIS_EN: + return visitor.visitFluxAlexisEn(); + case FLUX_HAORAN_ZH: + return visitor.visitFluxHaoranZh(); + case AURA2AMALTHEA_EN: + return visitor.visitAura2AmaltheaEn(); + case AURA2SELENE_EN: + return visitor.visitAura2SeleneEn(); + case FLUX_ROBERTO_PT: + return visitor.visitFluxRobertoPt(); + case FLUX_TANNER_EN: + return visitor.visitFluxTannerEn(); + case FLUX_JEROME_TL: + return visitor.visitFluxJeromeTl(); + case FLUX_BENOIT_FR: + return visitor.visitFluxBenoitFr(); + case FLUX_SOFIA_IT: + return visitor.visitFluxSofiaIt(); + case FLUX_WENJING_ZH: + return visitor.visitFluxWenjingZh(); + case FLUX_SERKAN_TR: + return visitor.visitFluxSerkanTr(); + case FLUX_SHARON_EN: + return visitor.visitFluxSharonEn(); + case FLUX_LIEZEL_TL: + return visitor.visitFluxLiezelTl(); + case FLUX_TEGUH_ID: + return visitor.visitFluxTeguhId(); + case FLUX_MARTA_PT: + return visitor.visitFluxMartaPt(); + case FLUX_RIZKY_ID: + return visitor.visitFluxRizkyId(); + case FLUX_RASMUS_DA: + return visitor.visitFluxRasmusDa(); + case AURA2LUNA_EN: + return visitor.visitAura2LunaEn(); + case FLUX_FLORIAN_FR: + return visitor.visitFluxFlorianFr(); + case FLUX_ERLEND_NO: + return visitor.visitFluxErlendNo(); + case FLUX_HANNAH_EN: + return visitor.visitFluxHannahEn(); + case AURA_ORION_EN: + return visitor.visitAuraOrionEn(); + case AURA2ATHENA_EN: + return visitor.visitAura2AthenaEn(); + case AURA_ARCAS_EN: + return visitor.visitAuraArcasEn(); + case FLUX_ECEM_TR: + return visitor.visitFluxEcemTr(); + case FLUX_SANNE_NL: + return visitor.visitFluxSanneNl(); + case FLUX_BIANCA_PT: + return visitor.visitFluxBiancaPt(); + case FLUX_HEATHER_EN: + return visitor.visitFluxHeatherEn(); + case FLUX_SUNITA_HI: + return visitor.visitFluxSunitaHi(); + case FLUX_OSKAR_SV: + return visitor.visitFluxOskarSv(); + case FLUX_FAJAR_ID: + return visitor.visitFluxFajarId(); + case FLUX_VINCENZO_IT: + return visitor.visitFluxVincenzoIt(); + case FLUX_CATARINA_PT: + return visitor.visitFluxCatarinaPt(); + case FLUX_KATJA_SL: + return visitor.visitFluxKatjaSl(); + case FLUX_JASNA_HR: + return visitor.visitFluxJasnaHr(); + case FLUX_BRIGITTE_FR: + return visitor.visitFluxBrigitteFr(); + case FLUX_MATEUS_PT: + return visitor.visitFluxMateusPt(); + case FLUX_GIORGIO_IT: + return visitor.visitFluxGiorgioIt(); + case AURA2CORDELIA_EN: + return visitor.visitAura2CordeliaEn(); + case AURA2ATLAS_EN: + return visitor.visitAura2AtlasEn(); + case FLUX_DIRK_NL: + return visitor.visitFluxDirkNl(); + case FLUX_DILEK_TR: + return visitor.visitFluxDilekTr(); + case AURA2PLUTO_EN: + return visitor.visitAura2PlutoEn(); + case FLUX_BREE_EN: + return visitor.visitFluxBreeEn(); + case FLUX_BHAVNA_GU: + return visitor.visitFluxBhavnaGu(); + case FLUX_AJAY_HI: + return visitor.visitFluxAjayHi(); + case FLUX_BRUNO_PT: + return visitor.visitFluxBrunoPt(); + case FLUX_HUGO_PT: + return visitor.visitFluxHugoPt(); + case FLUX_MILES_EN: + return visitor.visitFluxMilesEn(); + case FLUX_JIAN_ZH: + return visitor.visitFluxJianZh(); + case AURA_ASTERIA_EN: + return visitor.visitAuraAsteriaEn(); + case AURA2ELECTRA_EN: + return visitor.visitAura2ElectraEn(); + case FLUX_IOANA_RO: + return visitor.visitFluxIoanaRo(); + case FLUX_DENYS_UK: + return visitor.visitFluxDenysUk(); + case FLUX_YASMINE_FR: + return visitor.visitFluxYasmineFr(); + case FLUX_NATALIA_RU: + return visitor.visitFluxNataliaRu(); + case FLUX_BARTOSZ_PL: + return visitor.visitFluxBartoszPl(); + case AURA2SIRIO_ES: + return visitor.visitAura2SirioEs(); + case FLUX_KELSEY_EN: + return visitor.visitFluxKelseyEn(); + case FLUX_SIENNA_EN: + return visitor.visitFluxSiennaEn(); + case FLUX_IRENE_NL: + return visitor.visitFluxIreneNl(); + case FLUX_GIZEM_TR: + return visitor.visitFluxGizemTr(); + case FLUX_PERNILLE_DA: + return visitor.visitFluxPernilleDa(); + case FLUX_MEGHAN_EN: + return visitor.visitFluxMeghanEn(); + case FLUX_MATTEO_IT: + return visitor.visitFluxMatteoIt(); + case FLUX_FRIDA_SV: + return visitor.visitFluxFridaSv(); + case AURA2HERMES_EN: + return visitor.visitAura2HermesEn(); + case FLUX_CONOR_EN: + return visitor.visitFluxConorEn(); + case FLUX_MAMUN_BN: + return visitor.visitFluxMamunBn(); + case FLUX_CLAUDIA_PT: + return visitor.visitFluxClaudiaPt(); case FLUX_RUFUS_EN: return visitor.visitFluxRufusEn(); + case FLUX_BO_ZH: + return visitor.visitFluxBoZh(); + case FLUX_HETAL_GU: + return visitor.visitFluxHetalGu(); case FLUX_WES_EN: return visitor.visitFluxWesEn(); - case AURA2CALLISTA_EN: - return visitor.visitAura2CallistaEn(); case AURA2AURORA_EN: return visitor.visitAura2AuroraEn(); - case AURA2OPHELIA_EN: - return visitor.visitAura2OpheliaEn(); - case FLUX_BRUCE_EN: - return visitor.visitFluxBruceEn(); + case FLUX_ZHEN_ZH: + return visitor.visitFluxZhenZh(); + case FLUX_BENEDITA_PT: + return visitor.visitFluxBeneditaPt(); + case FLUX_SHREYA_HI: + return visitor.visitFluxShreyaHi(); + case FLUX_MINH_VI: + return visitor.visitFluxMinhVi(); case AURA2APOLLO_EN: return visitor.visitAura2ApolloEn(); + case FLUX_ZEYNEP_TR: + return visitor.visitFluxZeynepTr(); case AURA2DELIA_EN: return visitor.visitAura2DeliaEn(); case AURA2MARS_EN: return visitor.visitAura2MarsEn(); + case FLUX_CAMILLE_FR: + return visitor.visitFluxCamilleFr(); case AURA_HERA_EN: return visitor.visitAuraHeraEn(); case FLUX_MAEVE_EN: return visitor.visitFluxMaeveEn(); - case FLUX_MARCUS_EN: - return visitor.visitFluxMarcusEn(); + case FLUX_TOBIAS_DE: + return visitor.visitFluxTobiasDe(); + case FLUX_KUANYU_ZH: + return visitor.visitFluxKuanyuZh(); + case FLUX_EWA_PL: + return visitor.visitFluxEwaPl(); + case FLUX_SONJA_DE: + return visitor.visitFluxSonjaDe(); + case FLUX_ANGELA_IT: + return visitor.visitFluxAngelaIt(); case AURA2ARIES_EN: return visitor.visitAura2AriesEn(); - case FLUX_PAIGE_EN: - return visitor.visitFluxPaigeEn(); + case FLUX_BENJAMIN_DE: + return visitor.visitFluxBenjaminDe(); case AURA2JUNO_EN: return visitor.visitAura2JunoEn(); - case FLUX_DREW_EN: - return visitor.visitFluxDrewEn(); - case AURA2JAVIER_ES: - return visitor.visitAura2JavierEs(); + case FLUX_TRISHA_TL: + return visitor.visitFluxTrishaTl(); + case FLUX_RENATO_PT: + return visitor.visitFluxRenatoPt(); + case FLUX_PAVAN_TE: + return visitor.visitFluxPavanTe(); case AURA2ANDROMEDA_EN: return visitor.visitAura2AndromedaEn(); - case AURA2SATURN_EN: - return visitor.visitAura2SaturnEn(); - case AURA2IRIS_EN: - return visitor.visitAura2IrisEn(); + case FLUX_SIGNE_NO: + return visitor.visitFluxSigneNo(); + case FLUX_KACPER_PL: + return visitor.visitFluxKacperPl(); + case FLUX_RAVI_TE: + return visitor.visitFluxRaviTe(); + case FLUX_KAVYA_TA: + return visitor.visitFluxKavyaTa(); + case FLUX_JOMAR_TL: + return visitor.visitFluxJomarTl(); + case FLUX_DIVYA_HI: + return visitor.visitFluxDivyaHi(); case AURA_ANGUS_EN: return visitor.visitAuraAngusEn(); + case FLUX_VEERLE_NL: + return visitor.visitFluxVeerleNl(); case FLUX_KAI_EN: return visitor.visitFluxKaiEn(); - case FLUX_BRITTANY_EN: - return visitor.visitFluxBrittanyEn(); - case FLUX_SEAN_EN: - return visitor.visitFluxSeanEn(); - case AURA2HELENA_EN: - return visitor.visitAura2HelenaEn(); + case FLUX_MARTIN_ES: + return visitor.visitFluxMartinEs(); + case FLUX_DOMINIKA_SK: + return visitor.visitFluxDominikaSk(); case FLUX_HALEY_EN: return visitor.visitFluxHaleyEn(); + case FLUX_ESPEN_NO: + return visitor.visitFluxEspenNo(); case AURA_STELLA_EN: return visitor.visitAuraStellaEn(); - case FLUX_JACK_EN: - return visitor.visitFluxJackEn(); + case FLUX_MIKYUNG_KO: + return visitor.visitFluxMikyungKo(); + case FLUX_PEDRO_PT: + return visitor.visitFluxPedroPt(); + case FLUX_JUSTYNA_PL: + return visitor.visitFluxJustynaPl(); case AURA2DRACO_EN: return visitor.visitAura2DracoEn(); - case FLUX_PRIYA_EN: - return visitor.visitFluxPriyaEn(); - case AURA_HELIOS_EN: - return visitor.visitAuraHeliosEn(); - case AURA2JANUS_EN: - return visitor.visitAura2JanusEn(); - case AURA2NESTOR_ES: - return visitor.visitAura2NestorEs(); + case FLUX_AMBREEN_UR: + return visitor.visitFluxAmbreenUr(); case AURA2ORION_EN: return visitor.visitAura2OrionEn(); - case AURA2MINERVA_EN: - return visitor.visitAura2MinervaEn(); - case AURA2ALVARO_ES: - return visitor.visitAura2AlvaroEs(); + case FLUX_GUSTAVO_ES: + return visitor.visitFluxGustavoEs(); + case FLUX_SNEHA_MR: + return visitor.visitFluxSnehaMr(); + case FLUX_LUDVIG_SV: + return visitor.visitFluxLudvigSv(); + case FLUX_MONIQUE_NL: + return visitor.visitFluxMoniqueNl(); case AURA_PERSEUS_EN: return visitor.visitAuraPerseusEn(); case AURA2VESTA_EN: return visitor.visitAura2VestaEn(); - case FLUX_COLE_EN: - return visitor.visitFluxColeEn(); + case FLUX_ARTUR_PT: + return visitor.visitFluxArturPt(); + case FLUX_FITRI_ID: + return visitor.visitFluxFitriId(); case AURA2ZEUS_EN: return visitor.visitAura2ZeusEn(); + case FLUX_CECILIA_ES: + return visitor.visitFluxCeciliaEs(); + case FLUX_FERNANDA_ES: + return visitor.visitFluxFernandaEs(); case AURA2ORPHEUS_EN: return visitor.visitAura2OrpheusEn(); + case FLUX_PRACHI_HI: + return visitor.visitFluxPrachiHi(); + case FLUX_MANLOK_ZH: + return visitor.visitFluxManlokZh(); + case FLUX_HYUNWOO_KO: + return visitor.visitFluxHyunwooKo(); case AURA2THALIA_EN: return visitor.visitAura2ThaliaEn(); case FLUX_NAVEEN_EN: return visitor.visitFluxNaveenEn(); - case AURA2ASTERIA_EN: - return visitor.visitAura2AsteriaEn(); + case FLUX_STEFANO_IT: + return visitor.visitFluxStefanoIt(); + case FLUX_LOTTE_NL: + return visitor.visitFluxLotteNl(); + case FLUX_LEONIE_DE: + return visitor.visitFluxLeonieDe(); + case FLUX_JANINE_DE: + return visitor.visitFluxJanineDe(); + case FLUX_AGNESE_LV: + return visitor.visitFluxAgneseLv(); + case FLUX_VERENA_DE: + return visitor.visitFluxVerenaDe(); case AURA2SELENA_ES: return visitor.visitAura2SelenaEs(); - case FLUX_MARCELO_EN: - return visitor.visitFluxMarceloEn(); - case FLUX_ELISE_EN: - return visitor.visitFluxEliseEn(); - case FLUX_ALEXIS_EN: - return visitor.visitFluxAlexisEn(); + case FLUX_RICARDO_PT: + return visitor.visitFluxRicardoPt(); + case FLUX_AFSANA_BN: + return visitor.visitFluxAfsanaBn(); + case FLUX_NADINE_DE: + return visitor.visitFluxNadineDe(); + case FLUX_DESISLAVA_BG: + return visitor.visitFluxDesislavaBg(); + case FLUX_MIKHAIL_RU: + return visitor.visitFluxMikhailRu(); + case FLUX_YAWEN_ZH: + return visitor.visitFluxYawenZh(); + case FLUX_VALENTINA_ES: + return visitor.visitFluxValentinaEs(); + case FLUX_YUTING_ZH: + return visitor.visitFluxYutingZh(); + case FLUX_MIGUEL_PT: + return visitor.visitFluxMiguelPt(); + case FLUX_DALIBOR_HR: + return visitor.visitFluxDaliborHr(); case AURA_LUNA_EN: return visitor.visitAuraLunaEn(); case AURA_ORPHEUS_EN: return visitor.visitAuraOrpheusEn(); - case AURA2AMALTHEA_EN: - return visitor.visitAura2AmaltheaEn(); + case FLUX_PATRICIA_ES: + return visitor.visitFluxPatriciaEs(); + case FLUX_RODRIGO_PT: + return visitor.visitFluxRodrigoPt(); + case FLUX_GOKUL_TA: + return visitor.visitFluxGokulTa(); case FLUX_DONOVAN_EN: return visitor.visitFluxDonovanEn(); - case AURA2SELENE_EN: - return visitor.visitAura2SeleneEn(); - case FLUX_TANNER_EN: - return visitor.visitFluxTannerEn(); - case FLUX_SHARON_EN: - return visitor.visitFluxSharonEn(); - case AURA2LUNA_EN: - return visitor.visitAura2LunaEn(); + case FLUX_THIERRY_FR: + return visitor.visitFluxThierryFr(); + case FLUX_PAOLA_IT: + return visitor.visitFluxPaolaIt(); + case FLUX_CHIAYING_ZH: + return visitor.visitFluxChiayingZh(); + case FLUX_MATHIEU_FR: + return visitor.visitFluxMathieuFr(); + case FLUX_ALFREDO_ES: + return visitor.visitFluxAlfredoEs(); + case FLUX_GREGOR_SL: + return visitor.visitFluxGregorSl(); + case FLUX_HAYATO_JA: + return visitor.visitFluxHayatoJa(); + case FLUX_SHUVO_BN: + return visitor.visitFluxShuvoBn(); + case FLUX_NIELS_NL: + return visitor.visitFluxNielsNl(); + case FLUX_ARJUN_HI: + return visitor.visitFluxArjunHi(); + case FLUX_ROCCO_IT: + return visitor.visitFluxRoccoIt(); + case FLUX_CARMEN_ES: + return visitor.visitFluxCarmenEs(); case AURA2PHOEBE_EN: return visitor.visitAura2PhoebeEn(); - case FLUX_HANNAH_EN: - return visitor.visitFluxHannahEn(); + case FLUX_ESZTER_HU: + return visitor.visitFluxEszterHu(); + case FLUX_PRATIK_MR: + return visitor.visitFluxPratikMr(); + case FLUX_FLEUR_NL: + return visitor.visitFluxFleurNl(); + case FLUX_RAFAEL_ES: + return visitor.visitFluxRafaelEs(); case AURA2DIANA_ES: return visitor.visitAura2DianaEs(); - case AURA_ORION_EN: - return visitor.visitAuraOrionEn(); - case AURA2ATHENA_EN: - return visitor.visitAura2AthenaEn(); - case AURA_ARCAS_EN: - return visitor.visitAuraArcasEn(); + case FLUX_CHIARA_IT: + return visitor.visitFluxChiaraIt(); + case FLUX_ANDREI_RU: + return visitor.visitFluxAndreiRu(); + case FLUX_JOSIPA_HR: + return visitor.visitFluxJosipaHr(); case AURA2THEIA_EN: return visitor.visitAura2TheiaEn(); + case FLUX_VERONIQUE_FR: + return visitor.visitFluxVeroniqueFr(); case FLUX_WADE_EN: return visitor.visitFluxWadeEn(); - case FLUX_HEATHER_EN: - return visitor.visitFluxHeatherEn(); + case FLUX_JAIME_ES: + return visitor.visitFluxJaimeEs(); + case FLUX_NOZOMI_JA: + return visitor.visitFluxNozomiJa(); + case FLUX_DOMAGOJ_HR: + return visitor.visitFluxDomagojHr(); + case FLUX_VIKRAM_HI: + return visitor.visitFluxVikramHi(); + case FLUX_SOLOMIYA_UK: + return visitor.visitFluxSolomiyaUk(); + case FLUX_MARCIA_PT: + return visitor.visitFluxMarciaPt(); + case FLUX_RIKKE_DA: + return visitor.visitFluxRikkeDa(); + case FLUX_ARNAUD_FR: + return visitor.visitFluxArnaudFr(); + case FLUX_SVEN_DE: + return visitor.visitFluxSvenDe(); + case FLUX_RAJESH_HI: + return visitor.visitFluxRajeshHi(); case FLUX_CLIFF_EN: return visitor.visitFluxCliffEn(); + case FLUX_YVONNE_NL: + return visitor.visitFluxYvonneNl(); + case FLUX_ERNESTO_ES: + return visitor.visitFluxErnestoEs(); + case FLUX_MAGDALENA_DE: + return visitor.visitFluxMagdalenaDe(); case AURA2JUPITER_EN: return visitor.visitAura2JupiterEn(); + case FLUX_JURAJ_SK: + return visitor.visitFluxJurajSk(); case FLUX_KIT_EN: return visitor.visitFluxKitEn(); + case FLUX_MINJUN_KO: + return visitor.visitFluxMinjunKo(); + case FLUX_KIRILL_RU: + return visitor.visitFluxKirillRu(); case AURA2AQUILA_ES: return visitor.visitAura2AquilaEs(); case AURA2CORA_EN: return visitor.visitAura2CoraEn(); - case AURA2CORDELIA_EN: - return visitor.visitAura2CordeliaEn(); - case AURA2ATLAS_EN: - return visitor.visitAura2AtlasEn(); + case FLUX_DANIJELA_HR: + return visitor.visitFluxDanijelaHr(); + case FLUX_NIKOLAI_RU: + return visitor.visitFluxNikolaiRu(); + case FLUX_LIJUAN_ZH: + return visitor.visitFluxLijuanZh(); + case FLUX_SUNGMIN_KO: + return visitor.visitFluxSungminKo(); + case FLUX_YANNICK_DE: + return visitor.visitFluxYannickDe(); + case FLUX_EDUARDO_ES: + return visitor.visitFluxEduardoEs(); + case FLUX_JORDI_CA: + return visitor.visitFluxJordiCa(); + case FLUX_GODA_LT: + return visitor.visitFluxGodaLt(); + case FLUX_BENCE_HU: + return visitor.visitFluxBenceHu(); + case FLUX_COSMIN_RO: + return visitor.visitFluxCosminRo(); + case FLUX_EMRE_TR: + return visitor.visitFluxEmreTr(); case AURA2HYPERION_EN: return visitor.visitAura2HyperionEn(); case AURA2CELESTE_ES: return visitor.visitAura2CelesteEs(); - case AURA2PLUTO_EN: - return visitor.visitAura2PlutoEn(); - case FLUX_BREE_EN: - return visitor.visitFluxBreeEn(); + case FLUX_RUBEN_NL: + return visitor.visitFluxRubenNl(); case AURA2ARCAS_EN: return visitor.visitAura2ArcasEn(); case FLUX_COLIN_EN: return visitor.visitFluxColinEn(); + case FLUX_SOOJIN_KO: + return visitor.visitFluxSoojinKo(); case AURA_ATHENA_EN: return visitor.visitAuraAthenaEn(); case AURA2ODYSSEUS_EN: return visitor.visitAura2OdysseusEn(); case AURA2PANDORA_EN: return visitor.visitAura2PandoraEn(); - case FLUX_MILES_EN: - return visitor.visitFluxMilesEn(); - case AURA_ASTERIA_EN: - return visitor.visitAuraAsteriaEn(); - case AURA2ELECTRA_EN: - return visitor.visitAura2ElectraEn(); + case FLUX_PIERRE_FR: + return visitor.visitFluxPierreFr(); + case FLUX_JIGNESH_GU: + return visitor.visitFluxJigneshGu(); + case FLUX_IZZAH_MS: + return visitor.visitFluxIzzahMs(); + case FLUX_USMAN_UR: + return visitor.visitFluxUsmanUr(); + case FLUX_SAYAKA_JA: + return visitor.visitFluxSayakaJa(); case FLUX_GEMMA_EN: return visitor.visitFluxGemmaEn(); case AURA2ESTRELLA_ES: return visitor.visitAura2EstrellaEs(); + case FLUX_VLADIMIR_RU: + return visitor.visitFluxVladimirRu(); case UNKNOWN: default: return visitor.visitUnknown(string); @@ -461,206 +1379,664 @@ public T visit(Visitor visitor) { @JsonCreator(mode = JsonCreator.Mode.DELEGATING) public static DeepgramModel valueOf(String value) { switch (value) { - case "aura-2-sirio-es": - return AURA2SIRIO_ES; case "aura-2-hera-en": return AURA2HERA_EN; - case "flux-kelsey-en": - return FLUX_KELSEY_EN; - case "flux-renee-en": - return FLUX_RENEE_EN; - case "flux-sienna-en": - return FLUX_SIENNA_EN; + case "flux-ritu-hi": + return FLUX_RITU_HI; + case "flux-tomas-es": + return FLUX_TOMAS_ES; + case "flux-olga-ru": + return FLUX_OLGA_RU; case "aura-2-harmonia-en": return AURA2HARMONIA_EN; case "aura-2-carina-es": return AURA2CARINA_ES; case "flux-meena-en": return FLUX_MEENA_EN; - case "flux-meghan-en": - return FLUX_MEGHAN_EN; + case "flux-polina-ru": + return FLUX_POLINA_RU; case "aura-zeus-en": return AURA_ZEUS_EN; - case "aura-2-hermes-en": - return AURA2HERMES_EN; - case "flux-conor-en": - return FLUX_CONOR_EN; + case "flux-sravani-te": + return FLUX_SRAVANI_TE; + case "flux-konrad-pl": + return FLUX_KONRAD_PL; case "aura-2-neptune-en": return AURA2NEPTUNE_EN; case "flux-brooke-en": return FLUX_BROOKE_EN; - case "flux-rufus-en": - return FLUX_RUFUS_EN; - case "flux-wes-en": - return FLUX_WES_EN; case "aura-2-callista-en": return AURA2CALLISTA_EN; - case "aura-2-aurora-en": - return AURA2AURORA_EN; + case "flux-jakub-cs": + return FLUX_JAKUB_CS; case "aura-2-ophelia-en": return AURA2OPHELIA_EN; + case "flux-sabbir-bn": + return FLUX_SABBIR_BN; case "flux-bruce-en": return FLUX_BRUCE_EN; - case "aura-2-apollo-en": - return AURA2APOLLO_EN; - case "aura-2-delia-en": - return AURA2DELIA_EN; - case "aura-2-mars-en": - return AURA2MARS_EN; - case "aura-hera-en": - return AURA_HERA_EN; - case "flux-maeve-en": - return FLUX_MAEVE_EN; + case "flux-sumaiya-bn": + return FLUX_SUMAIYA_BN; + case "flux-anjali-hi": + return FLUX_ANJALI_HI; + case "flux-mauricio-es": + return FLUX_MAURICIO_ES; + case "flux-christian-de": + return FLUX_CHRISTIAN_DE; + case "flux-gergana-bg": + return FLUX_GERGANA_BG; + case "flux-ida-no": + return FLUX_IDA_NO; + case "flux-jyoti-hi": + return FLUX_JYOTI_HI; + case "flux-triin-et": + return FLUX_TRIIN_ET; case "flux-marcus-en": return FLUX_MARCUS_EN; - case "aura-2-aries-en": - return AURA2ARIES_EN; + case "flux-wenbo-zh": + return FLUX_WENBO_ZH; + case "flux-shufen-zh": + return FLUX_SHUFEN_ZH; case "flux-paige-en": return FLUX_PAIGE_EN; - case "aura-2-juno-en": - return AURA2JUNO_EN; + case "flux-vinoth-ta": + return FLUX_VINOTH_TA; case "flux-drew-en": return FLUX_DREW_EN; + case "flux-charlotta-sv": + return FLUX_CHARLOTTA_SV; case "aura-2-javier-es": return AURA2JAVIER_ES; - case "aura-2-andromeda-en": - return AURA2ANDROMEDA_EN; + case "flux-chloe-fr": + return FLUX_CHLOE_FR; + case "flux-fiorella-es": + return FLUX_FIORELLA_ES; case "aura-2-saturn-en": return AURA2SATURN_EN; + case "flux-pallavi-hi": + return FLUX_PALLAVI_HI; case "aura-2-iris-en": return AURA2IRIS_EN; - case "aura-angus-en": - return AURA_ANGUS_EN; - case "flux-kai-en": - return FLUX_KAI_EN; + case "flux-aina-es": + return FLUX_AINA_ES; + case "flux-maxim-ru": + return FLUX_MAXIM_RU; + case "flux-rolf-de": + return FLUX_ROLF_DE; + case "flux-vegard-no": + return FLUX_VEGARD_NO; + case "flux-haziq-ms": + return FLUX_HAZIQ_MS; + case "flux-luuk-nl": + return FLUX_LUUK_NL; + case "flux-pilar-es": + return FLUX_PILAR_ES; + case "flux-mehmet-tr": + return FLUX_MEHMET_TR; + case "flux-rahul-hi": + return FLUX_RAHUL_HI; case "flux-brittany-en": return FLUX_BRITTANY_EN; case "flux-sean-en": return FLUX_SEAN_EN; + case "flux-eunji-ko": + return FLUX_EUNJI_KO; + case "flux-silje-no": + return FLUX_SILJE_NO; + case "flux-noel-tl": + return FLUX_NOEL_TL; case "aura-2-helena-en": return AURA2HELENA_EN; - case "flux-haley-en": - return FLUX_HALEY_EN; - case "aura-stella-en": - return AURA_STELLA_EN; + case "flux-julien-fr": + return FLUX_JULIEN_FR; + case "flux-ayumi-ja": + return FLUX_AYUMI_JA; case "flux-jack-en": return FLUX_JACK_EN; - case "aura-2-draco-en": - return AURA2DRACO_EN; case "flux-priya-en": return FLUX_PRIYA_EN; case "aura-helios-en": return AURA_HELIOS_EN; + case "flux-kirsi-fi": + return FLUX_KIRSI_FI; + case "flux-wilma-sv": + return FLUX_WILMA_SV; + case "flux-leandro-pt": + return FLUX_LEANDRO_PT; case "aura-2-janus-en": return AURA2JANUS_EN; case "aura-2-nestor-es": return AURA2NESTOR_ES; - case "aura-2-orion-en": - return AURA2ORION_EN; + case "flux-bram-nl": + return FLUX_BRAM_NL; + case "flux-federico-it": + return FLUX_FEDERICO_IT; + case "flux-tibor-hu": + return FLUX_TIBOR_HU; + case "flux-edgars-lv": + return FLUX_EDGARS_LV; + case "flux-manjunath-kn": + return FLUX_MANJUNATH_KN; + case "flux-zuzanna-pl": + return FLUX_ZUZANNA_PL; case "aura-2-minerva-en": return AURA2MINERVA_EN; + case "flux-pontus-sv": + return FLUX_PONTUS_SV; case "aura-2-alvaro-es": return AURA2ALVARO_ES; - case "aura-perseus-en": - return AURA_PERSEUS_EN; - case "aura-2-vesta-en": - return AURA2VESTA_EN; + case "flux-axel-sv": + return FLUX_AXEL_SV; case "flux-cole-en": return FLUX_COLE_EN; - case "aura-2-zeus-en": - return AURA2ZEUS_EN; - case "aura-2-orpheus-en": - return AURA2ORPHEUS_EN; - case "aura-2-thalia-en": - return AURA2THALIA_EN; - case "flux-naveen-en": - return FLUX_NAVEEN_EN; + case "flux-vedran-hr": + return FLUX_VEDRAN_HR; + case "flux-duvan-es": + return FLUX_DUVAN_ES; + case "flux-jie-zh": + return FLUX_JIE_ZH; + case "flux-moritz-de": + return FLUX_MORITZ_DE; + case "flux-judit-ca": + return FLUX_JUDIT_CA; + case "flux-kinga-hu": + return FLUX_KINGA_HU; + case "flux-hoa-vi": + return FLUX_HOA_VI; case "aura-2-asteria-en": return AURA2ASTERIA_EN; - case "aura-2-selena-es": - return AURA2SELENA_ES; + case "flux-anouk-nl": + return FLUX_ANOUK_NL; + case "flux-nikhil-hi": + return FLUX_NIKHIL_HI; + case "flux-ysabel-es": + return FLUX_YSABEL_ES; + case "flux-pooja-mr": + return FLUX_POOJA_MR; + case "flux-neringa-lt": + return FLUX_NERINGA_LT; case "flux-marcelo-en": return FLUX_MARCELO_EN; + case "flux-mariana-pt": + return FLUX_MARIANA_PT; + case "flux-mihaela-hr": + return FLUX_MIHAELA_HR; + case "flux-kostas-el": + return FLUX_KOSTAS_EL; + case "flux-ishrat-bn": + return FLUX_ISHRAT_BN; + case "flux-vito-it": + return FLUX_VITO_IT; + case "flux-dewi-id": + return FLUX_DEWI_ID; case "flux-elise-en": return FLUX_ELISE_EN; + case "flux-teemu-fi": + return FLUX_TEEMU_FI; + case "flux-sowmya-ta": + return FLUX_SOWMYA_TA; case "flux-alexis-en": return FLUX_ALEXIS_EN; - case "aura-luna-en": - return AURA_LUNA_EN; - case "aura-orpheus-en": - return AURA_ORPHEUS_EN; + case "flux-haoran-zh": + return FLUX_HAORAN_ZH; case "aura-2-amalthea-en": return AURA2AMALTHEA_EN; - case "flux-donovan-en": - return FLUX_DONOVAN_EN; case "aura-2-selene-en": return AURA2SELENE_EN; + case "flux-roberto-pt": + return FLUX_ROBERTO_PT; case "flux-tanner-en": return FLUX_TANNER_EN; + case "flux-jerome-tl": + return FLUX_JEROME_TL; + case "flux-benoit-fr": + return FLUX_BENOIT_FR; + case "flux-sofia-it": + return FLUX_SOFIA_IT; + case "flux-wenjing-zh": + return FLUX_WENJING_ZH; + case "flux-serkan-tr": + return FLUX_SERKAN_TR; case "flux-sharon-en": return FLUX_SHARON_EN; + case "flux-liezel-tl": + return FLUX_LIEZEL_TL; + case "flux-teguh-id": + return FLUX_TEGUH_ID; + case "flux-marta-pt": + return FLUX_MARTA_PT; + case "flux-rizky-id": + return FLUX_RIZKY_ID; + case "flux-rasmus-da": + return FLUX_RASMUS_DA; case "aura-2-luna-en": return AURA2LUNA_EN; - case "aura-2-phoebe-en": - return AURA2PHOEBE_EN; + case "flux-florian-fr": + return FLUX_FLORIAN_FR; + case "flux-erlend-no": + return FLUX_ERLEND_NO; case "flux-hannah-en": return FLUX_HANNAH_EN; - case "aura-2-diana-es": - return AURA2DIANA_ES; case "aura-orion-en": return AURA_ORION_EN; case "aura-2-athena-en": return AURA2ATHENA_EN; case "aura-arcas-en": return AURA_ARCAS_EN; + case "flux-ecem-tr": + return FLUX_ECEM_TR; + case "flux-sanne-nl": + return FLUX_SANNE_NL; + case "flux-bianca-pt": + return FLUX_BIANCA_PT; + case "flux-heather-en": + return FLUX_HEATHER_EN; + case "flux-sunita-hi": + return FLUX_SUNITA_HI; + case "flux-oskar-sv": + return FLUX_OSKAR_SV; + case "flux-fajar-id": + return FLUX_FAJAR_ID; + case "flux-vincenzo-it": + return FLUX_VINCENZO_IT; + case "flux-catarina-pt": + return FLUX_CATARINA_PT; + case "flux-katja-sl": + return FLUX_KATJA_SL; + case "flux-jasna-hr": + return FLUX_JASNA_HR; + case "flux-brigitte-fr": + return FLUX_BRIGITTE_FR; + case "flux-mateus-pt": + return FLUX_MATEUS_PT; + case "flux-giorgio-it": + return FLUX_GIORGIO_IT; + case "aura-2-cordelia-en": + return AURA2CORDELIA_EN; + case "aura-2-atlas-en": + return AURA2ATLAS_EN; + case "flux-dirk-nl": + return FLUX_DIRK_NL; + case "flux-dilek-tr": + return FLUX_DILEK_TR; + case "aura-2-pluto-en": + return AURA2PLUTO_EN; + case "flux-bree-en": + return FLUX_BREE_EN; + case "flux-bhavna-gu": + return FLUX_BHAVNA_GU; + case "flux-ajay-hi": + return FLUX_AJAY_HI; + case "flux-bruno-pt": + return FLUX_BRUNO_PT; + case "flux-hugo-pt": + return FLUX_HUGO_PT; + case "flux-miles-en": + return FLUX_MILES_EN; + case "flux-jian-zh": + return FLUX_JIAN_ZH; + case "aura-asteria-en": + return AURA_ASTERIA_EN; + case "aura-2-electra-en": + return AURA2ELECTRA_EN; + case "flux-ioana-ro": + return FLUX_IOANA_RO; + case "flux-denys-uk": + return FLUX_DENYS_UK; + case "flux-yasmine-fr": + return FLUX_YASMINE_FR; + case "flux-natalia-ru": + return FLUX_NATALIA_RU; + case "flux-bartosz-pl": + return FLUX_BARTOSZ_PL; + case "aura-2-sirio-es": + return AURA2SIRIO_ES; + case "flux-kelsey-en": + return FLUX_KELSEY_EN; + case "flux-sienna-en": + return FLUX_SIENNA_EN; + case "flux-irene-nl": + return FLUX_IRENE_NL; + case "flux-gizem-tr": + return FLUX_GIZEM_TR; + case "flux-pernille-da": + return FLUX_PERNILLE_DA; + case "flux-meghan-en": + return FLUX_MEGHAN_EN; + case "flux-matteo-it": + return FLUX_MATTEO_IT; + case "flux-frida-sv": + return FLUX_FRIDA_SV; + case "aura-2-hermes-en": + return AURA2HERMES_EN; + case "flux-conor-en": + return FLUX_CONOR_EN; + case "flux-mamun-bn": + return FLUX_MAMUN_BN; + case "flux-claudia-pt": + return FLUX_CLAUDIA_PT; + case "flux-rufus-en": + return FLUX_RUFUS_EN; + case "flux-bo-zh": + return FLUX_BO_ZH; + case "flux-hetal-gu": + return FLUX_HETAL_GU; + case "flux-wes-en": + return FLUX_WES_EN; + case "aura-2-aurora-en": + return AURA2AURORA_EN; + case "flux-zhen-zh": + return FLUX_ZHEN_ZH; + case "flux-benedita-pt": + return FLUX_BENEDITA_PT; + case "flux-shreya-hi": + return FLUX_SHREYA_HI; + case "flux-minh-vi": + return FLUX_MINH_VI; + case "aura-2-apollo-en": + return AURA2APOLLO_EN; + case "flux-zeynep-tr": + return FLUX_ZEYNEP_TR; + case "aura-2-delia-en": + return AURA2DELIA_EN; + case "aura-2-mars-en": + return AURA2MARS_EN; + case "flux-camille-fr": + return FLUX_CAMILLE_FR; + case "aura-hera-en": + return AURA_HERA_EN; + case "flux-maeve-en": + return FLUX_MAEVE_EN; + case "flux-tobias-de": + return FLUX_TOBIAS_DE; + case "flux-kuanyu-zh": + return FLUX_KUANYU_ZH; + case "flux-ewa-pl": + return FLUX_EWA_PL; + case "flux-sonja-de": + return FLUX_SONJA_DE; + case "flux-angela-it": + return FLUX_ANGELA_IT; + case "aura-2-aries-en": + return AURA2ARIES_EN; + case "flux-benjamin-de": + return FLUX_BENJAMIN_DE; + case "aura-2-juno-en": + return AURA2JUNO_EN; + case "flux-trisha-tl": + return FLUX_TRISHA_TL; + case "flux-renato-pt": + return FLUX_RENATO_PT; + case "flux-pavan-te": + return FLUX_PAVAN_TE; + case "aura-2-andromeda-en": + return AURA2ANDROMEDA_EN; + case "flux-signe-no": + return FLUX_SIGNE_NO; + case "flux-kacper-pl": + return FLUX_KACPER_PL; + case "flux-ravi-te": + return FLUX_RAVI_TE; + case "flux-kavya-ta": + return FLUX_KAVYA_TA; + case "flux-jomar-tl": + return FLUX_JOMAR_TL; + case "flux-divya-hi": + return FLUX_DIVYA_HI; + case "aura-angus-en": + return AURA_ANGUS_EN; + case "flux-veerle-nl": + return FLUX_VEERLE_NL; + case "flux-kai-en": + return FLUX_KAI_EN; + case "flux-martin-es": + return FLUX_MARTIN_ES; + case "flux-dominika-sk": + return FLUX_DOMINIKA_SK; + case "flux-haley-en": + return FLUX_HALEY_EN; + case "flux-espen-no": + return FLUX_ESPEN_NO; + case "aura-stella-en": + return AURA_STELLA_EN; + case "flux-mikyung-ko": + return FLUX_MIKYUNG_KO; + case "flux-pedro-pt": + return FLUX_PEDRO_PT; + case "flux-justyna-pl": + return FLUX_JUSTYNA_PL; + case "aura-2-draco-en": + return AURA2DRACO_EN; + case "flux-ambreen-ur": + return FLUX_AMBREEN_UR; + case "aura-2-orion-en": + return AURA2ORION_EN; + case "flux-gustavo-es": + return FLUX_GUSTAVO_ES; + case "flux-sneha-mr": + return FLUX_SNEHA_MR; + case "flux-ludvig-sv": + return FLUX_LUDVIG_SV; + case "flux-monique-nl": + return FLUX_MONIQUE_NL; + case "aura-perseus-en": + return AURA_PERSEUS_EN; + case "aura-2-vesta-en": + return AURA2VESTA_EN; + case "flux-artur-pt": + return FLUX_ARTUR_PT; + case "flux-fitri-id": + return FLUX_FITRI_ID; + case "aura-2-zeus-en": + return AURA2ZEUS_EN; + case "flux-cecilia-es": + return FLUX_CECILIA_ES; + case "flux-fernanda-es": + return FLUX_FERNANDA_ES; + case "aura-2-orpheus-en": + return AURA2ORPHEUS_EN; + case "flux-prachi-hi": + return FLUX_PRACHI_HI; + case "flux-manlok-zh": + return FLUX_MANLOK_ZH; + case "flux-hyunwoo-ko": + return FLUX_HYUNWOO_KO; + case "aura-2-thalia-en": + return AURA2THALIA_EN; + case "flux-naveen-en": + return FLUX_NAVEEN_EN; + case "flux-stefano-it": + return FLUX_STEFANO_IT; + case "flux-lotte-nl": + return FLUX_LOTTE_NL; + case "flux-leonie-de": + return FLUX_LEONIE_DE; + case "flux-janine-de": + return FLUX_JANINE_DE; + case "flux-agnese-lv": + return FLUX_AGNESE_LV; + case "flux-verena-de": + return FLUX_VERENA_DE; + case "aura-2-selena-es": + return AURA2SELENA_ES; + case "flux-ricardo-pt": + return FLUX_RICARDO_PT; + case "flux-afsana-bn": + return FLUX_AFSANA_BN; + case "flux-nadine-de": + return FLUX_NADINE_DE; + case "flux-desislava-bg": + return FLUX_DESISLAVA_BG; + case "flux-mikhail-ru": + return FLUX_MIKHAIL_RU; + case "flux-yawen-zh": + return FLUX_YAWEN_ZH; + case "flux-valentina-es": + return FLUX_VALENTINA_ES; + case "flux-yuting-zh": + return FLUX_YUTING_ZH; + case "flux-miguel-pt": + return FLUX_MIGUEL_PT; + case "flux-dalibor-hr": + return FLUX_DALIBOR_HR; + case "aura-luna-en": + return AURA_LUNA_EN; + case "aura-orpheus-en": + return AURA_ORPHEUS_EN; + case "flux-patricia-es": + return FLUX_PATRICIA_ES; + case "flux-rodrigo-pt": + return FLUX_RODRIGO_PT; + case "flux-gokul-ta": + return FLUX_GOKUL_TA; + case "flux-donovan-en": + return FLUX_DONOVAN_EN; + case "flux-thierry-fr": + return FLUX_THIERRY_FR; + case "flux-paola-it": + return FLUX_PAOLA_IT; + case "flux-chiaying-zh": + return FLUX_CHIAYING_ZH; + case "flux-mathieu-fr": + return FLUX_MATHIEU_FR; + case "flux-alfredo-es": + return FLUX_ALFREDO_ES; + case "flux-gregor-sl": + return FLUX_GREGOR_SL; + case "flux-hayato-ja": + return FLUX_HAYATO_JA; + case "flux-shuvo-bn": + return FLUX_SHUVO_BN; + case "flux-niels-nl": + return FLUX_NIELS_NL; + case "flux-arjun-hi": + return FLUX_ARJUN_HI; + case "flux-rocco-it": + return FLUX_ROCCO_IT; + case "flux-carmen-es": + return FLUX_CARMEN_ES; + case "aura-2-phoebe-en": + return AURA2PHOEBE_EN; + case "flux-eszter-hu": + return FLUX_ESZTER_HU; + case "flux-pratik-mr": + return FLUX_PRATIK_MR; + case "flux-fleur-nl": + return FLUX_FLEUR_NL; + case "flux-rafael-es": + return FLUX_RAFAEL_ES; + case "aura-2-diana-es": + return AURA2DIANA_ES; + case "flux-chiara-it": + return FLUX_CHIARA_IT; + case "flux-andrei-ru": + return FLUX_ANDREI_RU; + case "flux-josipa-hr": + return FLUX_JOSIPA_HR; case "aura-2-theia-en": return AURA2THEIA_EN; + case "flux-veronique-fr": + return FLUX_VERONIQUE_FR; case "flux-wade-en": return FLUX_WADE_EN; - case "flux-heather-en": - return FLUX_HEATHER_EN; + case "flux-jaime-es": + return FLUX_JAIME_ES; + case "flux-nozomi-ja": + return FLUX_NOZOMI_JA; + case "flux-domagoj-hr": + return FLUX_DOMAGOJ_HR; + case "flux-vikram-hi": + return FLUX_VIKRAM_HI; + case "flux-solomiya-uk": + return FLUX_SOLOMIYA_UK; + case "flux-marcia-pt": + return FLUX_MARCIA_PT; + case "flux-rikke-da": + return FLUX_RIKKE_DA; + case "flux-arnaud-fr": + return FLUX_ARNAUD_FR; + case "flux-sven-de": + return FLUX_SVEN_DE; + case "flux-rajesh-hi": + return FLUX_RAJESH_HI; case "flux-cliff-en": return FLUX_CLIFF_EN; + case "flux-yvonne-nl": + return FLUX_YVONNE_NL; + case "flux-ernesto-es": + return FLUX_ERNESTO_ES; + case "flux-magdalena-de": + return FLUX_MAGDALENA_DE; case "aura-2-jupiter-en": return AURA2JUPITER_EN; + case "flux-juraj-sk": + return FLUX_JURAJ_SK; case "flux-kit-en": return FLUX_KIT_EN; + case "flux-minjun-ko": + return FLUX_MINJUN_KO; + case "flux-kirill-ru": + return FLUX_KIRILL_RU; case "aura-2-aquila-es": return AURA2AQUILA_ES; case "aura-2-cora-en": return AURA2CORA_EN; - case "aura-2-cordelia-en": - return AURA2CORDELIA_EN; - case "aura-2-atlas-en": - return AURA2ATLAS_EN; + case "flux-danijela-hr": + return FLUX_DANIJELA_HR; + case "flux-nikolai-ru": + return FLUX_NIKOLAI_RU; + case "flux-lijuan-zh": + return FLUX_LIJUAN_ZH; + case "flux-sungmin-ko": + return FLUX_SUNGMIN_KO; + case "flux-yannick-de": + return FLUX_YANNICK_DE; + case "flux-eduardo-es": + return FLUX_EDUARDO_ES; + case "flux-jordi-ca": + return FLUX_JORDI_CA; + case "flux-goda-lt": + return FLUX_GODA_LT; + case "flux-bence-hu": + return FLUX_BENCE_HU; + case "flux-cosmin-ro": + return FLUX_COSMIN_RO; + case "flux-emre-tr": + return FLUX_EMRE_TR; case "aura-2-hyperion-en": return AURA2HYPERION_EN; case "aura-2-celeste-es": return AURA2CELESTE_ES; - case "aura-2-pluto-en": - return AURA2PLUTO_EN; - case "flux-bree-en": - return FLUX_BREE_EN; + case "flux-ruben-nl": + return FLUX_RUBEN_NL; case "aura-2-arcas-en": return AURA2ARCAS_EN; case "flux-colin-en": return FLUX_COLIN_EN; + case "flux-soojin-ko": + return FLUX_SOOJIN_KO; case "aura-athena-en": return AURA_ATHENA_EN; case "aura-2-odysseus-en": return AURA2ODYSSEUS_EN; - case "aura-2-pandora-en": - return AURA2PANDORA_EN; - case "flux-miles-en": - return FLUX_MILES_EN; - case "aura-asteria-en": - return AURA_ASTERIA_EN; - case "aura-2-electra-en": - return AURA2ELECTRA_EN; + case "aura-2-pandora-en": + return AURA2PANDORA_EN; + case "flux-pierre-fr": + return FLUX_PIERRE_FR; + case "flux-jignesh-gu": + return FLUX_JIGNESH_GU; + case "flux-izzah-ms": + return FLUX_IZZAH_MS; + case "flux-usman-ur": + return FLUX_USMAN_UR; + case "flux-sayaka-ja": + return FLUX_SAYAKA_JA; case "flux-gemma-en": return FLUX_GEMMA_EN; case "aura-2-estrella-es": return AURA2ESTRELLA_ES; + case "flux-vladimir-ru": + return FLUX_VLADIMIR_RU; default: return new DeepgramModel(Value.UNKNOWN, value); } @@ -815,57 +2191,515 @@ public enum Value { FLUX_DREW_EN, - FLUX_ELISE_EN, + FLUX_ELISE_EN, + + FLUX_GEMMA_EN, + + FLUX_HALEY_EN, + + FLUX_HANNAH_EN, + + FLUX_HEATHER_EN, + + FLUX_JACK_EN, + + FLUX_KAI_EN, + + FLUX_KELSEY_EN, + + FLUX_KIT_EN, + + FLUX_MAEVE_EN, + + FLUX_MARCELO_EN, + + FLUX_MARCUS_EN, + + FLUX_MEENA_EN, + + FLUX_MEGHAN_EN, + + FLUX_MILES_EN, + + FLUX_NAVEEN_EN, + + FLUX_PAIGE_EN, + + FLUX_PRIYA_EN, + + FLUX_RUFUS_EN, + + FLUX_SEAN_EN, + + FLUX_SHARON_EN, + + FLUX_SIENNA_EN, + + FLUX_TANNER_EN, + + FLUX_WADE_EN, + + FLUX_WES_EN, + + FLUX_ANOUK_NL, + + FLUX_BRAM_NL, + + FLUX_FLEUR_NL, + + FLUX_IRENE_NL, + + FLUX_LUUK_NL, + + FLUX_MONIQUE_NL, + + FLUX_RUBEN_NL, + + FLUX_SANNE_NL, + + FLUX_YVONNE_NL, + + FLUX_DIRK_NL, + + FLUX_LOTTE_NL, + + FLUX_NIELS_NL, + + FLUX_VEERLE_NL, + + FLUX_ARNAUD_FR, + + FLUX_BENOIT_FR, + + FLUX_BRIGITTE_FR, + + FLUX_CAMILLE_FR, + + FLUX_CHLOE_FR, + + FLUX_FLORIAN_FR, + + FLUX_JULIEN_FR, + + FLUX_MATHIEU_FR, + + FLUX_PIERRE_FR, + + FLUX_THIERRY_FR, + + FLUX_VERONIQUE_FR, + + FLUX_YASMINE_FR, + + FLUX_BENJAMIN_DE, + + FLUX_CHRISTIAN_DE, + + FLUX_JANINE_DE, + + FLUX_MAGDALENA_DE, + + FLUX_MORITZ_DE, + + FLUX_NADINE_DE, + + FLUX_ROLF_DE, + + FLUX_SONJA_DE, + + FLUX_SVEN_DE, + + FLUX_TOBIAS_DE, + + FLUX_VERENA_DE, + + FLUX_LEONIE_DE, + + FLUX_YANNICK_DE, + + FLUX_AJAY_HI, + + FLUX_ANJALI_HI, + + FLUX_ARJUN_HI, + + FLUX_DIVYA_HI, + + FLUX_JYOTI_HI, + + FLUX_NIKHIL_HI, + + FLUX_PALLAVI_HI, + + FLUX_PRACHI_HI, + + FLUX_RAHUL_HI, + + FLUX_RAJESH_HI, + + FLUX_RITU_HI, + + FLUX_SHREYA_HI, + + FLUX_SUNITA_HI, + + FLUX_VIKRAM_HI, + + FLUX_ANGELA_IT, + + FLUX_CHIARA_IT, + + FLUX_FEDERICO_IT, + + FLUX_GIORGIO_IT, + + FLUX_MATTEO_IT, + + FLUX_PAOLA_IT, + + FLUX_ROCCO_IT, + + FLUX_SOFIA_IT, + + FLUX_STEFANO_IT, + + FLUX_VINCENZO_IT, + + FLUX_VITO_IT, + + FLUX_AYUMI_JA, + + FLUX_HAYATO_JA, + + FLUX_NOZOMI_JA, + + FLUX_SAYAKA_JA, + + FLUX_BIANCA_PT, + + FLUX_BRUNO_PT, + + FLUX_CLAUDIA_PT, + + FLUX_LEANDRO_PT, + + FLUX_MARCIA_PT, + + FLUX_MARIANA_PT, + + FLUX_MARTA_PT, + + FLUX_MATEUS_PT, + + FLUX_MIGUEL_PT, + + FLUX_RENATO_PT, + + FLUX_ROBERTO_PT, + + FLUX_RODRIGO_PT, + + FLUX_ARTUR_PT, + + FLUX_BENEDITA_PT, + + FLUX_CATARINA_PT, + + FLUX_HUGO_PT, + + FLUX_PEDRO_PT, + + FLUX_RICARDO_PT, + + FLUX_ANDREI_RU, + + FLUX_KIRILL_RU, + + FLUX_MAXIM_RU, + + FLUX_MIKHAIL_RU, + + FLUX_NATALIA_RU, + + FLUX_NIKOLAI_RU, + + FLUX_OLGA_RU, + + FLUX_POLINA_RU, + + FLUX_VLADIMIR_RU, + + FLUX_AINA_ES, + + FLUX_ALFREDO_ES, + + FLUX_CARMEN_ES, + + FLUX_CECILIA_ES, + + FLUX_DUVAN_ES, + + FLUX_EDUARDO_ES, + + FLUX_ERNESTO_ES, + + FLUX_FERNANDA_ES, + + FLUX_FIORELLA_ES, + + FLUX_GUSTAVO_ES, + + FLUX_JAIME_ES, + + FLUX_MARTIN_ES, + + FLUX_MAURICIO_ES, + + FLUX_PATRICIA_ES, + + FLUX_PILAR_ES, + + FLUX_RAFAEL_ES, + + FLUX_TOMAS_ES, + + FLUX_VALENTINA_ES, + + FLUX_YSABEL_ES, + + FLUX_AFSANA_BN, + + FLUX_ISHRAT_BN, + + FLUX_MAMUN_BN, + + FLUX_SABBIR_BN, + + FLUX_SHUVO_BN, + + FLUX_SUMAIYA_BN, + + FLUX_DESISLAVA_BG, + + FLUX_GERGANA_BG, + + FLUX_JORDI_CA, + + FLUX_JUDIT_CA, + + FLUX_BO_ZH, + + FLUX_HAORAN_ZH, + + FLUX_JIAN_ZH, + + FLUX_JIE_ZH, + + FLUX_LIJUAN_ZH, + + FLUX_SHUFEN_ZH, + + FLUX_WENBO_ZH, + + FLUX_WENJING_ZH, + + FLUX_ZHEN_ZH, + + FLUX_CHIAYING_ZH, + + FLUX_KUANYU_ZH, + + FLUX_YAWEN_ZH, + + FLUX_YUTING_ZH, + + FLUX_MANLOK_ZH, + + FLUX_DALIBOR_HR, + + FLUX_DANIJELA_HR, + + FLUX_DOMAGOJ_HR, + + FLUX_JASNA_HR, + + FLUX_JOSIPA_HR, + + FLUX_MIHAELA_HR, + + FLUX_VEDRAN_HR, + + FLUX_JAKUB_CS, + + FLUX_PERNILLE_DA, + + FLUX_RASMUS_DA, + + FLUX_RIKKE_DA, + + FLUX_TRIIN_ET, + + FLUX_KIRSI_FI, + + FLUX_TEEMU_FI, + + FLUX_KOSTAS_EL, + + FLUX_BHAVNA_GU, + + FLUX_HETAL_GU, + + FLUX_JIGNESH_GU, + + FLUX_BENCE_HU, + + FLUX_ESZTER_HU, + + FLUX_KINGA_HU, + + FLUX_TIBOR_HU, + + FLUX_DEWI_ID, + + FLUX_FAJAR_ID, + + FLUX_FITRI_ID, + + FLUX_RIZKY_ID, + + FLUX_TEGUH_ID, + + FLUX_MANJUNATH_KN, + + FLUX_EUNJI_KO, + + FLUX_HYUNWOO_KO, + + FLUX_MIKYUNG_KO, + + FLUX_MINJUN_KO, + + FLUX_SOOJIN_KO, + + FLUX_SUNGMIN_KO, + + FLUX_AGNESE_LV, + + FLUX_EDGARS_LV, + + FLUX_GODA_LT, + + FLUX_NERINGA_LT, + + FLUX_HAZIQ_MS, + + FLUX_IZZAH_MS, + + FLUX_POOJA_MR, + + FLUX_PRATIK_MR, + + FLUX_SNEHA_MR, + + FLUX_ERLEND_NO, + + FLUX_ESPEN_NO, + + FLUX_IDA_NO, + + FLUX_SIGNE_NO, + + FLUX_SILJE_NO, + + FLUX_VEGARD_NO, + + FLUX_BARTOSZ_PL, + + FLUX_EWA_PL, + + FLUX_JUSTYNA_PL, + + FLUX_KACPER_PL, + + FLUX_KONRAD_PL, + + FLUX_ZUZANNA_PL, + + FLUX_COSMIN_RO, + + FLUX_IOANA_RO, + + FLUX_DOMINIKA_SK, + + FLUX_JURAJ_SK, + + FLUX_GREGOR_SL, + + FLUX_KATJA_SL, + + FLUX_AXEL_SV, + + FLUX_CHARLOTTA_SV, + + FLUX_FRIDA_SV, + + FLUX_LUDVIG_SV, + + FLUX_OSKAR_SV, + + FLUX_PONTUS_SV, + + FLUX_WILMA_SV, - FLUX_GEMMA_EN, + FLUX_JEROME_TL, - FLUX_HALEY_EN, + FLUX_JOMAR_TL, - FLUX_HANNAH_EN, + FLUX_LIEZEL_TL, - FLUX_HEATHER_EN, + FLUX_NOEL_TL, - FLUX_JACK_EN, + FLUX_TRISHA_TL, - FLUX_KAI_EN, + FLUX_GOKUL_TA, - FLUX_KELSEY_EN, + FLUX_KAVYA_TA, - FLUX_RENEE_EN, + FLUX_SOWMYA_TA, - FLUX_KIT_EN, + FLUX_VINOTH_TA, - FLUX_MAEVE_EN, + FLUX_PAVAN_TE, - FLUX_MARCELO_EN, + FLUX_RAVI_TE, - FLUX_MARCUS_EN, + FLUX_SRAVANI_TE, - FLUX_MEENA_EN, + FLUX_DILEK_TR, - FLUX_MEGHAN_EN, + FLUX_ECEM_TR, - FLUX_MILES_EN, + FLUX_EMRE_TR, - FLUX_NAVEEN_EN, + FLUX_GIZEM_TR, - FLUX_PAIGE_EN, + FLUX_MEHMET_TR, - FLUX_PRIYA_EN, + FLUX_SERKAN_TR, - FLUX_RUFUS_EN, + FLUX_ZEYNEP_TR, - FLUX_SEAN_EN, + FLUX_DENYS_UK, - FLUX_SHARON_EN, + FLUX_SOLOMIYA_UK, - FLUX_SIENNA_EN, + FLUX_AMBREEN_UR, - FLUX_TANNER_EN, + FLUX_USMAN_UR, - FLUX_WADE_EN, + FLUX_HOA_VI, - FLUX_WES_EN, + FLUX_MINH_VI, UNKNOWN } @@ -1035,13 +2869,6 @@ public interface Visitor { T visitFluxKelseyEn(); - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - T visitFluxReneeEn(); - T visitFluxKitEn(); T visitFluxMaeveEn(); @@ -1076,6 +2903,466 @@ public interface Visitor { T visitFluxWesEn(); + T visitFluxAnoukNl(); + + T visitFluxBramNl(); + + T visitFluxFleurNl(); + + T visitFluxIreneNl(); + + T visitFluxLuukNl(); + + T visitFluxMoniqueNl(); + + T visitFluxRubenNl(); + + T visitFluxSanneNl(); + + T visitFluxYvonneNl(); + + T visitFluxDirkNl(); + + T visitFluxLotteNl(); + + T visitFluxNielsNl(); + + T visitFluxVeerleNl(); + + T visitFluxArnaudFr(); + + T visitFluxBenoitFr(); + + T visitFluxBrigitteFr(); + + T visitFluxCamilleFr(); + + T visitFluxChloeFr(); + + T visitFluxFlorianFr(); + + T visitFluxJulienFr(); + + T visitFluxMathieuFr(); + + T visitFluxPierreFr(); + + T visitFluxThierryFr(); + + T visitFluxVeroniqueFr(); + + T visitFluxYasmineFr(); + + T visitFluxBenjaminDe(); + + T visitFluxChristianDe(); + + T visitFluxJanineDe(); + + T visitFluxMagdalenaDe(); + + T visitFluxMoritzDe(); + + T visitFluxNadineDe(); + + T visitFluxRolfDe(); + + T visitFluxSonjaDe(); + + T visitFluxSvenDe(); + + T visitFluxTobiasDe(); + + T visitFluxVerenaDe(); + + T visitFluxLeonieDe(); + + T visitFluxYannickDe(); + + T visitFluxAjayHi(); + + T visitFluxAnjaliHi(); + + T visitFluxArjunHi(); + + T visitFluxDivyaHi(); + + T visitFluxJyotiHi(); + + T visitFluxNikhilHi(); + + T visitFluxPallaviHi(); + + T visitFluxPrachiHi(); + + T visitFluxRahulHi(); + + T visitFluxRajeshHi(); + + T visitFluxRituHi(); + + T visitFluxShreyaHi(); + + T visitFluxSunitaHi(); + + T visitFluxVikramHi(); + + T visitFluxAngelaIt(); + + T visitFluxChiaraIt(); + + T visitFluxFedericoIt(); + + T visitFluxGiorgioIt(); + + T visitFluxMatteoIt(); + + T visitFluxPaolaIt(); + + T visitFluxRoccoIt(); + + T visitFluxSofiaIt(); + + T visitFluxStefanoIt(); + + T visitFluxVincenzoIt(); + + T visitFluxVitoIt(); + + T visitFluxAyumiJa(); + + T visitFluxHayatoJa(); + + T visitFluxNozomiJa(); + + T visitFluxSayakaJa(); + + T visitFluxBiancaPt(); + + T visitFluxBrunoPt(); + + T visitFluxClaudiaPt(); + + T visitFluxLeandroPt(); + + T visitFluxMarciaPt(); + + T visitFluxMarianaPt(); + + T visitFluxMartaPt(); + + T visitFluxMateusPt(); + + T visitFluxMiguelPt(); + + T visitFluxRenatoPt(); + + T visitFluxRobertoPt(); + + T visitFluxRodrigoPt(); + + T visitFluxArturPt(); + + T visitFluxBeneditaPt(); + + T visitFluxCatarinaPt(); + + T visitFluxHugoPt(); + + T visitFluxPedroPt(); + + T visitFluxRicardoPt(); + + T visitFluxAndreiRu(); + + T visitFluxKirillRu(); + + T visitFluxMaximRu(); + + T visitFluxMikhailRu(); + + T visitFluxNataliaRu(); + + T visitFluxNikolaiRu(); + + T visitFluxOlgaRu(); + + T visitFluxPolinaRu(); + + T visitFluxVladimirRu(); + + T visitFluxAinaEs(); + + T visitFluxAlfredoEs(); + + T visitFluxCarmenEs(); + + T visitFluxCeciliaEs(); + + T visitFluxDuvanEs(); + + T visitFluxEduardoEs(); + + T visitFluxErnestoEs(); + + T visitFluxFernandaEs(); + + T visitFluxFiorellaEs(); + + T visitFluxGustavoEs(); + + T visitFluxJaimeEs(); + + T visitFluxMartinEs(); + + T visitFluxMauricioEs(); + + T visitFluxPatriciaEs(); + + T visitFluxPilarEs(); + + T visitFluxRafaelEs(); + + T visitFluxTomasEs(); + + T visitFluxValentinaEs(); + + T visitFluxYsabelEs(); + + T visitFluxAfsanaBn(); + + T visitFluxIshratBn(); + + T visitFluxMamunBn(); + + T visitFluxSabbirBn(); + + T visitFluxShuvoBn(); + + T visitFluxSumaiyaBn(); + + T visitFluxDesislavaBg(); + + T visitFluxGerganaBg(); + + T visitFluxJordiCa(); + + T visitFluxJuditCa(); + + T visitFluxBoZh(); + + T visitFluxHaoranZh(); + + T visitFluxJianZh(); + + T visitFluxJieZh(); + + T visitFluxLijuanZh(); + + T visitFluxShufenZh(); + + T visitFluxWenboZh(); + + T visitFluxWenjingZh(); + + T visitFluxZhenZh(); + + T visitFluxChiayingZh(); + + T visitFluxKuanyuZh(); + + T visitFluxYawenZh(); + + T visitFluxYutingZh(); + + T visitFluxManlokZh(); + + T visitFluxDaliborHr(); + + T visitFluxDanijelaHr(); + + T visitFluxDomagojHr(); + + T visitFluxJasnaHr(); + + T visitFluxJosipaHr(); + + T visitFluxMihaelaHr(); + + T visitFluxVedranHr(); + + T visitFluxJakubCs(); + + T visitFluxPernilleDa(); + + T visitFluxRasmusDa(); + + T visitFluxRikkeDa(); + + T visitFluxTriinEt(); + + T visitFluxKirsiFi(); + + T visitFluxTeemuFi(); + + T visitFluxKostasEl(); + + T visitFluxBhavnaGu(); + + T visitFluxHetalGu(); + + T visitFluxJigneshGu(); + + T visitFluxBenceHu(); + + T visitFluxEszterHu(); + + T visitFluxKingaHu(); + + T visitFluxTiborHu(); + + T visitFluxDewiId(); + + T visitFluxFajarId(); + + T visitFluxFitriId(); + + T visitFluxRizkyId(); + + T visitFluxTeguhId(); + + T visitFluxManjunathKn(); + + T visitFluxEunjiKo(); + + T visitFluxHyunwooKo(); + + T visitFluxMikyungKo(); + + T visitFluxMinjunKo(); + + T visitFluxSoojinKo(); + + T visitFluxSungminKo(); + + T visitFluxAgneseLv(); + + T visitFluxEdgarsLv(); + + T visitFluxGodaLt(); + + T visitFluxNeringaLt(); + + T visitFluxHaziqMs(); + + T visitFluxIzzahMs(); + + T visitFluxPoojaMr(); + + T visitFluxPratikMr(); + + T visitFluxSnehaMr(); + + T visitFluxErlendNo(); + + T visitFluxEspenNo(); + + T visitFluxIdaNo(); + + T visitFluxSigneNo(); + + T visitFluxSiljeNo(); + + T visitFluxVegardNo(); + + T visitFluxBartoszPl(); + + T visitFluxEwaPl(); + + T visitFluxJustynaPl(); + + T visitFluxKacperPl(); + + T visitFluxKonradPl(); + + T visitFluxZuzannaPl(); + + T visitFluxCosminRo(); + + T visitFluxIoanaRo(); + + T visitFluxDominikaSk(); + + T visitFluxJurajSk(); + + T visitFluxGregorSl(); + + T visitFluxKatjaSl(); + + T visitFluxAxelSv(); + + T visitFluxCharlottaSv(); + + T visitFluxFridaSv(); + + T visitFluxLudvigSv(); + + T visitFluxOskarSv(); + + T visitFluxPontusSv(); + + T visitFluxWilmaSv(); + + T visitFluxJeromeTl(); + + T visitFluxJomarTl(); + + T visitFluxLiezelTl(); + + T visitFluxNoelTl(); + + T visitFluxTrishaTl(); + + T visitFluxGokulTa(); + + T visitFluxKavyaTa(); + + T visitFluxSowmyaTa(); + + T visitFluxVinothTa(); + + T visitFluxPavanTe(); + + T visitFluxRaviTe(); + + T visitFluxSravaniTe(); + + T visitFluxDilekTr(); + + T visitFluxEcemTr(); + + T visitFluxEmreTr(); + + T visitFluxGizemTr(); + + T visitFluxMehmetTr(); + + T visitFluxSerkanTr(); + + T visitFluxZeynepTr(); + + T visitFluxDenysUk(); + + T visitFluxSolomiyaUk(); + + T visitFluxAmbreenUr(); + + T visitFluxUsmanUr(); + + T visitFluxHoaVi(); + + T visitFluxMinhVi(); + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java index 41c0977..787b4ef 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProvider.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProvider.java @@ -21,10 +21,10 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = DeepgramThinkProvider.Builder.class) public final class DeepgramThinkProvider { - private final Optional version; - private final DeepgramThinkProviderModel model; + private final Optional version; + private final Optional temperature; private final Optional reasoningMode; @@ -34,45 +34,63 @@ public final class DeepgramThinkProvider { private final Map additionalProperties; private DeepgramThinkProvider( - Optional version, DeepgramThinkProviderModel model, + Optional version, Optional temperature, Optional reasoningMode, Optional voicePromptOptOut, Map additionalProperties) { - this.version = version; this.model = model; + this.version = version; this.temperature = temperature; this.reasoningMode = reasoningMode; this.voicePromptOptOut = voicePromptOptOut; this.additionalProperties = additionalProperties; } + /** + * @return Provider type for Deepgram-hosted language models. Must be deepgram. + */ @JsonProperty("type") public String getType() { return "deepgram"; } - @JsonProperty("version") - public Optional getVersion() { - return version; - } - + /** + * @return Deepgram language model to use. Early Access. think-fast requires the Model Improvement Program: a session with mip_opt_out set to true is rejected with INVALID_SETTINGS. Use phonellm-mini-alpha-2-fp8 for sessions that opt out. + */ @JsonProperty("model") public DeepgramThinkProviderModel getModel() { return model; } + /** + * @return API version for the Deepgram think provider. Defaults to v1. + */ + @JsonProperty("version") + public Optional getVersion() { + return version; + } + + /** + * @return Deepgram temperature (0-2). + */ @JsonProperty("temperature") public Optional getTemperature() { return temperature; } + /** + * @return Reasoning effort. For phonellm-mini-alpha-2-fp8, use none or omit it; other values put reasoning text in the reply, which the agent speaks. + */ @JsonProperty("reasoning_mode") public Optional getReasoningMode() { return reasoningMode; } + /** + * @return With think-fast, Deepgram places spoken-style instructions ahead of your prompt and sends a VOICE_PROMPT_ADDED warning. Set to true to send your prompt unchanged. + */ @JsonProperty("voice_prompt_opt_out") public Optional getVoicePromptOptOut() { return voicePromptOptOut; @@ -90,8 +108,8 @@ public Map getAdditionalProperties() { } private boolean equalTo(DeepgramThinkProvider other) { - return version.equals(other.version) - && model.equals(other.model) + return model.equals(other.model) + && version.equals(other.version) && temperature.equals(other.temperature) && reasoningMode.equals(other.reasoningMode) && voicePromptOptOut.equals(other.voicePromptOptOut); @@ -99,7 +117,7 @@ private boolean equalTo(DeepgramThinkProvider other) { @java.lang.Override public int hashCode() { - return Objects.hash(this.version, this.model, this.temperature, this.reasoningMode, this.voicePromptOptOut); + return Objects.hash(this.model, this.version, this.temperature, this.reasoningMode, this.voicePromptOptOut); } @java.lang.Override @@ -112,6 +130,9 @@ public static ModelStage builder() { } public interface ModelStage { + /** + *

Deepgram language model to use. Early Access. think-fast requires the Model Improvement Program: a session with mip_opt_out set to true is rejected with INVALID_SETTINGS. Use phonellm-mini-alpha-2-fp8 for sessions that opt out.

+ */ _FinalStage model(@NotNull DeepgramThinkProviderModel model); Builder from(DeepgramThinkProvider other); @@ -124,18 +145,30 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + /** + *

API version for the Deepgram think provider. Defaults to v1.

+ */ _FinalStage version(Optional version); _FinalStage version(String version); + /** + *

Deepgram temperature (0-2).

+ */ _FinalStage temperature(Optional temperature); _FinalStage temperature(Double temperature); + /** + *

Reasoning effort. For phonellm-mini-alpha-2-fp8, use none or omit it; other values put reasoning text in the reply, which the agent speaks.

+ */ _FinalStage reasoningMode(Optional reasoningMode); _FinalStage reasoningMode(DeepgramThinkProviderReasoningMode reasoningMode); + /** + *

With think-fast, Deepgram places spoken-style instructions ahead of your prompt and sends a VOICE_PROMPT_ADDED warning. Set to true to send your prompt unchanged.

+ */ _FinalStage voicePromptOptOut(Optional voicePromptOptOut); _FinalStage voicePromptOptOut(Boolean voicePromptOptOut); @@ -160,14 +193,18 @@ private Builder() {} @java.lang.Override public Builder from(DeepgramThinkProvider other) { - version(other.getVersion()); model(other.getModel()); + version(other.getVersion()); temperature(other.getTemperature()); reasoningMode(other.getReasoningMode()); voicePromptOptOut(other.getVoicePromptOptOut()); return this; } + /** + *

Deepgram language model to use. Early Access. think-fast requires the Model Improvement Program: a session with mip_opt_out set to true is rejected with INVALID_SETTINGS. Use phonellm-mini-alpha-2-fp8 for sessions that opt out.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override @JsonSetter("model") public _FinalStage model(@NotNull DeepgramThinkProviderModel model) { @@ -175,12 +212,19 @@ public _FinalStage model(@NotNull DeepgramThinkProviderModel model) { return this; } + /** + *

With think-fast, Deepgram places spoken-style instructions ahead of your prompt and sends a VOICE_PROMPT_ADDED warning. Set to true to send your prompt unchanged.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override public _FinalStage voicePromptOptOut(Boolean voicePromptOptOut) { this.voicePromptOptOut = Optional.ofNullable(voicePromptOptOut); return this; } + /** + *

With think-fast, Deepgram places spoken-style instructions ahead of your prompt and sends a VOICE_PROMPT_ADDED warning. Set to true to send your prompt unchanged.

+ */ @java.lang.Override @JsonSetter(value = "voice_prompt_opt_out", nulls = Nulls.SKIP) public _FinalStage voicePromptOptOut(Optional voicePromptOptOut) { @@ -188,12 +232,19 @@ public _FinalStage voicePromptOptOut(Optional voicePromptOptOut) { return this; } + /** + *

Reasoning effort. For phonellm-mini-alpha-2-fp8, use none or omit it; other values put reasoning text in the reply, which the agent speaks.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override public _FinalStage reasoningMode(DeepgramThinkProviderReasoningMode reasoningMode) { this.reasoningMode = Optional.ofNullable(reasoningMode); return this; } + /** + *

Reasoning effort. For phonellm-mini-alpha-2-fp8, use none or omit it; other values put reasoning text in the reply, which the agent speaks.

+ */ @java.lang.Override @JsonSetter(value = "reasoning_mode", nulls = Nulls.SKIP) public _FinalStage reasoningMode(Optional reasoningMode) { @@ -201,12 +252,19 @@ public _FinalStage reasoningMode(Optional re return this; } + /** + *

Deepgram temperature (0-2).

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override public _FinalStage temperature(Double temperature) { this.temperature = Optional.ofNullable(temperature); return this; } + /** + *

Deepgram temperature (0-2).

+ */ @java.lang.Override @JsonSetter(value = "temperature", nulls = Nulls.SKIP) public _FinalStage temperature(Optional temperature) { @@ -214,12 +272,19 @@ public _FinalStage temperature(Optional temperature) { return this; } + /** + *

API version for the Deepgram think provider. Defaults to v1.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ @java.lang.Override public _FinalStage version(String version) { this.version = Optional.ofNullable(version); return this; } + /** + *

API version for the Deepgram think provider. Defaults to v1.

+ */ @java.lang.Override @JsonSetter(value = "version", nulls = Nulls.SKIP) public _FinalStage version(Optional version) { @@ -230,7 +295,7 @@ public _FinalStage version(Optional version) { @java.lang.Override public DeepgramThinkProvider build() { return new DeepgramThinkProvider( - version, model, temperature, reasoningMode, voicePromptOptOut, additionalProperties); + model, version, temperature, reasoningMode, voicePromptOptOut, additionalProperties); } @java.lang.Override diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java index f9f00eb..6591875 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java @@ -10,8 +10,8 @@ public final class DeepgramThinkProviderModel { public static final DeepgramThinkProviderModel THINK_FAST = new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); - public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA_2_FP8 = - new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); + public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA2FP8 = + new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA2FP8, "phonellm-mini-alpha-2-fp8"); private final Value value; @@ -48,7 +48,7 @@ public T visit(Visitor visitor) { switch (value) { case THINK_FAST: return visitor.visitThinkFast(); - case PHONELLM_MINI_ALPHA_2_FP8: + case PHONELLM_MINI_ALPHA2FP8: return visitor.visitPhonellmMiniAlpha2Fp8(); case UNKNOWN: default: @@ -62,7 +62,7 @@ public static DeepgramThinkProviderModel valueOf(String value) { case "think-fast": return THINK_FAST; case "phonellm-mini-alpha-2-fp8": - return PHONELLM_MINI_ALPHA_2_FP8; + return PHONELLM_MINI_ALPHA2FP8; default: return new DeepgramThinkProviderModel(Value.UNKNOWN, value); } @@ -71,7 +71,7 @@ public static DeepgramThinkProviderModel valueOf(String value) { public enum Value { THINK_FAST, - PHONELLM_MINI_ALPHA_2_FP8, + PHONELLM_MINI_ALPHA2FP8, UNKNOWN } diff --git a/src/main/java/com/deepgram/types/ListenV1RedactUsage.java b/src/main/java/com/deepgram/types/ListenV1RedactUsage.java new file mode 100644 index 0000000..5fd1d67 --- /dev/null +++ b/src/main/java/com/deepgram/types/ListenV1RedactUsage.java @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListenV1RedactUsage { + public static final ListenV1RedactUsage FALSE = new ListenV1RedactUsage(Value.FALSE, "false"); + + public static final ListenV1RedactUsage TRUE = new ListenV1RedactUsage(Value.TRUE, "true"); + + private final Value value; + + private final String string; + + ListenV1RedactUsage(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListenV1RedactUsage && this.string.equals(((ListenV1RedactUsage) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FALSE: + return visitor.visitFalse(); + case TRUE: + return visitor.visitTrue(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListenV1RedactUsage valueOf(String value) { + switch (value) { + case "false": + return FALSE; + case "true": + return TRUE; + default: + return new ListenV1RedactUsage(Value.UNKNOWN, value); + } + } + + public enum Value { + TRUE, + + FALSE, + + UNKNOWN + } + + public interface Visitor { + T visitTrue(); + + T visitFalse(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/ListenV2RedactUsage.java b/src/main/java/com/deepgram/types/ListenV2RedactUsage.java new file mode 100644 index 0000000..b93ed9d --- /dev/null +++ b/src/main/java/com/deepgram/types/ListenV2RedactUsage.java @@ -0,0 +1,83 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class ListenV2RedactUsage { + public static final ListenV2RedactUsage FALSE = new ListenV2RedactUsage(Value.FALSE, "false"); + + public static final ListenV2RedactUsage TRUE = new ListenV2RedactUsage(Value.TRUE, "true"); + + private final Value value; + + private final String string; + + ListenV2RedactUsage(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ListenV2RedactUsage && this.string.equals(((ListenV2RedactUsage) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FALSE: + return visitor.visitFalse(); + case TRUE: + return visitor.visitTrue(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ListenV2RedactUsage valueOf(String value) { + switch (value) { + case "false": + return FALSE; + case "true": + return TRUE; + default: + return new ListenV2RedactUsage(Value.UNKNOWN, value); + } + } + + public enum Value { + TRUE, + + FALSE, + + UNKNOWN + } + + public interface Visitor { + T visitTrue(); + + T visitFalse(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/SpeakV2NormalizeVolume.java b/src/main/java/com/deepgram/types/SpeakV2NormalizeVolume.java new file mode 100644 index 0000000..87309df --- /dev/null +++ b/src/main/java/com/deepgram/types/SpeakV2NormalizeVolume.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.deepgram.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public final class SpeakV2NormalizeVolume { + public static final SpeakV2NormalizeVolume FALSE = new SpeakV2NormalizeVolume(Value.FALSE, "false"); + + public static final SpeakV2NormalizeVolume TRUE = new SpeakV2NormalizeVolume(Value.TRUE, "true"); + + private final Value value; + + private final String string; + + SpeakV2NormalizeVolume(Value value, String string) { + this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; + } + + @java.lang.Override + @JsonValue + public String toString() { + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof SpeakV2NormalizeVolume + && this.string.equals(((SpeakV2NormalizeVolume) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case FALSE: + return visitor.visitFalse(); + case TRUE: + return visitor.visitTrue(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SpeakV2NormalizeVolume valueOf(String value) { + switch (value) { + case "false": + return FALSE; + case "true": + return TRUE; + default: + return new SpeakV2NormalizeVolume(Value.UNKNOWN, value); + } + } + + public enum Value { + TRUE, + + FALSE, + + UNKNOWN + } + + public interface Visitor { + T visitTrue(); + + T visitFalse(); + + T visitUnknown(String unknownType); + } +} diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java index d093a02..44acbff 100644 --- a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java +++ b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java @@ -159,9 +159,7 @@ public interface Visitor { T visitGroq(Groq groq); - default T visitDeepgram(DeepgramThinkProvider deepgram) { - return _visitUnknown(deepgram); - } + T visitDeepgram(DeepgramThinkProvider deepgram); T _visitUnknown(Object unknownType); } From 819d64391103005e9b17120d2c3a934163cdd17b Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 12 Nov 2026 12:21:37 +0000 Subject: [PATCH 4/8] chore: re-apply manual patches after regen --- .fernignore | 65 +- AGENTS.md | 1 + .../java/com/deepgram/core/ClientOptions.java | 17 +- .../com/deepgram/core/ClientOptions.java.bak | 409 ---- .../core/ReconnectingWebSocketListener.java | 61 +- .../ReconnectingWebSocketListener.java.bak | 622 ------ .../agent/v1/types/AgentV1AgentAudioDone.java | 5 + .../v1/types/AgentV1AgentAudioDone.java.bak | 83 - .../v1/types/AgentV1ConversationText.java | 30 +- .../v1/types/AgentV1ConversationText.java.bak | 317 --- .../agent/v1/types/AgentV1ForceEndTurn.java | 5 + .../v1/types/AgentV1ForceEndTurn.java.bak | 83 - .../agent/v1/types/AgentV1KeepAlive.java | 5 + .../agent/v1/types/AgentV1KeepAlive.java.bak | 83 - .../agent/v1/types/AgentV1ListenUpdated.java | 5 + .../v1/types/AgentV1ListenUpdated.java.bak | 83 - .../agent/v1/types/AgentV1PromptUpdated.java | 5 + .../v1/types/AgentV1PromptUpdated.java.bak | 83 - ...tV1SettingsAgentContextListenProvider.java | 2 +- ...ettingsAgentContextListenProvider.java.bak | 224 -- .../AgentV1SettingsAgentListenProvider.java | 2 +- ...gentV1SettingsAgentListenProvider.java.bak | 224 -- .../v1/types/AgentV1SettingsApplied.java | 5 + .../v1/types/AgentV1SettingsApplied.java.bak | 83 - .../agent/v1/types/AgentV1SpeakUpdated.java | 5 + .../v1/types/AgentV1SpeakUpdated.java.bak | 83 - .../v1/types/AgentV1ThinkLiveUpdated.java | 5 + .../v1/types/AgentV1ThinkLiveUpdated.java.bak | 83 - .../agent/v1/types/AgentV1ThinkUpdated.java | 5 + .../v1/types/AgentV1ThinkUpdated.java.bak | 83 - .../AgentV1UpdateListenListenProvider.java | 2 +- ...AgentV1UpdateListenListenProvider.java.bak | 224 -- .../v1/types/AgentV1UserStartedSpeaking.java | 5 + .../types/AgentV1UserStartedSpeaking.java.bak | 83 - .../agent/v1/websocket/V1WebSocketClient.java | 7 +- .../v1/websocket/V1WebSocketClient.java.bak | 981 --------- .../v1/media/requests/ListenV1RequestUrl.java | 12 +- .../requests/ListenV1RequestUrl.java.bak | 1932 ----------------- .../MediaTranscribeRequestOctetStream.java | 12 +- ...MediaTranscribeRequestOctetStream.java.bak | 1931 ---------------- .../listen/v1/websocket/V1ConnectOptions.java | 8 +- .../v1/websocket/V1ConnectOptions.java.bak | 1129 ---------- .../v1/websocket/V1WebSocketClient.java | 33 +- .../v1/websocket/V1WebSocketClient.java.bak | 650 ------ .../listen/v2/types/ListenV2CloseStream.java | 5 + .../v2/types/ListenV2CloseStream.java.bak | 83 - .../listen/v2/types/ListenV2ForceEndTurn.java | 5 + .../v2/types/ListenV2ForceEndTurn.java.bak | 83 - .../v2/websocket/V2WebSocketClient.java | 47 +- .../v2/websocket/V2WebSocketClient.java.bak | 563 ----- .../speak/v1/websocket/V1WebSocketClient.java | 8 + .../v1/websocket/V1WebSocketClient.java.bak | 467 ---- .../speak/v2/types/SpeakV2Close.java | 5 + .../speak/v2/types/SpeakV2Close.java.bak | 83 - .../v2/types/SpeakV2ConfigureFailureCode.java | 4 +- .../SpeakV2ConfigureFailureCode.java.bak | 121 -- .../speak/v2/types/SpeakV2Flush.java | 5 + .../speak/v2/types/SpeakV2Flush.java.bak | 83 - .../speak/v2/websocket/V2WebSocketClient.java | 17 +- .../v2/websocket/V2WebSocketClient.java.bak | 630 ------ .../com/deepgram/types/DeepgramModel.java | 20 + .../com/deepgram/types/DeepgramModel.java.bak | 1081 --------- .../types/DeepgramThinkProviderModel.java | 7 + .../types/ThinkSettingsV1Provider.java | 4 +- .../types/ThinkSettingsV1Provider.java.bak | 458 ---- 65 files changed, 313 insertions(+), 13241 deletions(-) delete mode 100644 src/main/java/com/deepgram/core/ClientOptions.java.bak delete mode 100644 src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak delete mode 100644 src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak delete mode 100644 src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak delete mode 100644 src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak delete mode 100644 src/main/java/com/deepgram/types/DeepgramModel.java.bak delete mode 100644 src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak diff --git a/.fernignore b/.fernignore index 042e465..25267e4 100644 --- a/.fernignore +++ b/.fernignore @@ -16,7 +16,7 @@ src/main/java/com/deepgram/AsyncDeepgramClientBuilder.java # Fern regen overwrites these with incorrect SDK names and strips the markers. # Fern 4.22.1 closes tracked WebSockets before SDK-owned OkHttp resources; retain that lifecycle behavior while # reapplying only these headers. -src/main/java/com/deepgram/core/ClientOptions.java.bak +src/main/java/com/deepgram/core/ClientOptions.java # Transport abstraction (pluggable transport for SageMaker, etc.) src/main/java/com/deepgram/core/transport/ @@ -30,7 +30,7 @@ src/main/java/com/deepgram/resources/listen/v1/websocket/ListenV1ConfigureFailur # Bug fixes for maxRetries(0) semantics ("connect once, don't retry") and a # configurable connectionTimeoutMs on ReconnectOptions (was hardcoded 4000ms). # Pull this back out once the fixes are upstreamed into the Fern generator. -src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak +src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java # Forward-compat patch: Fern's generated dispatcher routes any unrecognized message # type to the error handler ("Update your SDK version..."), which makes benign new @@ -40,8 +40,8 @@ src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak # NOTE: the listen v2 and speak v2 clients below also carry the streaming query-param patches # (multi-value serialization + the additionalProperties escape hatch) documented lower down — # keep them frozen until those fixes are upstreamed too. -src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak -src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak +src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java +src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java # Streaming query-param patches on the generated WS connect() builders. Two fixes: # (1) Multi-value serialization: array-valued params (listen: keyterm, keywords, replace, search, @@ -55,25 +55,28 @@ src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java. # listen v2 and speak v2 clients are frozen above; freeze the listen v1 and speak v1 clients here too # so the fixes survive regen. Re-apply after regen; unfreeze once the generator emits array params as # repeats and serializes additionalProperties on the WS connect path (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak -src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java +src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java # Agent V1 forwards raw frames through onMessage(String); suppress generic errors only when a raw # handler is registered, otherwise retain legacy onError delivery for unknown control frames. -src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak +src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java # Source and binary compatibility for third-party implementations of generated builder stages. # Generated concrete builders override languageHint; default interface methods preserve existing custom implementations. -src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak -src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak -src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak +src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java +src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java +src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java # Preserve existing AgentV1ConversationText builder implementations after adding conversationalBehavior. -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java # Fern now generates the distinct Deepgram Think provider and model types. Keep the union frozen only to preserve the # default Visitor method for source and binary compatibility with callers compiled before the Deepgram provider existed. -src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak +src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java + +# Retains the previous public PhoneLLM constant spelling after Fern removed the underscore before 2. +src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java # Restores the FLUX_RENEE_EN constant that generator 4.18.0 dropped. The voice is live: # POST /v2/speak?model=flux-renee-en returns 200 with valid audio, and the name resolves in the @@ -85,26 +88,26 @@ src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak # changes -- 4.18.0 alone added 25 constants. On the next regen do NOT restore the .bak wholesale: # diff it against the newly generated file, carry forward every new voice, and re-apply only the # FLUX_RENEE_EN touchpoints (constant, Value enum, visit() case, valueOf() case, Visitor method). -src/main/java/com/deepgram/types/DeepgramModel.java.bak +src/main/java/com/deepgram/types/DeepgramModel.java # Manual equals/hashCode contract fix: Fern generates equals() (all instances equal) but no # hashCode() for fields-less message types, violating the Object contract. We add a consistent # hashCode() to each. Unfreeze and drop these patches once the generator emits a matching # equals/hashCode pair for fields-less types (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak -src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java +src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # Union default-variant fix (STOPGAP). The agent listen-provider unions declare `version` as an # optional discriminator, so a provider payload without it is valid (and is what 0.7.x emits). Fern @@ -113,13 +116,13 @@ src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java # {"provider":null}, silently dropping the caller's provider on the wire. Patched to # defaultImpl = V2Value on each. Guarded by AgentSettingsProviderDefaultTest. Unfreeze and drop once # the generator stops defaulting unions to the empty _UnknownValue (tracked as an upstream Fern request). -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak -src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java +src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java # Preserve binary-compatible Visitor implementations from before this generated enum added # CONTROL_COMBINATION_INVALID. The default method routes old visitors through visitUnknown. -src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak +src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java # Build and project configuration build.gradle diff --git a/AGENTS.md b/AGENTS.md index a5e697a..7e14b27 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,6 +52,7 @@ Current temporarily frozen files: - `src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java` - Agent V1 already delivers every raw control frame through `onMessage(String)`. Suppress generic errors for unknown frames only when a raw handler is registered; otherwise retain legacy `onError` delivery. Preserve the generated Think Live, dynamic-injection, and frustration handlers during reconciliation. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java` restores the legacy `content(...): _FinalStage` builder stage and defaults omitted or empty `conversational_behavior` to `default`. The schema now requires the wire field, while this shim preserves source and binary compatibility for callers compiled before Think Live existed. `ConversationalBehaviorStage` remains as an intentionally retained generated type, even though the restored legacy stage no longer returns it. - `src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java` makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility with implementations compiled before the provider existed. Fern now generates the distinct Think provider and model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`; retain only this Visitor default until Fern generates it or the next major release. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`. +- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. Guarded by the Think-provider regression tests. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java` - fields-less event type with a manual `hashCode()` patch. Fern generates `equals()` but no matching `hashCode()`, violating the Object contract; retain the patch, freeze entry, and `RegenTypesTest.FieldsLessMessageContract` assertion until Fern fixes the pattern. - `src/main/java/com/deepgram/core/ClientOptions.java` - preserves release-please version markers, correct SDK header constants, and the accurate `close()` lifecycle Javadoc that Fern currently overwrites; use the standard `.bak` swap/restore workflow during regen review. Since generator 4.18.0 Fern emits a `getSdkVersion()` helper reading `Package.getImplementationVersion()` instead of a literal. That *does* resolve in the published artifact (CI publishes via `./mvnw deploy -P release`, and `pom.xml`'s maven-jar-plugin sets `addDefaultImplementationEntries=true`, so the JAR manifest carries `Implementation-Version`), but it resolves to `null` under Gradle and in tests, where it silently falls back to a hardcoded literal the generator does not keep current. We keep the explicit literals because they are correct in every context and because `.github/release-please-config.json` already lists this file in `extra-files`, so release-please bumps it alongside `pom.xml`, `build.gradle`, and `.fern/metadata.json`. Fern also emits `User-Agent` with a `com.deepgram.` prefix while leaving `X-Fern-SDK-Name` on the `com.deepgram:` Maven-coordinate form; we keep both on the colon form. Fern 4.22.1 tracks and closes child WebSockets before shutting down SDK-owned OkHttp resources; the permanent custom client wrappers inherit it, so do not add wrapper-local lifecycle code and retain Fern's lifecycle implementation during reconciliation. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` - carries bug fixes for `maxRetries(0)` semantics ("connect once, don't retry") and a configurable `connectionTimeoutMs` field (was hardcoded 4000ms), plus an `applyOptionsOverride(...)` hook used by `TransportWebSocketFactory` to apply per-transport reconnect policy; pull this back out once the fixes are upstreamed into the Fern generator. Use the standard `.bak` swap/restore workflow during regen review. diff --git a/src/main/java/com/deepgram/core/ClientOptions.java b/src/main/java/com/deepgram/core/ClientOptions.java index 63b6d66..8369b24 100644 --- a/src/main/java/com/deepgram/core/ClientOptions.java +++ b/src/main/java/com/deepgram/core/ClientOptions.java @@ -63,10 +63,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.deepgram.deepgram-java-sdk/" + getSdkVersion()); + put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.4"); // x-release-please-version put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); - put("X-Fern-SDK-Version", getSdkVersion()); + put("X-Fern-SDK-Version", "0.11.4"); // x-release-please-version } }); this.headerSuppliers = headerSuppliers; @@ -98,11 +98,6 @@ public Map headers(RequestOptions requestOptions) { return values; } - private static String getSdkVersion() { - String version = ClientOptions.class.getPackage().getImplementationVersion(); - return version != null ? version : "0.11.5"; - } - public int timeout(RequestOptions requestOptions) { if (requestOptions == null) { return this.timeout; @@ -149,10 +144,12 @@ public Optional retryJitterFactor() { * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the * caller owns its lifecycle. *

- * In-flight calls are not cancelled or awaited, and any request issued after this method - * returns fails with a {@code RejectedExecutionException}. Options derived from this one via + * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later + * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous + * requests may still run. Options derived from this one via * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either - * releases them for both. Calling this method more than once has no further effect. + * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method + * more than once has no further effect. *

* WebSocket clients created from this client that are still connected are disconnected * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the diff --git a/src/main/java/com/deepgram/core/ClientOptions.java.bak b/src/main/java/com/deepgram/core/ClientOptions.java.bak deleted file mode 100644 index 8369b24..0000000 --- a/src/main/java/com/deepgram/core/ClientOptions.java.bak +++ /dev/null @@ -1,409 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Supplier; -import okhttp3.OkHttpClient; - -public final class ClientOptions { - private final Environment environment; - - private final Map headers; - - private final Map> headerSuppliers; - - private final OkHttpClient httpClient; - - private final boolean ownsHttpClient; - - private final AtomicBoolean closed; - - private final Set openWebSockets; - - private final int timeout; - - private final int maxRetries; - - private final Optional initialRetryDelayMillis; - - private final Optional maxRetryDelayMillis; - - private final Optional retryJitterFactor; - - private final Optional webSocketFactory; - - private final Optional logging; - - private ClientOptions( - Environment environment, - Map headers, - Map> headerSuppliers, - OkHttpClient httpClient, - boolean ownsHttpClient, - AtomicBoolean closed, - Set openWebSockets, - int timeout, - int maxRetries, - Optional initialRetryDelayMillis, - Optional maxRetryDelayMillis, - Optional retryJitterFactor, - Optional webSocketFactory, - Optional logging) { - this.environment = environment; - this.headers = new HashMap<>(); - this.headers.putAll(headers); - this.headers.putAll(new HashMap() { - { - put("User-Agent", "com.deepgram:deepgram-java-sdk/0.11.4"); // x-release-please-version - put("X-Fern-Language", "JAVA"); - put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk"); - put("X-Fern-SDK-Version", "0.11.4"); // x-release-please-version - } - }); - this.headerSuppliers = headerSuppliers; - this.httpClient = httpClient; - this.ownsHttpClient = ownsHttpClient; - this.closed = closed; - this.openWebSockets = openWebSockets; - this.timeout = timeout; - this.maxRetries = maxRetries; - this.initialRetryDelayMillis = initialRetryDelayMillis; - this.maxRetryDelayMillis = maxRetryDelayMillis; - this.retryJitterFactor = retryJitterFactor; - this.webSocketFactory = webSocketFactory; - this.logging = logging; - } - - public Environment environment() { - return this.environment; - } - - public Map headers(RequestOptions requestOptions) { - Map values = new HashMap<>(this.headers); - headerSuppliers.forEach((key, supplier) -> { - values.put(key, supplier.get()); - }); - if (requestOptions != null) { - values.putAll(requestOptions.getHeaders()); - } - return values; - } - - public int timeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.timeout; - } - return requestOptions.getTimeout().orElse(this.timeout); - } - - public OkHttpClient httpClient() { - return this.httpClient; - } - - public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.httpClient; - } - return this.httpClient - .newBuilder() - .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .build(); - } - - public int maxRetries() { - return this.maxRetries; - } - - public Optional initialRetryDelayMillis() { - return this.initialRetryDelayMillis; - } - - public Optional maxRetryDelayMillis() { - return this.maxRetryDelayMillis; - } - - public Optional retryJitterFactor() { - return this.retryJitterFactor; - } - - /** - * Releases resources owned by this client. Only shuts down the underlying OkHttpClient's - * dispatcher executor and evicts its connection pool when this client created that - * OkHttpClient itself; an OkHttpClient supplied via httpClient is left running, since the - * caller owns its lifecycle. - *

- * In-flight calls are not cancelled or awaited. When this client owns its OkHttpClient, later - * asynchronous HTTP requests can fail when the dispatcher rejects work, while synchronous - * requests may still run. Options derived from this one via - * {@code Builder.from(...)} share the same dispatcher and connection pool, so closing either - * releases them for both. A caller-supplied OkHttpClient remains running. Calling this method - * more than once has no further effect. - *

- * WebSocket clients created from this client that are still connected are disconnected - * first (whether or not the OkHttpClient is owned), so they stop reconnecting before the - * dispatcher goes away. Any WebSocket connect or reconnect attempted afterwards fails with - * an {@code IllegalStateException} explaining that the client has been closed. - */ - public void close() { - if (!this.closed.compareAndSet(false, true)) { - return; - } - for (AutoCloseable webSocket : new ArrayList<>(this.openWebSockets)) { - try { - webSocket.close(); - } catch (Exception e) { - // best effort; keep closing the remaining sockets and the HTTP client - } - } - this.openWebSockets.clear(); - if (!this.ownsHttpClient) { - return; - } - this.httpClient.dispatcher().executorService().shutdown(); - this.httpClient.connectionPool().evictAll(); - } - - /** - * Returns whether {@link #close()} has been called on this client. - */ - public boolean isClosed() { - return this.closed.get(); - } - - /** - * Tracks a connected WebSocket client so that {@link #close()} disconnects it. - * - * @throws IllegalStateException if this client has already been closed - */ - public void registerWebSocket(AutoCloseable webSocket) { - this.openWebSockets.add(webSocket); - if (this.closed.get()) { - this.openWebSockets.remove(webSocket); - throw new IllegalStateException("root client has been closed"); - } - } - - /** - * Stops tracking a WebSocket client that has been disconnected. - */ - public void unregisterWebSocket(AutoCloseable webSocket) { - this.openWebSockets.remove(webSocket); - } - - public Optional webSocketFactory() { - return this.webSocketFactory; - } - - public Optional logging() { - return this.logging; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Environment environment; - - private final Map headers = new HashMap<>(); - - private final Map> headerSuppliers = new HashMap<>(); - - private int maxRetries = 2; - - private Optional initialRetryDelayMillis = Optional.empty(); - - private Optional maxRetryDelayMillis = Optional.empty(); - - private Optional retryJitterFactor = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private OkHttpClient httpClient = null; - - private boolean ownsHttpClient = true; - - private AtomicBoolean closed; - - private Set openWebSockets; - - private Optional logging = Optional.empty(); - - private Optional webSocketFactory = Optional.empty(); - - public Builder environment(Environment environment) { - this.environment = environment; - return this; - } - - public Builder addHeader(String key, String value) { - if (value != null) { - this.headers.put(key, value); - } - return this; - } - - public Builder addHeader(String key, Supplier value) { - this.headerSuppliers.put(key, value); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(int timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - /** - * Override the timeout in seconds. Defaults to 60 seconds. - */ - public Builder timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - /** - * Override the maximum number of retries. Defaults to 2 retries. - */ - public Builder maxRetries(int maxRetries) { - this.maxRetries = maxRetries; - return this; - } - - /** - * Override the initial delay (in milliseconds) used for exponential backoff between retries. Defaults to 1000 milliseconds. - */ - public Builder initialRetryDelayMillis(long initialRetryDelayMillis) { - this.initialRetryDelayMillis = Optional.of(initialRetryDelayMillis); - return this; - } - - /** - * Override the maximum delay (in milliseconds) between retries. Defaults to 60000 milliseconds. - */ - public Builder maxRetryDelayMillis(long maxRetryDelayMillis) { - this.maxRetryDelayMillis = Optional.of(maxRetryDelayMillis); - return this; - } - - /** - * Override the jitter factor (between 0 and 1) applied to retry delays. Defaults to 0.2. - */ - public Builder retryJitterFactor(double retryJitterFactor) { - this.retryJitterFactor = Optional.of(retryJitterFactor); - return this; - } - - /** - * Sets the underlying OkHttp client. The caller retains ownership of its lifecycle: - * close() will not shut down its dispatcher executor or evict its connection pool. - */ - public Builder httpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; - this.ownsHttpClient = httpClient == null; - return this; - } - - /** - * Set a custom WebSocketFactory for creating WebSocket connections. - */ - public Builder webSocketFactory(WebSocketFactory webSocketFactory) { - this.webSocketFactory = Optional.of(webSocketFactory); - return this; - } - - /** - * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. - */ - public Builder logging(LogConfig logging) { - this.logging = Optional.of(logging); - return this; - } - - public ClientOptions build() { - OkHttpClient.Builder httpClientBuilder = - this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); - - if (this.httpClient != null) { - timeout.ifPresent(timeout -> httpClientBuilder - .callTimeout(timeout, TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS)); - } else { - httpClientBuilder - .callTimeout(this.timeout.orElse(60), TimeUnit.SECONDS) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .addInterceptor(new RetryInterceptor( - this.maxRetries, - this.initialRetryDelayMillis, - this.maxRetryDelayMillis, - this.retryJitterFactor)); - } - - Logger logger = Logger.from(this.logging); - httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); - httpClientBuilder.addInterceptor(new ResponseDecompressionInterceptor()); - - this.httpClient = httpClientBuilder.build(); - this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); - - AtomicBoolean closedToUse = this.closed != null ? this.closed : new AtomicBoolean(false); - Set openWebSocketsToUse = - this.openWebSockets != null ? this.openWebSockets : ConcurrentHashMap.newKeySet(); - - return new ClientOptions( - environment, - headers, - headerSuppliers, - httpClient, - this.ownsHttpClient, - closedToUse, - openWebSocketsToUse, - this.timeout.get(), - this.maxRetries, - this.initialRetryDelayMillis, - this.maxRetryDelayMillis, - this.retryJitterFactor, - this.webSocketFactory, - this.logging); - } - - /** - * Create a new Builder initialized with values from an existing ClientOptions - */ - public static Builder from(ClientOptions clientOptions) { - Builder builder = new Builder(); - builder.environment = clientOptions.environment(); - builder.timeout = Optional.of(clientOptions.timeout(null)); - builder.httpClient = clientOptions.httpClient(); - builder.ownsHttpClient = clientOptions.ownsHttpClient; - builder.closed = clientOptions.closed; - builder.openWebSockets = clientOptions.openWebSockets; - builder.headers.putAll(clientOptions.headers); - builder.headerSuppliers.putAll(clientOptions.headerSuppliers); - builder.maxRetries = clientOptions.maxRetries(); - builder.initialRetryDelayMillis = clientOptions.initialRetryDelayMillis(); - builder.maxRetryDelayMillis = clientOptions.maxRetryDelayMillis(); - builder.retryJitterFactor = clientOptions.retryJitterFactor(); - builder.logging = clientOptions.logging(); - return builder; - } - } -} diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java index dc32da2..b51aacc 100644 --- a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java +++ b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java @@ -27,13 +27,7 @@ * Provides production-ready resilience for WebSocket connections. */ public abstract class ReconnectingWebSocketListener extends WebSocketListener { - private final long minReconnectionDelayMs; - - private final long maxReconnectionDelayMs; - - private final double reconnectionDelayGrowFactor; - - private final int maxRetries; + private volatile ReconnectOptions activeOptions; private final int maxEnqueuedMessages; @@ -81,22 +75,30 @@ public ReconnectingWebSocketListener( ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier, BooleanSupplier closedCheck) { - this.minReconnectionDelayMs = options.minReconnectionDelayMs; - this.maxReconnectionDelayMs = options.maxReconnectionDelayMs; - this.reconnectionDelayGrowFactor = options.reconnectionDelayGrowFactor; - this.maxRetries = options.maxRetries; + this.activeOptions = options; this.maxEnqueuedMessages = options.maxEnqueuedMessages; this.connectionSupplier = connectionSupplier; this.closedCheck = closedCheck; } + /** + * Replaces option-derived reconnect settings without rebuilding generated clients. + * + * @param options replacement options; {@code null} is a no-op + */ + public void applyOptionsOverride(ReconnectOptions options) { + if (options != null) { + this.activeOptions = options; + } + } + /** * Initiates a WebSocket connection with automatic reconnection enabled. * * Connection behavior: - * - Times out after 4000 milliseconds + * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) * - Thread-safe via atomic lock (returns immediately if connection in progress) - * - Retry count not incremented for initial connection attempt + * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry * * Error handling: * - TimeoutException: Includes retry attempt context @@ -114,18 +116,20 @@ public void connect() { onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); return; } - if (retryCount.get() >= maxRetries) { + ReconnectOptions options = this.activeOptions; + if (retryCount.get() > options.maxRetries) { connectLock.set(false); return; } try { CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); try { - webSocket = connectionFuture.get(4000, MILLISECONDS); + webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); } catch (TimeoutException e) { connectionFuture.cancel(true); TimeoutException timeoutError = - new TimeoutException("WebSocket connection timeout after " + 4000 + " milliseconds" + new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs + + " milliseconds" + (retryCount.get() > 0 ? " (retry attempt #" + retryCount.get() + ")" : " (initial connection attempt)")); @@ -415,10 +419,12 @@ protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, Strin */ private long getNextDelay() { if (retryCount.get() == 1) { - return minReconnectionDelayMs; + return activeOptions.minReconnectionDelayMs; } - long delay = (long) (minReconnectionDelayMs * Math.pow(reconnectionDelayGrowFactor, retryCount.get() - 1)); - return Math.min(delay, maxReconnectionDelayMs); + ReconnectOptions options = this.activeOptions; + long delay = (long) + (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); + return Math.min(delay, options.maxReconnectionDelayMs); } /** @@ -504,12 +510,15 @@ public static final class ReconnectOptions { public final int maxEnqueuedMessages; + public final long connectionTimeoutMs; + private ReconnectOptions(Builder builder) { this.minReconnectionDelayMs = builder.minReconnectionDelayMs; this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; this.maxRetries = builder.maxRetries; this.maxEnqueuedMessages = builder.maxEnqueuedMessages; + this.connectionTimeoutMs = builder.connectionTimeoutMs; } public static Builder builder() { @@ -527,12 +536,15 @@ public static final class Builder { private int maxEnqueuedMessages; + private long connectionTimeoutMs; + public Builder() { this.minReconnectionDelayMs = 1000; this.maxReconnectionDelayMs = 10000; this.reconnectionDelayGrowFactor = 1.3; this.maxRetries = 2147483647; this.maxEnqueuedMessages = 1000; + this.connectionTimeoutMs = 4000; } public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { @@ -560,6 +572,14 @@ public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { return this; } + /** + * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. + */ + public Builder connectionTimeoutMs(long connectionTimeoutMs) { + this.connectionTimeoutMs = connectionTimeoutMs; + return this; + } + /** * Builds the ReconnectOptions with validation. * @@ -592,6 +612,9 @@ public ReconnectOptions build() { if (maxEnqueuedMessages < 0) { throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); } + if (connectionTimeoutMs <= 0) { + throw new IllegalArgumentException("connectionTimeoutMs must be positive"); + } return new ReconnectOptions(this); } } diff --git a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak b/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak deleted file mode 100644 index b51aacc..0000000 --- a/src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java.bak +++ /dev/null @@ -1,622 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.core; - -import static java.util.concurrent.TimeUnit.*; - -import java.util.ArrayList; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.BooleanSupplier; -import java.util.function.Consumer; -import java.util.function.Supplier; -import okhttp3.Response; -import okhttp3.WebSocket; -import okhttp3.WebSocketListener; -import okio.ByteString; - -/** - * WebSocketListener with automatic reconnection, exponential backoff, and message queuing. - * Provides production-ready resilience for WebSocket connections. - */ -public abstract class ReconnectingWebSocketListener extends WebSocketListener { - private volatile ReconnectOptions activeOptions; - - private final int maxEnqueuedMessages; - - private final AtomicInteger retryCount = new AtomicInteger(0); - - private final AtomicBoolean connectLock = new AtomicBoolean(false); - - private final AtomicBoolean shouldReconnect = new AtomicBoolean(true); - - protected volatile WebSocket webSocket; - - private volatile long connectionEstablishedTime = 0L; - - private final ConcurrentLinkedQueue messageQueue = new ConcurrentLinkedQueue<>(); - - private final ConcurrentLinkedQueue binaryMessageQueue = new ConcurrentLinkedQueue<>(); - - private final ScheduledExecutorService reconnectExecutor = Executors.newSingleThreadScheduledExecutor(); - - private final Supplier connectionSupplier; - - private final BooleanSupplier closedCheck; - - /** - * Creates a new reconnecting WebSocket listener. - * - * @param options Reconnection configuration options - * @param connectionSupplier Supplier that creates new WebSocket connections - */ - public ReconnectingWebSocketListener( - ReconnectingWebSocketListener.ReconnectOptions options, Supplier connectionSupplier) { - this(options, connectionSupplier, () -> false); - } - - /** - * Creates a new reconnecting WebSocket listener. - * - * @param options Reconnection configuration options - * @param connectionSupplier Supplier that creates new WebSocket connections - * @param closedCheck Returns true once the owning client has been closed; connect and - * reconnect attempts made after that point fail with an {@link IllegalStateException} - * instead of being retried - */ - public ReconnectingWebSocketListener( - ReconnectingWebSocketListener.ReconnectOptions options, - Supplier connectionSupplier, - BooleanSupplier closedCheck) { - this.activeOptions = options; - this.maxEnqueuedMessages = options.maxEnqueuedMessages; - this.connectionSupplier = connectionSupplier; - this.closedCheck = closedCheck; - } - - /** - * Replaces option-derived reconnect settings without rebuilding generated clients. - * - * @param options replacement options; {@code null} is a no-op - */ - public void applyOptionsOverride(ReconnectOptions options) { - if (options != null) { - this.activeOptions = options; - } - } - - /** - * Initiates a WebSocket connection with automatic reconnection enabled. - * - * Connection behavior: - * - Times out after {@code ReconnectOptions.connectionTimeoutMs} (default 4000ms) - * - Thread-safe via atomic lock (returns immediately if connection in progress) - * - {@code maxRetries} counts retries only; {@code maxRetries(0)} means connect once, do not retry - * - * Error handling: - * - TimeoutException: Includes retry attempt context - * - InterruptedException: Preserves thread interruption status - * - ExecutionException: Extracts actual cause and adds context - * - Owning client closed: reports an IllegalStateException once and stops reconnecting - */ - public void connect() { - if (!connectLock.compareAndSet(false, true)) { - return; - } - if (closedCheck.getAsBoolean()) { - shouldReconnect.set(false); - connectLock.set(false); - onWebSocketFailure(null, new IllegalStateException("root client has been closed"), null); - return; - } - ReconnectOptions options = this.activeOptions; - if (retryCount.get() > options.maxRetries) { - connectLock.set(false); - return; - } - try { - CompletableFuture connectionFuture = CompletableFuture.supplyAsync(connectionSupplier); - try { - webSocket = connectionFuture.get(options.connectionTimeoutMs, MILLISECONDS); - } catch (TimeoutException e) { - connectionFuture.cancel(true); - TimeoutException timeoutError = - new TimeoutException("WebSocket connection timeout after " + options.connectionTimeoutMs - + " milliseconds" - + (retryCount.get() > 0 - ? " (retry attempt #" + retryCount.get() + ")" - : " (initial connection attempt)")); - onWebSocketFailure(null, timeoutError, null); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } catch (InterruptedException e) { - connectionFuture.cancel(true); - Thread.currentThread().interrupt(); - InterruptedException interruptError = new InterruptedException("WebSocket connection interrupted" - + (retryCount.get() > 0 - ? " during retry attempt #" + retryCount.get() - : " during initial connection")); - interruptError.initCause(e); - onWebSocketFailure(null, interruptError, null); - } catch (ExecutionException e) { - Throwable cause = e.getCause() != null ? e.getCause() : e; - String context = retryCount.get() > 0 - ? "WebSocket connection failed during retry attempt #" + retryCount.get() - : "WebSocket connection failed during initial attempt"; - RuntimeException wrappedException = new RuntimeException( - context + ": " + cause.getClass().getSimpleName() + ": " + cause.getMessage()); - wrappedException.initCause(cause); - onWebSocketFailure(null, wrappedException, null); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } - } finally { - connectLock.set(false); - } - } - - /** - * Disconnects the WebSocket and disables automatic reconnection. - * - * This method: - * - Disables automatic reconnection - * - Clears queued messages to prevent stale data - * - Closes the WebSocket with standard close code 1000 - * - Properly shuts down the reconnect executor to prevent thread leaks - * - Waits up to 5 seconds for executor termination - */ - public void disconnect() { - shouldReconnect.set(false); - messageQueue.clear(); - binaryMessageQueue.clear(); - if (webSocket != null) { - webSocket.close(1000, "Client disconnecting"); - } - reconnectExecutor.shutdown(); - try { - if (!reconnectExecutor.awaitTermination(5, SECONDS)) { - reconnectExecutor.shutdownNow(); - } - } catch (InterruptedException e) { - reconnectExecutor.shutdownNow(); - Thread.currentThread().interrupt(); - } - } - - /** - * Sends a message or queues it if not connected. - * - * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). - * - * Behavior: - * - If connected: Attempts direct send, queues if buffer full - * - If disconnected: Queues message up to maxEnqueuedMessages limit - * - If queue full: Message is dropped - * - * @param message The message to send - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean send(String message) { - return send(message, null); - } - - /** - * Sends a message or queues it if not connected, exposing the accepting socket. - * - * Behaves like {@link #send(String)}, but additionally invokes {@code onSent} with the - * WebSocket that accepted the message. The callback is only invoked when the message was - * sent directly, never when it was queued or dropped. This lets callers associate a - * protocol-level message with the specific connection it was delivered on, e.g. to decide - * in {@link #shouldReconnectAfterClose(WebSocket, int, String)} whether a later close of that same - * connection was expected. - * - * @param message The message to send - * @param onSent Callback receiving the WebSocket that accepted the message, or null - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean send(String message, Consumer onSent) { - WebSocket ws = webSocket; - if (ws != null) { - boolean sent = ws.send(message); - if (sent && onSent != null) { - onSent.accept(ws); - } - if (!sent && messageQueue.size() < maxEnqueuedMessages) { - messageQueue.offer(message); - return false; - } - return sent; - } else { - if (messageQueue.size() < maxEnqueuedMessages) { - messageQueue.offer(message); - return false; - } - return false; - } - } - - /** - * Sends binary data or queues it if not connected. - * - * Thread-safe: Synchronized to prevent race conditions with flushMessageQueue(). - * - * Behavior: - * - If connected: Attempts direct send, queues if buffer full - * - If disconnected: Queues data up to maxEnqueuedMessages limit - * - If queue full: Data is dropped - * - * @param data The binary data to send - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean sendBinary(ByteString data) { - return sendBinary(data, null); - } - - /** - * Sends binary data or queues it if not connected, exposing the accepting socket. - * - * Behaves like {@link #sendBinary(ByteString)}, but additionally invokes {@code onSent} with - * the WebSocket that accepted the data. The callback is only invoked when the data was sent - * directly, never when it was queued or dropped. - * - * @param data The binary data to send - * @param onSent Callback receiving the WebSocket that accepted the data, or null - * @return true if sent immediately, false if queued or dropped - */ - public synchronized boolean sendBinary(ByteString data, Consumer onSent) { - WebSocket ws = webSocket; - if (ws != null) { - boolean sent = ws.send(data); - if (sent && onSent != null) { - onSent.accept(ws); - } - if (!sent && binaryMessageQueue.size() < maxEnqueuedMessages) { - binaryMessageQueue.offer(data); - return false; - } - return sent; - } else { - if (binaryMessageQueue.size() < maxEnqueuedMessages) { - binaryMessageQueue.offer(data); - return false; - } - return false; - } - } - - /** - * Gets the current WebSocket instance. - * Thread-safe method to access the WebSocket connection. - * @return the WebSocket or null if not connected - */ - public WebSocket getWebSocket() { - return webSocket; - } - - /** - * @hidden - */ - @Override - public void onOpen(WebSocket webSocket, Response response) { - this.webSocket = webSocket; - connectionEstablishedTime = System.currentTimeMillis(); - retryCount.set(0); - flushMessageQueue(); - onWebSocketOpen(webSocket, response); - } - - @Override - public void onMessage(WebSocket webSocket, String text) { - onWebSocketMessage(webSocket, text); - } - - @Override - public void onMessage(WebSocket webSocket, ByteString bytes) { - onWebSocketBinaryMessage(webSocket, bytes); - } - - /** - * @hidden - */ - @Override - public void onFailure(WebSocket webSocket, Throwable t, Response response) { - this.webSocket = null; - long uptime = 0L; - if (connectionEstablishedTime > 0) { - uptime = System.currentTimeMillis() - connectionEstablishedTime; - if (uptime >= 5000) { - retryCount.set(0); - } - } - connectionEstablishedTime = 0L; - Throwable enhancedError = t; - if (t != null) { - String errorContext = "WebSocket connection failed"; - if (uptime > 0) { - errorContext += " after " + (uptime / 1000) + " seconds"; - } - if (response != null) { - errorContext += " with HTTP " + response.code() + " " + response.message(); - } - enhancedError = - new RuntimeException(errorContext + ": " + t.getClass().getSimpleName() + ": " + t.getMessage()); - enhancedError.initCause(t); - } - onWebSocketFailure(webSocket, enhancedError, response); - if (shouldReconnect.get()) { - scheduleReconnect(); - } - } - - /** - * Acknowledges a peer-initiated close so OkHttp can complete the close handshake and - * invoke {@link #onClosed(WebSocket, int, String)}. - * - * Code 1005 is a local "no status received" sentinel reported when the peer sent an empty - * close frame. It is not a valid code to put on the wire, so it is acknowledged with - * the normal closure code 1000 instead. - * - * @hidden - */ - @Override - public void onClosing(WebSocket webSocket, int code, String reason) { - webSocket.close(code == 1005 ? 1000 : code, reason); - } - - /** - * @hidden - */ - @Override - public void onClosed(WebSocket webSocket, int code, String reason) { - this.webSocket = null; - if (connectionEstablishedTime > 0) { - long uptime = System.currentTimeMillis() - connectionEstablishedTime; - if (uptime >= 5000) { - retryCount.set(0); - } - } - connectionEstablishedTime = 0L; - onWebSocketClosed(webSocket, code, reason); - if (shouldReconnect.get() && shouldReconnectAfterClose(webSocket, code, reason)) { - scheduleReconnect(); - } - } - - /** - * Decides whether a completed close handshake should trigger a reconnect. - * - * Only consulted when reconnection has not been disabled via {@link #disconnect()}. - * The default treats normal closure (1000) as terminal and reconnects on any - * other code. Subclasses can override this when protocol context establishes that a - * particular close is terminal, for example a no-status close following a message that - * ends the stream. - * - * @param webSocket The WebSocket that was closed - * @param code The close status code reported by OkHttp - * @param reason The close reason sent by the peer, or an empty string - * @return true to schedule a reconnect, false to stay disconnected - */ - protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { - return code != 1000; - } - - /** - * Calculates the next reconnection delay using exponential backoff. - * - * Uses 0-based retry count where: - * - 0 = initial connection (not used by this method) - * - 1 = first retry (returns minReconnectionDelayMs) - * - 2+ = exponential backoff up to maxReconnectionDelayMs - */ - private long getNextDelay() { - if (retryCount.get() == 1) { - return activeOptions.minReconnectionDelayMs; - } - ReconnectOptions options = this.activeOptions; - long delay = (long) - (options.minReconnectionDelayMs * Math.pow(options.reconnectionDelayGrowFactor, retryCount.get() - 1)); - return Math.min(delay, options.maxReconnectionDelayMs); - } - - /** - * Schedules a reconnection attempt with appropriate delay. - * Increments retry count and uses exponential backoff. - * Does nothing once the owning client has been closed. - */ - private void scheduleReconnect() { - if (closedCheck.getAsBoolean()) { - shouldReconnect.set(false); - return; - } - retryCount.incrementAndGet(); - long delay = getNextDelay(); - reconnectExecutor.schedule(this::connect, delay, MILLISECONDS); - } - - /** - * Sends all queued messages after reconnection. - * - * Thread-safe: Synchronized to prevent race conditions with send() method. - * - * Algorithm: - * 1. Drains queue into temporary list to avoid holding lock during sends - * 2. Attempts to send each message in order - * 3. If any send fails, re-queues that message and all subsequent messages - * 4. Preserves message ordering during re-queueing - * 5. Repeats for binary message queue - */ - private synchronized void flushMessageQueue() { - WebSocket ws = webSocket; - if (ws != null) { - ArrayList tempQueue = new ArrayList<>(); - String message; - while ((message = messageQueue.poll()) != null) { - tempQueue.add(message); - } - for (int i = 0; i < tempQueue.size(); i++) { - if (!ws.send(tempQueue.get(i))) { - for (int j = i; j < tempQueue.size(); j++) { - messageQueue.offer(tempQueue.get(j)); - } - break; - } - } - ArrayList tempBinaryQueue = new ArrayList<>(); - ByteString binaryMsg; - while ((binaryMsg = binaryMessageQueue.poll()) != null) { - tempBinaryQueue.add(binaryMsg); - } - for (int i = 0; i < tempBinaryQueue.size(); i++) { - if (!ws.send(tempBinaryQueue.get(i))) { - for (int j = i; j < tempBinaryQueue.size(); j++) { - binaryMessageQueue.offer(tempBinaryQueue.get(j)); - } - break; - } - } - } - } - - protected abstract void onWebSocketOpen(WebSocket webSocket, Response response); - - protected abstract void onWebSocketMessage(WebSocket webSocket, String text); - - protected abstract void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes); - - protected abstract void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response); - - protected abstract void onWebSocketClosed(WebSocket webSocket, int code, String reason); - - /** - * Configuration options for automatic reconnection. - */ - public static final class ReconnectOptions { - public final long minReconnectionDelayMs; - - public final long maxReconnectionDelayMs; - - public final double reconnectionDelayGrowFactor; - - public final int maxRetries; - - public final int maxEnqueuedMessages; - - public final long connectionTimeoutMs; - - private ReconnectOptions(Builder builder) { - this.minReconnectionDelayMs = builder.minReconnectionDelayMs; - this.maxReconnectionDelayMs = builder.maxReconnectionDelayMs; - this.reconnectionDelayGrowFactor = builder.reconnectionDelayGrowFactor; - this.maxRetries = builder.maxRetries; - this.maxEnqueuedMessages = builder.maxEnqueuedMessages; - this.connectionTimeoutMs = builder.connectionTimeoutMs; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private long minReconnectionDelayMs; - - private long maxReconnectionDelayMs; - - private double reconnectionDelayGrowFactor; - - private int maxRetries; - - private int maxEnqueuedMessages; - - private long connectionTimeoutMs; - - public Builder() { - this.minReconnectionDelayMs = 1000; - this.maxReconnectionDelayMs = 10000; - this.reconnectionDelayGrowFactor = 1.3; - this.maxRetries = 2147483647; - this.maxEnqueuedMessages = 1000; - this.connectionTimeoutMs = 4000; - } - - public Builder minReconnectionDelayMs(long minReconnectionDelayMs) { - this.minReconnectionDelayMs = minReconnectionDelayMs; - return this; - } - - public Builder maxReconnectionDelayMs(long maxReconnectionDelayMs) { - this.maxReconnectionDelayMs = maxReconnectionDelayMs; - return this; - } - - public Builder reconnectionDelayGrowFactor(double reconnectionDelayGrowFactor) { - this.reconnectionDelayGrowFactor = reconnectionDelayGrowFactor; - return this; - } - - public Builder maxRetries(int maxRetries) { - this.maxRetries = maxRetries; - return this; - } - - public Builder maxEnqueuedMessages(int maxEnqueuedMessages) { - this.maxEnqueuedMessages = maxEnqueuedMessages; - return this; - } - - /** - * Sets the per-attempt connection timeout in milliseconds. Defaults to {@code 4000}. - */ - public Builder connectionTimeoutMs(long connectionTimeoutMs) { - this.connectionTimeoutMs = connectionTimeoutMs; - return this; - } - - /** - * Builds the ReconnectOptions with validation. - * - * Validates that: - * - All delay values are positive - * - minReconnectionDelayMs <= maxReconnectionDelayMs - * - reconnectionDelayGrowFactor >= 1.0 - * - maxRetries and maxEnqueuedMessages are non-negative - * - * @return The validated ReconnectOptions instance - * @throws IllegalArgumentException if configuration is invalid - */ - public ReconnectOptions build() { - if (minReconnectionDelayMs <= 0) { - throw new IllegalArgumentException("minReconnectionDelayMs must be positive"); - } - if (maxReconnectionDelayMs <= 0) { - throw new IllegalArgumentException("maxReconnectionDelayMs must be positive"); - } - if (minReconnectionDelayMs > maxReconnectionDelayMs) { - throw new IllegalArgumentException("minReconnectionDelayMs (" + minReconnectionDelayMs - + ") must not exceed maxReconnectionDelayMs (" + maxReconnectionDelayMs + ")"); - } - if (reconnectionDelayGrowFactor < 1.0) { - throw new IllegalArgumentException("reconnectionDelayGrowFactor must be >= 1.0"); - } - if (maxRetries < 0) { - throw new IllegalArgumentException("maxRetries must be non-negative"); - } - if (maxEnqueuedMessages < 0) { - throw new IllegalArgumentException("maxEnqueuedMessages must be non-negative"); - } - if (connectionTimeoutMs <= 0) { - throw new IllegalArgumentException("connectionTimeoutMs must be positive"); - } - return new ReconnectOptions(this); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java index 71825ed..5962f4b 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1AgentAudioDone; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak deleted file mode 100644 index 5962f4b..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1AgentAudioDone.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1AgentAudioDone.Builder.class) -public final class AgentV1AgentAudioDone { - private final Map additionalProperties; - - private AgentV1AgentAudioDone(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier indicating the agent has finished sending audio - */ - @JsonProperty("type") - public String getType() { - return "AgentAudioDone"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1AgentAudioDone; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1AgentAudioDone other) { - return this; - } - - public AgentV1AgentAudioDone build() { - return new AgentV1AgentAudioDone(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java index 56ebeab..ef4f56a 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java @@ -77,8 +77,8 @@ public String getContent() { * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off */ @JsonProperty("conversational_behavior") - public AgentV1ConversationTextConversationalBehavior getConversationalBehavior() { - return conversationalBehavior; + public Optional getConversationalBehavior() { + return Optional.of(conversationalBehavior); } /** @@ -143,7 +143,7 @@ public interface ContentStage { /** *

The actual statement that was spoken

*/ - ConversationalBehaviorStage content(@NotNull String content); + _FinalStage content(@NotNull String content); } public interface ConversationalBehaviorStage { @@ -161,6 +161,16 @@ public interface _FinalStage { _FinalStage additionalProperties(Map additionalProperties); + default _FinalStage conversationalBehavior( + @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { + return this; + } + + default _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + return this; + } + /** *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

*/ @@ -182,7 +192,8 @@ public static final class Builder implements RoleStage, ContentStage, Conversati private String content; - private AgentV1ConversationTextConversationalBehavior conversationalBehavior; + private AgentV1ConversationTextConversationalBehavior conversationalBehavior = + AgentV1ConversationTextConversationalBehavior.DEFAULT; private Optional> languages = Optional.empty(); @@ -220,7 +231,7 @@ public ContentStage role(@NotNull AgentV1ConversationTextRole role) { */ @java.lang.Override @JsonSetter("content") - public ConversationalBehaviorStage content(@NotNull String content) { + public _FinalStage content(@NotNull String content) { this.content = Objects.requireNonNull(content, "content must not be null"); return this; } @@ -230,7 +241,7 @@ public ConversationalBehaviorStage content(@NotNull String content) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - @JsonSetter("conversational_behavior") + @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) public _FinalStage conversationalBehavior( @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { this.conversationalBehavior = @@ -238,6 +249,13 @@ public _FinalStage conversationalBehavior( return this; } + public _FinalStage conversationalBehavior( + Optional conversationalBehavior) { + this.conversationalBehavior = conversationalBehavior.orElse( + AgentV1ConversationTextConversationalBehavior.DEFAULT); + return this; + } + /** *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

* @return Reference to {@code this} so that method calls can be chained together. diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak deleted file mode 100644 index ef4f56a..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java.bak +++ /dev/null @@ -1,317 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ConversationText.Builder.class) -public final class AgentV1ConversationText { - private final AgentV1ConversationTextRole role; - - private final String content; - - private final AgentV1ConversationTextConversationalBehavior conversationalBehavior; - - private final Optional> languagesHinted; - - private final Optional> languages; - - private final Map additionalProperties; - - private AgentV1ConversationText( - AgentV1ConversationTextRole role, - String content, - AgentV1ConversationTextConversationalBehavior conversationalBehavior, - Optional> languagesHinted, - Optional> languages, - Map additionalProperties) { - this.role = role; - this.content = content; - this.conversationalBehavior = conversationalBehavior; - this.languagesHinted = languagesHinted; - this.languages = languages; - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for conversation text - */ - @JsonProperty("type") - public String getType() { - return "ConversationText"; - } - - /** - * @return Identifies who spoke the statement - */ - @JsonProperty("role") - public AgentV1ConversationTextRole getRole() { - return role; - } - - /** - * @return The actual statement that was spoken - */ - @JsonProperty("content") - public String getContent() { - return content; - } - - /** - * @return Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off - */ - @JsonProperty("conversational_behavior") - public Optional getConversationalBehavior() { - return Optional.of(conversationalBehavior); - } - - /** - * @return The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi. - */ - @JsonProperty("languages_hinted") - public Optional> getLanguagesHinted() { - return languagesHinted; - } - - /** - * @return Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi. - */ - @JsonProperty("languages") - public Optional> getLanguages() { - return languages; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ConversationText && equalTo((AgentV1ConversationText) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AgentV1ConversationText other) { - return role.equals(other.role) - && content.equals(other.content) - && conversationalBehavior.equals(other.conversationalBehavior) - && languagesHinted.equals(other.languagesHinted) - && languages.equals(other.languages); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.role, this.content, this.conversationalBehavior, this.languagesHinted, this.languages); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RoleStage builder() { - return new Builder(); - } - - public interface RoleStage { - /** - *

Identifies who spoke the statement

- */ - ContentStage role(@NotNull AgentV1ConversationTextRole role); - - Builder from(AgentV1ConversationText other); - } - - public interface ContentStage { - /** - *

The actual statement that was spoken

- */ - _FinalStage content(@NotNull String content); - } - - public interface ConversationalBehaviorStage { - /** - *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

- */ - _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior); - } - - public interface _FinalStage { - AgentV1ConversationText build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - default _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { - return this; - } - - default _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- */ - _FinalStage languagesHinted(Optional> languagesHinted); - - _FinalStage languagesHinted(List languagesHinted); - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- */ - _FinalStage languages(Optional> languages); - - _FinalStage languages(List languages); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RoleStage, ContentStage, ConversationalBehaviorStage, _FinalStage { - private AgentV1ConversationTextRole role; - - private String content; - - private AgentV1ConversationTextConversationalBehavior conversationalBehavior = - AgentV1ConversationTextConversationalBehavior.DEFAULT; - - private Optional> languages = Optional.empty(); - - private Optional> languagesHinted = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AgentV1ConversationText other) { - role(other.getRole()); - content(other.getContent()); - conversationalBehavior(other.getConversationalBehavior()); - languagesHinted(other.getLanguagesHinted()); - languages(other.getLanguages()); - return this; - } - - /** - *

Identifies who spoke the statement

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("role") - public ContentStage role(@NotNull AgentV1ConversationTextRole role) { - this.role = Objects.requireNonNull(role, "role must not be null"); - return this; - } - - /** - *

The actual statement that was spoken

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(@NotNull String content) { - this.content = Objects.requireNonNull(content, "content must not be null"); - return this; - } - - /** - *

Annotates what kind of utterance the message represents: default (a standard turn), backchannel (a short acknowledgement while the user held the floor), presence_check (a prompt after extended silence), or filler (a line covering a wait on a function call or a dynamic InjectAgentMessage). Always sent; it is default for every message while Think Live is off

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter(value = "conversational_behavior", nulls = Nulls.SKIP) - public _FinalStage conversationalBehavior( - @NotNull AgentV1ConversationTextConversationalBehavior conversationalBehavior) { - this.conversationalBehavior = - Objects.requireNonNull(conversationalBehavior, "conversationalBehavior must not be null"); - return this; - } - - public _FinalStage conversationalBehavior( - Optional conversationalBehavior) { - this.conversationalBehavior = conversationalBehavior.orElse( - AgentV1ConversationTextConversationalBehavior.DEFAULT); - return this; - } - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languages(List languages) { - this.languages = Optional.ofNullable(languages); - return this; - } - - /** - *

Languages detected in the user's speech, sorted by word count (descending). Only present on user-role messages when the listen model is flux-general-multi.

- */ - @java.lang.Override - @JsonSetter(value = "languages", nulls = Nulls.SKIP) - public _FinalStage languages(Optional> languages) { - this.languages = languages; - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languagesHinted(List languagesHinted) { - this.languagesHinted = Optional.ofNullable(languagesHinted); - return this; - } - - /** - *

The language hints that were active at the time of the turn. Only present on user-role messages when the listen model is flux-general-multi.

- */ - @java.lang.Override - @JsonSetter(value = "languages_hinted", nulls = Nulls.SKIP) - public _FinalStage languagesHinted(Optional> languagesHinted) { - this.languagesHinted = languagesHinted; - return this; - } - - @java.lang.Override - public AgentV1ConversationText build() { - return new AgentV1ConversationText( - role, content, conversationalBehavior, languagesHinted, languages, additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java index 1672d2d..9bd5f76 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1ForceEndTurn; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak deleted file mode 100644 index 9bd5f76..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ForceEndTurn.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ForceEndTurn.Builder.class) -public final class AgentV1ForceEndTurn { - private final Map additionalProperties; - - private AgentV1ForceEndTurn(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for forcing the end of the current turn - */ - @JsonProperty("type") - public String getType() { - return "ForceEndTurn"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ForceEndTurn; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ForceEndTurn other) { - return this; - } - - public AgentV1ForceEndTurn build() { - return new AgentV1ForceEndTurn(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java index 7842266..f82f59e 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1KeepAlive; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak deleted file mode 100644 index f82f59e..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1KeepAlive.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1KeepAlive.Builder.class) -public final class AgentV1KeepAlive { - private final Map additionalProperties; - - private AgentV1KeepAlive(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "KeepAlive"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1KeepAlive; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1KeepAlive other) { - return this; - } - - public AgentV1KeepAlive build() { - return new AgentV1KeepAlive(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java index 65878c9..43b8628 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1ListenUpdated; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak deleted file mode 100644 index 43b8628..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ListenUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ListenUpdated.Builder.class) -public final class AgentV1ListenUpdated { - private final Map additionalProperties; - - private AgentV1ListenUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for listen update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ListenUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ListenUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ListenUpdated other) { - return this; - } - - public AgentV1ListenUpdated build() { - return new AgentV1ListenUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java index 68d71cc..e6efced 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1PromptUpdated; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak deleted file mode 100644 index e6efced..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1PromptUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1PromptUpdated.Builder.class) -public final class AgentV1PromptUpdated { - private final Map additionalProperties; - - private AgentV1PromptUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for prompt update confirmation - */ - @JsonProperty("type") - public String getType() { - return "PromptUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1PromptUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1PromptUpdated other) { - return this; - } - - public AgentV1PromptUpdated build() { - return new AgentV1PromptUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java index eea1585..393f1f9 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak deleted file mode 100644 index 393f1f9..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentContextListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1SettingsAgentContextListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1SettingsAgentContextListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1SettingsAgentContextListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1SettingsAgentContextListenProvider(new V1Value(value)); - } - - public static AgentV1SettingsAgentContextListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1SettingsAgentContextListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsAgentContextListenProvider - && value.equals(((AgentV1SettingsAgentContextListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentContextListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java index 4309ec0..345ba2f 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak deleted file mode 100644 index 345ba2f..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsAgentListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1SettingsAgentListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1SettingsAgentListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1SettingsAgentListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1SettingsAgentListenProvider(new V1Value(value)); - } - - public static AgentV1SettingsAgentListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1SettingsAgentListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsAgentListenProvider - && value.equals(((AgentV1SettingsAgentListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1SettingsAgentListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java index 0d60b72..ad1fdb2 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1SettingsApplied; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak deleted file mode 100644 index ad1fdb2..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SettingsApplied.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1SettingsApplied.Builder.class) -public final class AgentV1SettingsApplied { - private final Map additionalProperties; - - private AgentV1SettingsApplied(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for settings applied confirmation - */ - @JsonProperty("type") - public String getType() { - return "SettingsApplied"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SettingsApplied; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1SettingsApplied other) { - return this; - } - - public AgentV1SettingsApplied build() { - return new AgentV1SettingsApplied(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java index 747aa9d..8b134b5 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1SpeakUpdated; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak deleted file mode 100644 index 8b134b5..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1SpeakUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1SpeakUpdated.Builder.class) -public final class AgentV1SpeakUpdated { - private final Map additionalProperties; - - private AgentV1SpeakUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for speak update confirmation - */ - @JsonProperty("type") - public String getType() { - return "SpeakUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1SpeakUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1SpeakUpdated other) { - return this; - } - - public AgentV1SpeakUpdated build() { - return new AgentV1SpeakUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java index 8b15579..98eaf74 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1ThinkLiveUpdated; } + @java.lang.Override + public int hashCode() { + return 1; + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak deleted file mode 100644 index 98eaf74..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ThinkLiveUpdated.Builder.class) -public final class AgentV1ThinkLiveUpdated { - private final Map additionalProperties; - - private AgentV1ThinkLiveUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for Think Live model update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ThinkLiveUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ThinkLiveUpdated; - } - - @java.lang.Override - public int hashCode() { - return 1; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ThinkLiveUpdated other) { - return this; - } - - public AgentV1ThinkLiveUpdated build() { - return new AgentV1ThinkLiveUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java index 5668a71..2d67cad 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1ThinkUpdated; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak deleted file mode 100644 index 2d67cad..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkUpdated.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1ThinkUpdated.Builder.class) -public final class AgentV1ThinkUpdated { - private final Map additionalProperties; - - private AgentV1ThinkUpdated(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier for think update confirmation - */ - @JsonProperty("type") - public String getType() { - return "ThinkUpdated"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1ThinkUpdated; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1ThinkUpdated other) { - return this; - } - - public AgentV1ThinkUpdated build() { - return new AgentV1ThinkUpdated(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java index e693a04..e739aec 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java @@ -99,7 +99,7 @@ public interface Visitor { T _visitUnknown(Object unknownType); } - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = _UnknownValue.class) + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) @JsonIgnoreProperties(ignoreUnknown = true) private interface Value { diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak deleted file mode 100644 index e739aec..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UpdateListenListenProvider.java.bak +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.types.DeepgramListenProviderV1; -import com.deepgram.types.DeepgramListenProviderV2; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class AgentV1UpdateListenListenProvider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private AgentV1UpdateListenListenProvider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static AgentV1UpdateListenListenProvider v1(DeepgramListenProviderV1 value) { - return new AgentV1UpdateListenListenProvider(new V1Value(value)); - } - - public static AgentV1UpdateListenListenProvider v2(DeepgramListenProviderV2 value) { - return new AgentV1UpdateListenListenProvider(new V2Value(value)); - } - - public boolean isV1() { - return value instanceof V1Value; - } - - public boolean isV2() { - return value instanceof V2Value; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getV1() { - if (isV1()) { - return Optional.of(((V1Value) value).value); - } - return Optional.empty(); - } - - public Optional getV2() { - if (isV2()) { - return Optional.of(((V2Value) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1UpdateListenListenProvider - && value.equals(((AgentV1UpdateListenListenProvider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitV1(DeepgramListenProviderV1 v1); - - T visitV2(DeepgramListenProviderV2 v2); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "version", visible = true, defaultImpl = V2Value.class) - @JsonSubTypes({@JsonSubTypes.Type(V1Value.class), @JsonSubTypes.Type(V2Value.class)}) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("v1") - @JsonIgnoreProperties("version") - private static final class V1Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV1 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V1Value() {} - - private V1Value(DeepgramListenProviderV1 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV1(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1Value && equalTo((V1Value) other); - } - - private boolean equalTo(V1Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("v2") - @JsonIgnoreProperties("version") - private static final class V2Value implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "version", allowSetters = true) - private DeepgramListenProviderV2 value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private V2Value() {} - - private V2Value(DeepgramListenProviderV2 value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitV2(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V2Value && equalTo((V2Value) other); - } - - private boolean equalTo(V2Value other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("version") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "AgentV1UpdateListenListenProvider{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java index edb80f8..3556d31 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java +++ b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof AgentV1UserStartedSpeaking; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak b/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak deleted file mode 100644 index 3556d31..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/types/AgentV1UserStartedSpeaking.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AgentV1UserStartedSpeaking.Builder.class) -public final class AgentV1UserStartedSpeaking { - private final Map additionalProperties; - - private AgentV1UserStartedSpeaking(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier indicating that the user has begun speaking - */ - @JsonProperty("type") - public String getType() { - return "UserStartedSpeaking"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AgentV1UserStartedSpeaking; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AgentV1UserStartedSpeaking other) { - return this; - } - - public AgentV1UserStartedSpeaking build() { - return new AgentV1UserStartedSpeaking(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java index 15b883e..b648a3e 100644 --- a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java @@ -664,10 +664,7 @@ private void handleIncomingMessage(String json) { if (node == null || node.isNull()) { throw new IllegalArgumentException("Received null or invalid JSON message"); } - if (node.has("role") - && node.has("content") - && node.has("conversational_behavior") - && "ConversationText".equals(node.path("type").asText())) { + if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { AgentV1ConversationText conversationTextHandlerEvent = null; try { conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); @@ -970,7 +967,7 @@ private void handleIncomingMessage(String json) { } return; } - if (onErrorHandler != null) { + if (onMessageHandler == null && onErrorHandler != null) { onErrorHandler.accept(new RuntimeException( "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) + "... Update your SDK version to support new message types.")); diff --git a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index b648a3e..0000000 --- a/src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,981 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.agent.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.agent.v1.types.AgentV1AgentAudioDone; -import com.deepgram.resources.agent.v1.types.AgentV1AgentStartedSpeaking; -import com.deepgram.resources.agent.v1.types.AgentV1AgentThinking; -import com.deepgram.resources.agent.v1.types.AgentV1ConversationText; -import com.deepgram.resources.agent.v1.types.AgentV1CustomFromThinkProvider; -import com.deepgram.resources.agent.v1.types.AgentV1CustomToThinkProvider; -import com.deepgram.resources.agent.v1.types.AgentV1Error; -import com.deepgram.resources.agent.v1.types.AgentV1ForceEndTurn; -import com.deepgram.resources.agent.v1.types.AgentV1FrustrationDetected; -import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallCancelled; -import com.deepgram.resources.agent.v1.types.AgentV1FunctionCallRequest; -import com.deepgram.resources.agent.v1.types.AgentV1History; -import com.deepgram.resources.agent.v1.types.AgentV1InjectAgentMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectDynamicAgentMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectUserMessage; -import com.deepgram.resources.agent.v1.types.AgentV1InjectionRefused; -import com.deepgram.resources.agent.v1.types.AgentV1KeepAlive; -import com.deepgram.resources.agent.v1.types.AgentV1LatencyReport; -import com.deepgram.resources.agent.v1.types.AgentV1ListenUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1PromptUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ReceiveFunctionCallResponse; -import com.deepgram.resources.agent.v1.types.AgentV1SendFunctionCallResponse; -import com.deepgram.resources.agent.v1.types.AgentV1Settings; -import com.deepgram.resources.agent.v1.types.AgentV1SettingsApplied; -import com.deepgram.resources.agent.v1.types.AgentV1SpeakUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ThinkLiveUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1ThinkUpdated; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateListen; -import com.deepgram.resources.agent.v1.types.AgentV1UpdatePrompt; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateSpeak; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateThink; -import com.deepgram.resources.agent.v1.types.AgentV1UpdateThinkLive; -import com.deepgram.resources.agent.v1.types.AgentV1UserStartedSpeaking; -import com.deepgram.resources.agent.v1.types.AgentV1Warning; -import com.deepgram.resources.agent.v1.types.AgentV1Welcome; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer listenUpdatedHandler; - - private volatile Consumer thinkUpdatedHandler; - - private volatile Consumer thinkLiveUpdatedHandler; - - private volatile Consumer frustrationDetectedHandler; - - private volatile Consumer onFunctionCallResponseHandler; - - private volatile Consumer promptUpdatedHandler; - - private volatile Consumer speakUpdatedHandler; - - private volatile Consumer injectionRefusedHandler; - - private volatile Consumer welcomeHandler; - - private volatile Consumer settingsAppliedHandler; - - private volatile Consumer conversationTextHandler; - - private volatile Consumer userStartedSpeakingHandler; - - private volatile Consumer agentThinkingHandler; - - private volatile Consumer latencyReportHandler; - - private volatile Consumer functionCallRequestHandler; - - private volatile Consumer functionCallCancelledHandler; - - private volatile Consumer agentStartedSpeakingHandler; - - private volatile Consumer agentAudioDoneHandler; - - private volatile Consumer customFromThinkProviderHandler; - - private volatile Consumer errorHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer agentV1HistoryHandler; - - private volatile Consumer agentV1AudioHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - */ - public CompletableFuture connect() { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getAgentURL(); - String fullPath = "/v1/agent/converse"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (agentV1AudioHandler != null) { - agentV1AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends an AgentV1Settings message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendSettings(AgentV1Settings message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateListen message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateListen(AgentV1UpdateListen message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateThink message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateThink(AgentV1UpdateThink message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateThinkLive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateThinkLive(AgentV1UpdateThinkLive message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdateSpeak message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdateSpeak(AgentV1UpdateSpeak message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectUserMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectUserMessage(AgentV1InjectUserMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectAgentMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectAgentMessage(AgentV1InjectAgentMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1InjectDynamicAgentMessage message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInjectDynamicAgentMessage(AgentV1InjectDynamicAgentMessage message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1SendFunctionCallResponse message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFunctionCallResponse(AgentV1SendFunctionCallResponse message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1KeepAlive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendKeepAlive(AgentV1KeepAlive message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1UpdatePrompt message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendUpdatePrompt(AgentV1UpdatePrompt message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1ForceEndTurn message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendForceEndTurn(AgentV1ForceEndTurn message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1CustomToThinkProvider message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCustomToThinkProvider(AgentV1CustomToThinkProvider message) { - return sendMessage(message); - } - - /** - * Sends an AgentV1Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Registers a handler for AgentV1ListenUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onListenUpdated(Consumer handler) { - this.listenUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1ThinkUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onThinkUpdated(Consumer handler) { - this.thinkUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1ThinkLiveUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onThinkLiveUpdated(Consumer handler) { - this.thinkLiveUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1FrustrationDetected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFrustrationDetected(Consumer handler) { - this.frustrationDetectedHandler = handler; - } - - /** - * Registers a handler for AgentV1ReceiveFunctionCallResponse messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallResponse(Consumer handler) { - this.onFunctionCallResponseHandler = handler; - } - - /** - * Registers a handler for AgentV1PromptUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onPromptUpdated(Consumer handler) { - this.promptUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1SpeakUpdated messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakUpdated(Consumer handler) { - this.speakUpdatedHandler = handler; - } - - /** - * Registers a handler for AgentV1InjectionRefused messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onInjectionRefused(Consumer handler) { - this.injectionRefusedHandler = handler; - } - - /** - * Registers a handler for AgentV1Welcome messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWelcome(Consumer handler) { - this.welcomeHandler = handler; - } - - /** - * Registers a handler for AgentV1SettingsApplied messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSettingsApplied(Consumer handler) { - this.settingsAppliedHandler = handler; - } - - /** - * Registers a handler for AgentV1ConversationText messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConversationText(Consumer handler) { - this.conversationTextHandler = handler; - } - - /** - * Registers a handler for AgentV1UserStartedSpeaking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onUserStartedSpeaking(Consumer handler) { - this.userStartedSpeakingHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentThinking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentThinking(Consumer handler) { - this.agentThinkingHandler = handler; - } - - /** - * Registers a handler for AgentV1LatencyReport messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onLatencyReport(Consumer handler) { - this.latencyReportHandler = handler; - } - - /** - * Registers a handler for AgentV1FunctionCallRequest messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallRequest(Consumer handler) { - this.functionCallRequestHandler = handler; - } - - /** - * Registers a handler for AgentV1FunctionCallCancelled messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFunctionCallCancelled(Consumer handler) { - this.functionCallCancelledHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentStartedSpeaking messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentStartedSpeaking(Consumer handler) { - this.agentStartedSpeakingHandler = handler; - } - - /** - * Registers a handler for AgentV1AgentAudioDone messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentAudioDone(Consumer handler) { - this.agentAudioDoneHandler = handler; - } - - /** - * Registers a handler for AgentV1CustomFromThinkProvider messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onCustomFromThinkProvider(Consumer handler) { - this.customFromThinkProviderHandler = handler; - } - - /** - * Registers a handler for AgentV1Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler for AgentV1Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for AgentV1History messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentV1History(Consumer handler) { - this.agentV1HistoryHandler = handler; - } - - /** - * Registers a handler for AgentV1Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onAgentV1Audio(Consumer handler) { - this.agentV1AudioHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("role") && node.has("content") && "ConversationText".equals(node.path("type").asText())) { - AgentV1ConversationText conversationTextHandlerEvent = null; - try { - conversationTextHandlerEvent = objectMapper.treeToValue(node, AgentV1ConversationText.class); - } catch (Exception e) { - } - if (conversationTextHandlerEvent != null) { - if (conversationTextHandler != null) { - conversationTextHandler.accept(conversationTextHandlerEvent); - } - return; - } - } - if (node.has("total_latency") - && node.has("tts_latency") - && node.has("ttt_latency") - && "AgentStartedSpeaking".equals(node.path("type").asText())) { - AgentV1AgentStartedSpeaking agentStartedSpeakingHandlerEvent = null; - try { - agentStartedSpeakingHandlerEvent = - objectMapper.treeToValue(node, AgentV1AgentStartedSpeaking.class); - } catch (Exception e) { - } - if (agentStartedSpeakingHandlerEvent != null) { - if (agentStartedSpeakingHandler != null) { - agentStartedSpeakingHandler.accept(agentStartedSpeakingHandlerEvent); - } - return; - } - } - if (node.has("count") - && node.has("escalated") - && "FrustrationDetected".equals(node.path("type").asText())) { - AgentV1FrustrationDetected frustrationDetectedHandlerEvent = null; - try { - frustrationDetectedHandlerEvent = objectMapper.treeToValue(node, AgentV1FrustrationDetected.class); - } catch (Exception e) { - } - if (frustrationDetectedHandlerEvent != null) { - if (frustrationDetectedHandler != null) { - frustrationDetectedHandler.accept(frustrationDetectedHandlerEvent); - } - return; - } - } - if (node.has("name") - && node.has("content") - && "FunctionCallResponse".equals(node.path("type").asText())) { - AgentV1ReceiveFunctionCallResponse onFunctionCallResponseHandlerEvent = null; - try { - onFunctionCallResponseHandlerEvent = - objectMapper.treeToValue(node, AgentV1ReceiveFunctionCallResponse.class); - } catch (Exception e) { - } - if (onFunctionCallResponseHandlerEvent != null) { - if (onFunctionCallResponseHandler != null) { - onFunctionCallResponseHandler.accept(onFunctionCallResponseHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Error".equals(node.path("type").asText())) { - AgentV1Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, AgentV1Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Warning".equals(node.path("type").asText())) { - AgentV1Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, AgentV1Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("message") - && "InjectionRefused".equals(node.path("type").asText())) { - AgentV1InjectionRefused injectionRefusedHandlerEvent = null; - try { - injectionRefusedHandlerEvent = objectMapper.treeToValue(node, AgentV1InjectionRefused.class); - } catch (Exception e) { - } - if (injectionRefusedHandlerEvent != null) { - if (injectionRefusedHandler != null) { - injectionRefusedHandler.accept(injectionRefusedHandlerEvent); - } - return; - } - } - if (node.has("request_id") && "Welcome".equals(node.path("type").asText())) { - AgentV1Welcome welcomeHandlerEvent = null; - try { - welcomeHandlerEvent = objectMapper.treeToValue(node, AgentV1Welcome.class); - } catch (Exception e) { - } - if (welcomeHandlerEvent != null) { - if (welcomeHandler != null) { - welcomeHandler.accept(welcomeHandlerEvent); - } - return; - } - } - if (node.has("content") && "AgentThinking".equals(node.path("type").asText())) { - AgentV1AgentThinking agentThinkingHandlerEvent = null; - try { - agentThinkingHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentThinking.class); - } catch (Exception e) { - } - if (agentThinkingHandlerEvent != null) { - if (agentThinkingHandler != null) { - agentThinkingHandler.accept(agentThinkingHandlerEvent); - } - return; - } - } - if (node.has("functions") - && "FunctionCallRequest".equals(node.path("type").asText())) { - AgentV1FunctionCallRequest functionCallRequestHandlerEvent = null; - try { - functionCallRequestHandlerEvent = objectMapper.treeToValue(node, AgentV1FunctionCallRequest.class); - } catch (Exception e) { - } - if (functionCallRequestHandlerEvent != null) { - if (functionCallRequestHandler != null) { - functionCallRequestHandler.accept(functionCallRequestHandlerEvent); - } - return; - } - } - if (node.has("functions") - && "FunctionCallCancelled".equals(node.path("type").asText())) { - AgentV1FunctionCallCancelled functionCallCancelledHandlerEvent = null; - try { - functionCallCancelledHandlerEvent = - objectMapper.treeToValue(node, AgentV1FunctionCallCancelled.class); - } catch (Exception e) { - } - if (functionCallCancelledHandlerEvent != null) { - if (functionCallCancelledHandler != null) { - functionCallCancelledHandler.accept(functionCallCancelledHandlerEvent); - } - return; - } - } - if (node.has("content") - && "__customFromThinkProvider".equals(node.path("type").asText())) { - AgentV1CustomFromThinkProvider customFromThinkProviderHandlerEvent = null; - try { - customFromThinkProviderHandlerEvent = - objectMapper.treeToValue(node, AgentV1CustomFromThinkProvider.class); - } catch (Exception e) { - } - if (customFromThinkProviderHandlerEvent != null) { - if (customFromThinkProviderHandler != null) { - customFromThinkProviderHandler.accept(customFromThinkProviderHandlerEvent); - } - return; - } - } - if ("ListenUpdated".equals(node.path("type").asText())) { - AgentV1ListenUpdated listenUpdatedHandlerEvent = null; - try { - listenUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ListenUpdated.class); - } catch (Exception e) { - } - if (listenUpdatedHandlerEvent != null) { - if (listenUpdatedHandler != null) { - listenUpdatedHandler.accept(listenUpdatedHandlerEvent); - } - return; - } - } - if ("ThinkUpdated".equals(node.path("type").asText())) { - AgentV1ThinkUpdated thinkUpdatedHandlerEvent = null; - try { - thinkUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkUpdated.class); - } catch (Exception e) { - } - if (thinkUpdatedHandlerEvent != null) { - if (thinkUpdatedHandler != null) { - thinkUpdatedHandler.accept(thinkUpdatedHandlerEvent); - } - return; - } - } - if ("ThinkLiveUpdated".equals(node.path("type").asText())) { - AgentV1ThinkLiveUpdated thinkLiveUpdatedHandlerEvent = null; - try { - thinkLiveUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1ThinkLiveUpdated.class); - } catch (Exception e) { - } - if (thinkLiveUpdatedHandlerEvent != null) { - if (thinkLiveUpdatedHandler != null) { - thinkLiveUpdatedHandler.accept(thinkLiveUpdatedHandlerEvent); - } - return; - } - } - if ("PromptUpdated".equals(node.path("type").asText())) { - AgentV1PromptUpdated promptUpdatedHandlerEvent = null; - try { - promptUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1PromptUpdated.class); - } catch (Exception e) { - } - if (promptUpdatedHandlerEvent != null) { - if (promptUpdatedHandler != null) { - promptUpdatedHandler.accept(promptUpdatedHandlerEvent); - } - return; - } - } - if ("SpeakUpdated".equals(node.path("type").asText())) { - AgentV1SpeakUpdated speakUpdatedHandlerEvent = null; - try { - speakUpdatedHandlerEvent = objectMapper.treeToValue(node, AgentV1SpeakUpdated.class); - } catch (Exception e) { - } - if (speakUpdatedHandlerEvent != null) { - if (speakUpdatedHandler != null) { - speakUpdatedHandler.accept(speakUpdatedHandlerEvent); - } - return; - } - } - if ("SettingsApplied".equals(node.path("type").asText())) { - AgentV1SettingsApplied settingsAppliedHandlerEvent = null; - try { - settingsAppliedHandlerEvent = objectMapper.treeToValue(node, AgentV1SettingsApplied.class); - } catch (Exception e) { - } - if (settingsAppliedHandlerEvent != null) { - if (settingsAppliedHandler != null) { - settingsAppliedHandler.accept(settingsAppliedHandlerEvent); - } - return; - } - } - if ("UserStartedSpeaking".equals(node.path("type").asText())) { - AgentV1UserStartedSpeaking userStartedSpeakingHandlerEvent = null; - try { - userStartedSpeakingHandlerEvent = objectMapper.treeToValue(node, AgentV1UserStartedSpeaking.class); - } catch (Exception e) { - } - if (userStartedSpeakingHandlerEvent != null) { - if (userStartedSpeakingHandler != null) { - userStartedSpeakingHandler.accept(userStartedSpeakingHandlerEvent); - } - return; - } - } - if ("LatencyReport".equals(node.path("type").asText())) { - AgentV1LatencyReport latencyReportHandlerEvent = null; - try { - latencyReportHandlerEvent = objectMapper.treeToValue(node, AgentV1LatencyReport.class); - } catch (Exception e) { - } - if (latencyReportHandlerEvent != null) { - if (latencyReportHandler != null) { - latencyReportHandler.accept(latencyReportHandlerEvent); - } - return; - } - } - if ("AgentAudioDone".equals(node.path("type").asText())) { - AgentV1AgentAudioDone agentAudioDoneHandlerEvent = null; - try { - agentAudioDoneHandlerEvent = objectMapper.treeToValue(node, AgentV1AgentAudioDone.class); - } catch (Exception e) { - } - if (agentAudioDoneHandlerEvent != null) { - if (agentAudioDoneHandler != null) { - agentAudioDoneHandler.accept(agentAudioDoneHandlerEvent); - } - return; - } - } - AgentV1History agentV1HistoryHandlerEvent = null; - try { - agentV1HistoryHandlerEvent = objectMapper.treeToValue(node, AgentV1History.class); - } catch (Exception e) { - } - if (agentV1HistoryHandlerEvent != null) { - if (agentV1HistoryHandler != null) { - agentV1HistoryHandler.accept(agentV1HistoryHandlerEvent); - } - return; - } - if (onMessageHandler == null && onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java index da7a868..3b7fcba 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java @@ -698,11 +698,17 @@ public interface _FinalStage { /** *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

*/ - _FinalStage languageHint(Optional> languageHint); + default _FinalStage languageHint(Optional> languageHint) { + return this; + } - _FinalStage languageHint(List languageHint); + default _FinalStage languageHint(List languageHint) { + return this; + } - _FinalStage languageHint(String languageHint); + default _FinalStage languageHint(String languageHint) { + return this; + } /** *

Search for terms or phrases in submitted audio and replaces them

diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak deleted file mode 100644 index 448c459..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/ListenV1RequestUrl.java.bak +++ /dev/null @@ -1,1932 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.media.requests; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV1RequestUrl.Builder.class) -public final class ListenV1RequestUrl { - private final Optional> extra; - - private final Optional> tag; - - private final Optional> customTopic; - - private final Optional> customIntent; - - private final Optional> keyterm; - - private final Optional> keywords; - - private final Optional> languageHint; - - private final Optional> replace; - - private final Optional> search; - - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional sentiment; - - private final Optional summarize; - - private final Optional topics; - - private final Optional customTopicMode; - - private final Optional intents; - - private final Optional customIntentMode; - - private final Optional detectEntities; - - private final Optional detectLanguage; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional fillerWords; - - private final Optional language; - - private final Optional measurements; - - private final Optional model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional paragraphs; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional smartFormat; - - private final Optional utterances; - - private final Optional uttSplit; - - private final Optional version; - - private final Optional mipOptOut; - - private final String url; - - private final Map additionalProperties; - - private ListenV1RequestUrl( - Optional> extra, - Optional> tag, - Optional> customTopic, - Optional> customIntent, - Optional> keyterm, - Optional> keywords, - Optional> languageHint, - Optional> replace, - Optional> search, - Optional callback, - Optional callbackMethod, - Optional sentiment, - Optional summarize, - Optional topics, - Optional customTopicMode, - Optional intents, - Optional customIntentMode, - Optional detectEntities, - Optional detectLanguage, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional fillerWords, - Optional language, - Optional measurements, - Optional model, - Optional multichannel, - Optional numerals, - Optional paragraphs, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional smartFormat, - Optional utterances, - Optional uttSplit, - Optional version, - Optional mipOptOut, - String url, - Map additionalProperties) { - this.extra = extra; - this.tag = tag; - this.customTopic = customTopic; - this.customIntent = customIntent; - this.keyterm = keyterm; - this.keywords = keywords; - this.languageHint = languageHint; - this.replace = replace; - this.search = search; - this.callback = callback; - this.callbackMethod = callbackMethod; - this.sentiment = sentiment; - this.summarize = summarize; - this.topics = topics; - this.customTopicMode = customTopicMode; - this.intents = intents; - this.customIntentMode = customIntentMode; - this.detectEntities = detectEntities; - this.detectLanguage = detectLanguage; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.fillerWords = fillerWords; - this.language = language; - this.measurements = measurements; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.paragraphs = paragraphs; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.smartFormat = smartFormat; - this.utterances = utterances; - this.uttSplit = uttSplit; - this.version = version; - this.mipOptOut = mipOptOut; - this.url = url; - this.additionalProperties = additionalProperties; - } - - /** - * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing - */ - @JsonIgnore - public Optional> getExtra() { - return extra; - } - - /** - * @return Label your requests for the purpose of identification during usage reporting - */ - @JsonIgnore - public Optional> getTag() { - return tag; - } - - /** - * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. - */ - @JsonIgnore - public Optional> getCustomTopic() { - return customTopic; - } - - /** - * @return Custom intents you want the model to detect within your input audio if present - */ - @JsonIgnore - public Optional> getCustomIntent() { - return customIntent; - } - - /** - * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. - *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @JsonIgnore - public Optional> getKeyterm() { - return keyterm; - } - - /** - * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. - */ - @JsonIgnore - public Optional> getKeywords() { - return keywords; - } - - /** - * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. - */ - @JsonIgnore - public Optional> getLanguageHint() { - return languageHint; - } - - /** - * @return Search for terms or phrases in submitted audio and replaces them - */ - @JsonIgnore - public Optional> getReplace() { - return replace; - } - - /** - * @return Search for terms or phrases in submitted audio - */ - @JsonIgnore - public Optional> getSearch() { - return search; - } - - /** - * @return URL to which we'll make the callback request - */ - @JsonIgnore - public Optional getCallback() { - return callback; - } - - /** - * @return HTTP method by which the callback request will be made - */ - @JsonIgnore - public Optional getCallbackMethod() { - return callbackMethod; - } - - /** - * @return Recognizes the sentiment throughout a transcript or text - */ - @JsonIgnore - public Optional getSentiment() { - return sentiment; - } - - /** - * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. - */ - @JsonIgnore - public Optional getSummarize() { - return summarize; - } - - /** - * @return Detect topics throughout a transcript or text - */ - @JsonIgnore - public Optional getTopics() { - return topics; - } - - /** - * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param - */ - @JsonIgnore - public Optional getCustomTopicMode() { - return customTopicMode; - } - - /** - * @return Recognizes speaker intent throughout a transcript or text - */ - @JsonIgnore - public Optional getIntents() { - return intents; - } - - /** - * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. - */ - @JsonIgnore - public Optional getCustomIntentMode() { - return customIntentMode; - } - - /** - * @return Identifies and extracts key entities from content in submitted audio - */ - @JsonIgnore - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Identifies the dominant language spoken in submitted audio - */ - @JsonIgnore - public Optional getDetectLanguage() { - return detectLanguage; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonIgnore - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. - */ - @JsonIgnore - public Optional getDiarizeModel() { - return diarizeModel; - } - - /** - * @return Dictation mode for controlling formatting with dictated speech - */ - @JsonIgnore - public Optional getDictation() { - return dictation; - } - - /** - * @return Specify the expected encoding of your submitted audio - */ - @JsonIgnore - public Optional getEncoding() { - return encoding; - } - - /** - * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" - */ - @JsonIgnore - public Optional getFillerWords() { - return fillerWords; - } - - /** - * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available - */ - @JsonIgnore - public Optional getLanguage() { - return language; - } - - /** - * @return Spoken measurements will be converted to their corresponding abbreviations - */ - @JsonIgnore - public Optional getMeasurements() { - return measurements; - } - - /** - * @return AI model used to process submitted audio - */ - @JsonIgnore - public Optional getModel() { - return model; - } - - /** - * @return Transcribe each audio channel independently - */ - @JsonIgnore - public Optional getMultichannel() { - return multichannel; - } - - /** - * @return Numerals converts numbers from written format to numerical format - */ - @JsonIgnore - public Optional getNumerals() { - return numerals; - } - - /** - * @return Splits audio into paragraphs to improve transcript readability - */ - @JsonIgnore - public Optional getParagraphs() { - return paragraphs; - } - - /** - * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely - */ - @JsonIgnore - public Optional getProfanityFilter() { - return profanityFilter; - } - - /** - * @return Add punctuation and capitalization to the transcript - */ - @JsonIgnore - public Optional getPunctuate() { - return punctuate; - } - - /** - * @return Redaction removes sensitive information from your transcripts - */ - @JsonIgnore - public Optional getRedact() { - return redact; - } - - /** - * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability - */ - @JsonIgnore - public Optional getSmartFormat() { - return smartFormat; - } - - /** - * @return Segments speech into meaningful semantic units - */ - @JsonIgnore - public Optional getUtterances() { - return utterances; - } - - /** - * @return Seconds to wait before detecting a pause between words in submitted audio - */ - @JsonIgnore - public Optional getUttSplit() { - return uttSplit; - } - - /** - * @return Version of an AI model to use - */ - @JsonIgnore - public Optional getVersion() { - return version; - } - - /** - * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip - */ - @JsonIgnore - public Optional getMipOptOut() { - return mipOptOut; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV1RequestUrl && equalTo((ListenV1RequestUrl) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListenV1RequestUrl other) { - return extra.equals(other.extra) - && tag.equals(other.tag) - && customTopic.equals(other.customTopic) - && customIntent.equals(other.customIntent) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && languageHint.equals(other.languageHint) - && replace.equals(other.replace) - && search.equals(other.search) - && callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && sentiment.equals(other.sentiment) - && summarize.equals(other.summarize) - && topics.equals(other.topics) - && customTopicMode.equals(other.customTopicMode) - && intents.equals(other.intents) - && customIntentMode.equals(other.customIntentMode) - && detectEntities.equals(other.detectEntities) - && detectLanguage.equals(other.detectLanguage) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && fillerWords.equals(other.fillerWords) - && language.equals(other.language) - && measurements.equals(other.measurements) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && paragraphs.equals(other.paragraphs) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && smartFormat.equals(other.smartFormat) - && utterances.equals(other.utterances) - && uttSplit.equals(other.uttSplit) - && version.equals(other.version) - && mipOptOut.equals(other.mipOptOut) - && url.equals(other.url); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.extra, - this.tag, - this.customTopic, - this.customIntent, - this.keyterm, - this.keywords, - this.languageHint, - this.replace, - this.search, - this.callback, - this.callbackMethod, - this.sentiment, - this.summarize, - this.topics, - this.customTopicMode, - this.intents, - this.customIntentMode, - this.detectEntities, - this.detectLanguage, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.fillerWords, - this.language, - this.measurements, - this.model, - this.multichannel, - this.numerals, - this.paragraphs, - this.profanityFilter, - this.punctuate, - this.redact, - this.smartFormat, - this.utterances, - this.uttSplit, - this.version, - this.mipOptOut, - this.url); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UrlStage builder() { - return new Builder(); - } - - public interface UrlStage { - _FinalStage url(@NotNull String url); - - Builder from(ListenV1RequestUrl other); - } - - public interface _FinalStage { - ListenV1RequestUrl build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - _FinalStage extra(Optional> extra); - - _FinalStage extra(List extra); - - _FinalStage extra(String extra); - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - _FinalStage tag(Optional> tag); - - _FinalStage tag(List tag); - - _FinalStage tag(String tag); - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - _FinalStage customTopic(Optional> customTopic); - - _FinalStage customTopic(List customTopic); - - _FinalStage customTopic(String customTopic); - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - _FinalStage customIntent(Optional> customIntent); - - _FinalStage customIntent(List customIntent); - - _FinalStage customIntent(String customIntent); - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - _FinalStage keyterm(Optional> keyterm); - - _FinalStage keyterm(List keyterm); - - _FinalStage keyterm(String keyterm); - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - _FinalStage keywords(Optional> keywords); - - _FinalStage keywords(List keywords); - - _FinalStage keywords(String keywords); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } - - default _FinalStage languageHint(List languageHint) { - return this; - } - - default _FinalStage languageHint(String languageHint) { - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - _FinalStage replace(Optional> replace); - - _FinalStage replace(List replace); - - _FinalStage replace(String replace); - - /** - *

Search for terms or phrases in submitted audio

- */ - _FinalStage search(Optional> search); - - _FinalStage search(List search); - - _FinalStage search(String search); - - /** - *

URL to which we'll make the callback request

- */ - _FinalStage callback(Optional callback); - - _FinalStage callback(String callback); - - /** - *

HTTP method by which the callback request will be made

- */ - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - _FinalStage sentiment(Optional sentiment); - - _FinalStage sentiment(Boolean sentiment); - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - _FinalStage summarize(Optional summarize); - - _FinalStage summarize(MediaTranscribeRequestSummarize summarize); - - /** - *

Detect topics throughout a transcript or text

- */ - _FinalStage topics(Optional topics); - - _FinalStage topics(Boolean topics); - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - _FinalStage customTopicMode(Optional customTopicMode); - - _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - _FinalStage intents(Optional intents); - - _FinalStage intents(Boolean intents); - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - _FinalStage customIntentMode(Optional customIntentMode); - - _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(Boolean detectEntities); - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - _FinalStage detectLanguage(Optional detectLanguage); - - _FinalStage detectLanguage(Boolean detectLanguage); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(Boolean diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(Boolean dictation); - - /** - *

Specify the expected encoding of your submitted audio

- */ - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(MediaTranscribeRequestEncoding encoding); - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - _FinalStage fillerWords(Optional fillerWords); - - _FinalStage fillerWords(Boolean fillerWords); - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - _FinalStage language(Optional language); - - _FinalStage language(String language); - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - _FinalStage measurements(Optional measurements); - - _FinalStage measurements(Boolean measurements); - - /** - *

AI model used to process submitted audio

- */ - _FinalStage model(Optional model); - - _FinalStage model(MediaTranscribeRequestModel model); - - /** - *

Transcribe each audio channel independently

- */ - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(Boolean multichannel); - - /** - *

Numerals converts numbers from written format to numerical format

- */ - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(Boolean numerals); - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - _FinalStage paragraphs(Optional paragraphs); - - _FinalStage paragraphs(Boolean paragraphs); - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(Boolean profanityFilter); - - /** - *

Add punctuation and capitalization to the transcript

- */ - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(Boolean punctuate); - - /** - *

Redaction removes sensitive information from your transcripts

- */ - _FinalStage redact(Optional redact); - - _FinalStage redact(String redact); - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(Boolean smartFormat); - - /** - *

Segments speech into meaningful semantic units

- */ - _FinalStage utterances(Optional utterances); - - _FinalStage utterances(Boolean utterances); - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - _FinalStage uttSplit(Optional uttSplit); - - _FinalStage uttSplit(Double uttSplit); - - /** - *

Version of an AI model to use

- */ - _FinalStage version(Optional version); - - _FinalStage version(MediaTranscribeRequestVersion version); - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(Boolean mipOptOut); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, _FinalStage { - private String url; - - private Optional mipOptOut = Optional.empty(); - - private Optional version = Optional.empty(); - - private Optional uttSplit = Optional.empty(); - - private Optional utterances = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional paragraphs = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional model = Optional.empty(); - - private Optional measurements = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional fillerWords = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectLanguage = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional customIntentMode = Optional.empty(); - - private Optional intents = Optional.empty(); - - private Optional customTopicMode = Optional.empty(); - - private Optional topics = Optional.empty(); - - private Optional summarize = Optional.empty(); - - private Optional sentiment = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - private Optional> search = Optional.empty(); - - private Optional> replace = Optional.empty(); - - private Optional> languageHint = Optional.empty(); - - private Optional> keywords = Optional.empty(); - - private Optional> keyterm = Optional.empty(); - - private Optional> customIntent = Optional.empty(); - - private Optional> customTopic = Optional.empty(); - - private Optional> tag = Optional.empty(); - - private Optional> extra = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListenV1RequestUrl other) { - extra(other.getExtra()); - tag(other.getTag()); - customTopic(other.getCustomTopic()); - customIntent(other.getCustomIntent()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - languageHint(other.getLanguageHint()); - replace(other.getReplace()); - search(other.getSearch()); - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - sentiment(other.getSentiment()); - summarize(other.getSummarize()); - topics(other.getTopics()); - customTopicMode(other.getCustomTopicMode()); - intents(other.getIntents()); - customIntentMode(other.getCustomIntentMode()); - detectEntities(other.getDetectEntities()); - detectLanguage(other.getDetectLanguage()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - fillerWords(other.getFillerWords()); - language(other.getLanguage()); - measurements(other.getMeasurements()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - paragraphs(other.getParagraphs()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - smartFormat(other.getSmartFormat()); - utterances(other.getUtterances()); - uttSplit(other.getUttSplit()); - version(other.getVersion()); - mipOptOut(other.getMipOptOut()); - url(other.getUrl()); - return this; - } - - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(@NotNull String url) { - this.url = Objects.requireNonNull(url, "url must not be null"); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage mipOptOut(Boolean mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - /** - *

Version of an AI model to use

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage version(MediaTranscribeRequestVersion version) { - this.version = Optional.ofNullable(version); - return this; - } - - /** - *

Version of an AI model to use

- */ - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage uttSplit(Double uttSplit) { - this.uttSplit = Optional.ofNullable(uttSplit); - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) - public _FinalStage uttSplit(Optional uttSplit) { - this.uttSplit = uttSplit; - return this; - } - - /** - *

Segments speech into meaningful semantic units

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage utterances(Boolean utterances) { - this.utterances = Optional.ofNullable(utterances); - return this; - } - - /** - *

Segments speech into meaningful semantic units

- */ - @java.lang.Override - @JsonSetter(value = "utterances", nulls = Nulls.SKIP) - public _FinalStage utterances(Optional utterances) { - this.utterances = utterances; - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage smartFormat(Boolean smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage redact(String redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- */ - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- */ - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profanityFilter(Boolean profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage paragraphs(Boolean paragraphs) { - this.paragraphs = Optional.ofNullable(paragraphs); - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - @java.lang.Override - @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) - public _FinalStage paragraphs(Optional paragraphs) { - this.paragraphs = paragraphs; - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage numerals(Boolean numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- */ - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - /** - *

Transcribe each audio channel independently

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage multichannel(Boolean multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - /** - *

Transcribe each audio channel independently

- */ - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - /** - *

AI model used to process submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage model(MediaTranscribeRequestModel model) { - this.model = Optional.ofNullable(model); - return this; - } - - /** - *

AI model used to process submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public _FinalStage model(Optional model) { - this.model = model; - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage measurements(Boolean measurements) { - this.measurements = Optional.ofNullable(measurements); - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - @java.lang.Override - @JsonSetter(value = "measurements", nulls = Nulls.SKIP) - public _FinalStage measurements(Optional measurements) { - this.measurements = measurements; - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage language(String language) { - this.language = Optional.ofNullable(language); - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fillerWords(Boolean fillerWords) { - this.fillerWords = Optional.ofNullable(fillerWords); - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - @java.lang.Override - @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) - public _FinalStage fillerWords(Optional fillerWords) { - this.fillerWords = fillerWords; - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage dictation(Boolean dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(Boolean diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectLanguage(Boolean detectLanguage) { - this.detectLanguage = Optional.ofNullable(detectLanguage); - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) - public _FinalStage detectLanguage(Optional detectLanguage) { - this.detectLanguage = detectLanguage; - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectEntities(Boolean detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { - this.customIntentMode = Optional.ofNullable(customIntentMode); - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) - public _FinalStage customIntentMode(Optional customIntentMode) { - this.customIntentMode = customIntentMode; - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage intents(Boolean intents) { - this.intents = Optional.ofNullable(intents); - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "intents", nulls = Nulls.SKIP) - public _FinalStage intents(Optional intents) { - this.intents = intents; - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { - this.customTopicMode = Optional.ofNullable(customTopicMode); - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) - public _FinalStage customTopicMode(Optional customTopicMode) { - this.customTopicMode = customTopicMode; - return this; - } - - /** - *

Detect topics throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage topics(Boolean topics) { - this.topics = Optional.ofNullable(topics); - return this; - } - - /** - *

Detect topics throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "topics", nulls = Nulls.SKIP) - public _FinalStage topics(Optional topics) { - this.topics = topics; - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { - this.summarize = Optional.ofNullable(summarize); - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - @java.lang.Override - @JsonSetter(value = "summarize", nulls = Nulls.SKIP) - public _FinalStage summarize(Optional summarize) { - this.summarize = summarize; - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sentiment(Boolean sentiment) { - this.sentiment = Optional.ofNullable(sentiment); - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) - public _FinalStage sentiment(Optional sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - *

HTTP method by which the callback request will be made

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - /** - *

HTTP method by which the callback request will be made

- */ - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - /** - *

URL to which we'll make the callback request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callback(String callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - /** - *

URL to which we'll make the callback request

- */ - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public _FinalStage search(String search) { - this.search = Optional.of(Collections.singletonList(search)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage search(List search) { - this.search = Optional.ofNullable(search); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional> search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage replace(String replace) { - this.replace = Optional.of(Collections.singletonList(replace)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage replace(List replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional> replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(String languageHint) { - this.languageHint = Optional.of(Collections.singletonList(languageHint)); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageHint(List languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional> languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage keywords(String keywords) { - this.keywords = Optional.of(Collections.singletonList(keywords)); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keywords(List keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional> keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(String keyterm) { - this.keyterm = Optional.of(Collections.singletonList(keyterm)); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keyterm(List keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional> keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage customIntent(String customIntent) { - this.customIntent = Optional.of(Collections.singletonList(customIntent)); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntent(List customIntent) { - this.customIntent = Optional.ofNullable(customIntent); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) - public _FinalStage customIntent(Optional> customIntent) { - this.customIntent = customIntent; - return this; - } - - @java.lang.Override - public _FinalStage customTopic(String customTopic) { - this.customTopic = Optional.of(Collections.singletonList(customTopic)); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopic(List customTopic) { - this.customTopic = Optional.ofNullable(customTopic); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) - public _FinalStage customTopic(Optional> customTopic) { - this.customTopic = customTopic; - return this; - } - - @java.lang.Override - public _FinalStage tag(String tag) { - this.tag = Optional.of(Collections.singletonList(tag)); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tag(List tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional> tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage extra(String extra) { - this.extra = Optional.of(Collections.singletonList(extra)); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage extra(List extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional> extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public ListenV1RequestUrl build() { - return new ListenV1RequestUrl( - extra, - tag, - customTopic, - customIntent, - keyterm, - keywords, - languageHint, - replace, - search, - callback, - callbackMethod, - sentiment, - summarize, - topics, - customTopicMode, - intents, - customIntentMode, - detectEntities, - detectLanguage, - diarize, - diarizeModel, - dictation, - encoding, - fillerWords, - language, - measurements, - model, - multichannel, - numerals, - paragraphs, - profanityFilter, - punctuate, - redact, - smartFormat, - utterances, - uttSplit, - version, - mipOptOut, - url, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java index 5008aca..3134856 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java +++ b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java @@ -697,11 +697,17 @@ public interface _FinalStage { /** *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

*/ - _FinalStage languageHint(Optional> languageHint); + default _FinalStage languageHint(Optional> languageHint) { + return this; + } - _FinalStage languageHint(List languageHint); + default _FinalStage languageHint(List languageHint) { + return this; + } - _FinalStage languageHint(String languageHint); + default _FinalStage languageHint(String languageHint) { + return this; + } /** *

Search for terms or phrases in submitted audio and replaces them

diff --git a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak b/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak deleted file mode 100644 index f094b06..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/media/requests/MediaTranscribeRequestOctetStream.java.bak +++ /dev/null @@ -1,1931 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.media.requests; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCallbackMethod; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomIntentMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestCustomTopicMode; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestDiarizeModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestEncoding; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestModel; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestSummarize; -import com.deepgram.resources.listen.v1.media.types.MediaTranscribeRequestVersion; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = MediaTranscribeRequestOctetStream.Builder.class) -public final class MediaTranscribeRequestOctetStream { - private final Optional> extra; - - private final Optional> tag; - - private final Optional> customTopic; - - private final Optional> customIntent; - - private final Optional> keyterm; - - private final Optional> keywords; - - private final Optional> languageHint; - - private final Optional> replace; - - private final Optional> search; - - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional sentiment; - - private final Optional summarize; - - private final Optional topics; - - private final Optional customTopicMode; - - private final Optional intents; - - private final Optional customIntentMode; - - private final Optional detectEntities; - - private final Optional detectLanguage; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional fillerWords; - - private final Optional language; - - private final Optional measurements; - - private final Optional model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional paragraphs; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional smartFormat; - - private final Optional utterances; - - private final Optional uttSplit; - - private final Optional version; - - private final Optional mipOptOut; - - private final byte[] body; - - private final Map additionalProperties; - - private MediaTranscribeRequestOctetStream( - Optional> extra, - Optional> tag, - Optional> customTopic, - Optional> customIntent, - Optional> keyterm, - Optional> keywords, - Optional> languageHint, - Optional> replace, - Optional> search, - Optional callback, - Optional callbackMethod, - Optional sentiment, - Optional summarize, - Optional topics, - Optional customTopicMode, - Optional intents, - Optional customIntentMode, - Optional detectEntities, - Optional detectLanguage, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional fillerWords, - Optional language, - Optional measurements, - Optional model, - Optional multichannel, - Optional numerals, - Optional paragraphs, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional smartFormat, - Optional utterances, - Optional uttSplit, - Optional version, - Optional mipOptOut, - byte[] body, - Map additionalProperties) { - this.extra = extra; - this.tag = tag; - this.customTopic = customTopic; - this.customIntent = customIntent; - this.keyterm = keyterm; - this.keywords = keywords; - this.languageHint = languageHint; - this.replace = replace; - this.search = search; - this.callback = callback; - this.callbackMethod = callbackMethod; - this.sentiment = sentiment; - this.summarize = summarize; - this.topics = topics; - this.customTopicMode = customTopicMode; - this.intents = intents; - this.customIntentMode = customIntentMode; - this.detectEntities = detectEntities; - this.detectLanguage = detectLanguage; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.fillerWords = fillerWords; - this.language = language; - this.measurements = measurements; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.paragraphs = paragraphs; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.smartFormat = smartFormat; - this.utterances = utterances; - this.uttSplit = uttSplit; - this.version = version; - this.mipOptOut = mipOptOut; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return Arbitrary key-value pairs that are attached to the API response for usage in downstream processing - */ - @JsonProperty("extra") - public Optional> getExtra() { - return extra; - } - - /** - * @return Label your requests for the purpose of identification during usage reporting - */ - @JsonProperty("tag") - public Optional> getTag() { - return tag; - } - - /** - * @return Custom topics you want the model to detect within your input audio or text if present Submit up to 100. - */ - @JsonProperty("custom_topic") - public Optional> getCustomTopic() { - return customTopic; - } - - /** - * @return Custom intents you want the model to detect within your input audio if present - */ - @JsonProperty("custom_intent") - public Optional> getCustomIntent() { - return customIntent; - } - - /** - * @return Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3. - *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @JsonProperty("keyterm") - public Optional> getKeyterm() { - return keyterm; - } - - /** - * @return Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead. - */ - @JsonProperty("keywords") - public Optional> getKeywords() { - return keywords; - } - - /** - * @return Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting. - */ - @JsonProperty("language_hint") - public Optional> getLanguageHint() { - return languageHint; - } - - /** - * @return Search for terms or phrases in submitted audio and replaces them - */ - @JsonProperty("replace") - public Optional> getReplace() { - return replace; - } - - /** - * @return Search for terms or phrases in submitted audio - */ - @JsonProperty("search") - public Optional> getSearch() { - return search; - } - - /** - * @return URL to which we'll make the callback request - */ - @JsonProperty("callback") - public Optional getCallback() { - return callback; - } - - /** - * @return HTTP method by which the callback request will be made - */ - @JsonProperty("callback_method") - public Optional getCallbackMethod() { - return callbackMethod; - } - - /** - * @return Recognizes the sentiment throughout a transcript or text - */ - @JsonProperty("sentiment") - public Optional getSentiment() { - return sentiment; - } - - /** - * @return Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only. - */ - @JsonProperty("summarize") - public Optional getSummarize() { - return summarize; - } - - /** - * @return Detect topics throughout a transcript or text - */ - @JsonProperty("topics") - public Optional getTopics() { - return topics; - } - - /** - * @return Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param - */ - @JsonProperty("custom_topic_mode") - public Optional getCustomTopicMode() { - return customTopicMode; - } - - /** - * @return Recognizes speaker intent throughout a transcript or text - */ - @JsonProperty("intents") - public Optional getIntents() { - return intents; - } - - /** - * @return Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param. - */ - @JsonProperty("custom_intent_mode") - public Optional getCustomIntentMode() { - return customIntentMode; - } - - /** - * @return Identifies and extracts key entities from content in submitted audio - */ - @JsonProperty("detect_entities") - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Identifies the dominant language spoken in submitted audio - */ - @JsonProperty("detect_language") - public Optional getDetectLanguage() { - return detectLanguage; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonProperty("diarize") - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests. - */ - @JsonProperty("diarize_model") - public Optional getDiarizeModel() { - return diarizeModel; - } - - /** - * @return Dictation mode for controlling formatting with dictated speech - */ - @JsonProperty("dictation") - public Optional getDictation() { - return dictation; - } - - /** - * @return Specify the expected encoding of your submitted audio - */ - @JsonProperty("encoding") - public Optional getEncoding() { - return encoding; - } - - /** - * @return Filler Words can help transcribe interruptions in your audio, like "uh" and "um" - */ - @JsonProperty("filler_words") - public Optional getFillerWords() { - return fillerWords; - } - - /** - * @return The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available - */ - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - /** - * @return Spoken measurements will be converted to their corresponding abbreviations - */ - @JsonProperty("measurements") - public Optional getMeasurements() { - return measurements; - } - - /** - * @return AI model used to process submitted audio - */ - @JsonProperty("model") - public Optional getModel() { - return model; - } - - /** - * @return Transcribe each audio channel independently - */ - @JsonProperty("multichannel") - public Optional getMultichannel() { - return multichannel; - } - - /** - * @return Numerals converts numbers from written format to numerical format - */ - @JsonProperty("numerals") - public Optional getNumerals() { - return numerals; - } - - /** - * @return Splits audio into paragraphs to improve transcript readability - */ - @JsonProperty("paragraphs") - public Optional getParagraphs() { - return paragraphs; - } - - /** - * @return Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely - */ - @JsonProperty("profanity_filter") - public Optional getProfanityFilter() { - return profanityFilter; - } - - /** - * @return Add punctuation and capitalization to the transcript - */ - @JsonProperty("punctuate") - public Optional getPunctuate() { - return punctuate; - } - - /** - * @return Redaction removes sensitive information from your transcripts - */ - @JsonProperty("redact") - public Optional getRedact() { - return redact; - } - - /** - * @return Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability - */ - @JsonProperty("smart_format") - public Optional getSmartFormat() { - return smartFormat; - } - - /** - * @return Segments speech into meaningful semantic units - */ - @JsonProperty("utterances") - public Optional getUtterances() { - return utterances; - } - - /** - * @return Seconds to wait before detecting a pause between words in submitted audio - */ - @JsonProperty("utt_split") - public Optional getUttSplit() { - return uttSplit; - } - - /** - * @return Version of an AI model to use - */ - @JsonProperty("version") - public Optional getVersion() { - return version; - } - - /** - * @return Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip - */ - @JsonProperty("mip_opt_out") - public Optional getMipOptOut() { - return mipOptOut; - } - - @JsonProperty("body") - public byte[] getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MediaTranscribeRequestOctetStream && equalTo((MediaTranscribeRequestOctetStream) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MediaTranscribeRequestOctetStream other) { - return extra.equals(other.extra) - && tag.equals(other.tag) - && customTopic.equals(other.customTopic) - && customIntent.equals(other.customIntent) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && languageHint.equals(other.languageHint) - && replace.equals(other.replace) - && search.equals(other.search) - && callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && sentiment.equals(other.sentiment) - && summarize.equals(other.summarize) - && topics.equals(other.topics) - && customTopicMode.equals(other.customTopicMode) - && intents.equals(other.intents) - && customIntentMode.equals(other.customIntentMode) - && detectEntities.equals(other.detectEntities) - && detectLanguage.equals(other.detectLanguage) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && fillerWords.equals(other.fillerWords) - && language.equals(other.language) - && measurements.equals(other.measurements) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && paragraphs.equals(other.paragraphs) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && smartFormat.equals(other.smartFormat) - && utterances.equals(other.utterances) - && uttSplit.equals(other.uttSplit) - && version.equals(other.version) - && mipOptOut.equals(other.mipOptOut) - && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.extra, - this.tag, - this.customTopic, - this.customIntent, - this.keyterm, - this.keywords, - this.languageHint, - this.replace, - this.search, - this.callback, - this.callbackMethod, - this.sentiment, - this.summarize, - this.topics, - this.customTopicMode, - this.intents, - this.customIntentMode, - this.detectEntities, - this.detectLanguage, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.fillerWords, - this.language, - this.measurements, - this.model, - this.multichannel, - this.numerals, - this.paragraphs, - this.profanityFilter, - this.punctuate, - this.redact, - this.smartFormat, - this.utterances, - this.uttSplit, - this.version, - this.mipOptOut, - this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static BodyStage builder() { - return new Builder(); - } - - public interface BodyStage { - _FinalStage body(@NotNull byte[] body); - - Builder from(MediaTranscribeRequestOctetStream other); - } - - public interface _FinalStage { - MediaTranscribeRequestOctetStream build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - _FinalStage extra(Optional> extra); - - _FinalStage extra(List extra); - - _FinalStage extra(String extra); - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - _FinalStage tag(Optional> tag); - - _FinalStage tag(List tag); - - _FinalStage tag(String tag); - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - _FinalStage customTopic(Optional> customTopic); - - _FinalStage customTopic(List customTopic); - - _FinalStage customTopic(String customTopic); - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - _FinalStage customIntent(Optional> customIntent); - - _FinalStage customIntent(List customIntent); - - _FinalStage customIntent(String customIntent); - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - _FinalStage keyterm(Optional> keyterm); - - _FinalStage keyterm(List keyterm); - - _FinalStage keyterm(String keyterm); - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - _FinalStage keywords(Optional> keywords); - - _FinalStage keywords(List keywords); - - _FinalStage keywords(String keywords); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional> languageHint) { - return this; - } - - default _FinalStage languageHint(List languageHint) { - return this; - } - - default _FinalStage languageHint(String languageHint) { - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - _FinalStage replace(Optional> replace); - - _FinalStage replace(List replace); - - _FinalStage replace(String replace); - - /** - *

Search for terms or phrases in submitted audio

- */ - _FinalStage search(Optional> search); - - _FinalStage search(List search); - - _FinalStage search(String search); - - /** - *

URL to which we'll make the callback request

- */ - _FinalStage callback(Optional callback); - - _FinalStage callback(String callback); - - /** - *

HTTP method by which the callback request will be made

- */ - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod); - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - _FinalStage sentiment(Optional sentiment); - - _FinalStage sentiment(Boolean sentiment); - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - _FinalStage summarize(Optional summarize); - - _FinalStage summarize(MediaTranscribeRequestSummarize summarize); - - /** - *

Detect topics throughout a transcript or text

- */ - _FinalStage topics(Optional topics); - - _FinalStage topics(Boolean topics); - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - _FinalStage customTopicMode(Optional customTopicMode); - - _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode); - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - _FinalStage intents(Optional intents); - - _FinalStage intents(Boolean intents); - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - _FinalStage customIntentMode(Optional customIntentMode); - - _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode); - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(Boolean detectEntities); - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - _FinalStage detectLanguage(Optional detectLanguage); - - _FinalStage detectLanguage(Boolean detectLanguage); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(Boolean diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel); - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(Boolean dictation); - - /** - *

Specify the expected encoding of your submitted audio

- */ - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(MediaTranscribeRequestEncoding encoding); - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - _FinalStage fillerWords(Optional fillerWords); - - _FinalStage fillerWords(Boolean fillerWords); - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - _FinalStage language(Optional language); - - _FinalStage language(String language); - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - _FinalStage measurements(Optional measurements); - - _FinalStage measurements(Boolean measurements); - - /** - *

AI model used to process submitted audio

- */ - _FinalStage model(Optional model); - - _FinalStage model(MediaTranscribeRequestModel model); - - /** - *

Transcribe each audio channel independently

- */ - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(Boolean multichannel); - - /** - *

Numerals converts numbers from written format to numerical format

- */ - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(Boolean numerals); - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - _FinalStage paragraphs(Optional paragraphs); - - _FinalStage paragraphs(Boolean paragraphs); - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(Boolean profanityFilter); - - /** - *

Add punctuation and capitalization to the transcript

- */ - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(Boolean punctuate); - - /** - *

Redaction removes sensitive information from your transcripts

- */ - _FinalStage redact(Optional redact); - - _FinalStage redact(String redact); - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(Boolean smartFormat); - - /** - *

Segments speech into meaningful semantic units

- */ - _FinalStage utterances(Optional utterances); - - _FinalStage utterances(Boolean utterances); - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - _FinalStage uttSplit(Optional uttSplit); - - _FinalStage uttSplit(Double uttSplit); - - /** - *

Version of an AI model to use

- */ - _FinalStage version(Optional version); - - _FinalStage version(MediaTranscribeRequestVersion version); - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(Boolean mipOptOut); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements BodyStage, _FinalStage { - private byte[] body; - - private Optional mipOptOut = Optional.empty(); - - private Optional version = Optional.empty(); - - private Optional uttSplit = Optional.empty(); - - private Optional utterances = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional paragraphs = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional model = Optional.empty(); - - private Optional measurements = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional fillerWords = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectLanguage = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional customIntentMode = Optional.empty(); - - private Optional intents = Optional.empty(); - - private Optional customTopicMode = Optional.empty(); - - private Optional topics = Optional.empty(); - - private Optional summarize = Optional.empty(); - - private Optional sentiment = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - private Optional> search = Optional.empty(); - - private Optional> replace = Optional.empty(); - - private Optional> languageHint = Optional.empty(); - - private Optional> keywords = Optional.empty(); - - private Optional> keyterm = Optional.empty(); - - private Optional> customIntent = Optional.empty(); - - private Optional> customTopic = Optional.empty(); - - private Optional> tag = Optional.empty(); - - private Optional> extra = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MediaTranscribeRequestOctetStream other) { - extra(other.getExtra()); - tag(other.getTag()); - customTopic(other.getCustomTopic()); - customIntent(other.getCustomIntent()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - languageHint(other.getLanguageHint()); - replace(other.getReplace()); - search(other.getSearch()); - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - sentiment(other.getSentiment()); - summarize(other.getSummarize()); - topics(other.getTopics()); - customTopicMode(other.getCustomTopicMode()); - intents(other.getIntents()); - customIntentMode(other.getCustomIntentMode()); - detectEntities(other.getDetectEntities()); - detectLanguage(other.getDetectLanguage()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - fillerWords(other.getFillerWords()); - language(other.getLanguage()); - measurements(other.getMeasurements()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - paragraphs(other.getParagraphs()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - smartFormat(other.getSmartFormat()); - utterances(other.getUtterances()); - uttSplit(other.getUttSplit()); - version(other.getVersion()); - mipOptOut(other.getMipOptOut()); - body(other.getBody()); - return this; - } - - @java.lang.Override - @JsonSetter("body") - public _FinalStage body(@NotNull byte[] body) { - this.body = Objects.requireNonNull(body, "body must not be null"); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage mipOptOut(Boolean mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - /** - *

Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

- */ - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - /** - *

Version of an AI model to use

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage version(MediaTranscribeRequestVersion version) { - this.version = Optional.ofNullable(version); - return this; - } - - /** - *

Version of an AI model to use

- */ - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage uttSplit(Double uttSplit) { - this.uttSplit = Optional.ofNullable(uttSplit); - return this; - } - - /** - *

Seconds to wait before detecting a pause between words in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "utt_split", nulls = Nulls.SKIP) - public _FinalStage uttSplit(Optional uttSplit) { - this.uttSplit = uttSplit; - return this; - } - - /** - *

Segments speech into meaningful semantic units

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage utterances(Boolean utterances) { - this.utterances = Optional.ofNullable(utterances); - return this; - } - - /** - *

Segments speech into meaningful semantic units

- */ - @java.lang.Override - @JsonSetter(value = "utterances", nulls = Nulls.SKIP) - public _FinalStage utterances(Optional utterances) { - this.utterances = utterances; - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage smartFormat(Boolean smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - /** - *

Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability

- */ - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage redact(String redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - /** - *

Redaction removes sensitive information from your transcripts

- */ - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage punctuate(Boolean punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - /** - *

Add punctuation and capitalization to the transcript

- */ - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profanityFilter(Boolean profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - /** - *

Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely

- */ - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage paragraphs(Boolean paragraphs) { - this.paragraphs = Optional.ofNullable(paragraphs); - return this; - } - - /** - *

Splits audio into paragraphs to improve transcript readability

- */ - @java.lang.Override - @JsonSetter(value = "paragraphs", nulls = Nulls.SKIP) - public _FinalStage paragraphs(Optional paragraphs) { - this.paragraphs = paragraphs; - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage numerals(Boolean numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - /** - *

Numerals converts numbers from written format to numerical format

- */ - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - /** - *

Transcribe each audio channel independently

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage multichannel(Boolean multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - /** - *

Transcribe each audio channel independently

- */ - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - /** - *

AI model used to process submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage model(MediaTranscribeRequestModel model) { - this.model = Optional.ofNullable(model); - return this; - } - - /** - *

AI model used to process submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public _FinalStage model(Optional model) { - this.model = model; - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage measurements(Boolean measurements) { - this.measurements = Optional.ofNullable(measurements); - return this; - } - - /** - *

Spoken measurements will be converted to their corresponding abbreviations

- */ - @java.lang.Override - @JsonSetter(value = "measurements", nulls = Nulls.SKIP) - public _FinalStage measurements(Optional measurements) { - this.measurements = measurements; - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage language(String language) { - this.language = Optional.ofNullable(language); - return this; - } - - /** - *

The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available

- */ - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fillerWords(Boolean fillerWords) { - this.fillerWords = Optional.ofNullable(fillerWords); - return this; - } - - /** - *

Filler Words can help transcribe interruptions in your audio, like "uh" and "um"

- */ - @java.lang.Override - @JsonSetter(value = "filler_words", nulls = Nulls.SKIP) - public _FinalStage fillerWords(Optional fillerWords) { - this.fillerWords = fillerWords; - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage encoding(MediaTranscribeRequestEncoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - /** - *

Specify the expected encoding of your submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage dictation(Boolean dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - /** - *

Dictation mode for controlling formatting with dictated speech

- */ - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(MediaTranscribeRequestDiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set the deprecated diarize=true parameter. For batch, supported values are latest (currently v2), v1, and v2. For streaming, supported values are latest (currently v1) and v1; v2 returns a validation error on streaming requests.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(Boolean diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectLanguage(Boolean detectLanguage) { - this.detectLanguage = Optional.ofNullable(detectLanguage); - return this; - } - - /** - *

Identifies the dominant language spoken in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_language", nulls = Nulls.SKIP) - public _FinalStage detectLanguage(Optional detectLanguage) { - this.detectLanguage = detectLanguage; - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage detectEntities(Boolean detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - /** - *

Identifies and extracts key entities from content in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntentMode(MediaTranscribeRequestCustomIntentMode customIntentMode) { - this.customIntentMode = Optional.ofNullable(customIntentMode); - return this; - } - - /** - *

Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in the custom_intent param.

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent_mode", nulls = Nulls.SKIP) - public _FinalStage customIntentMode(Optional customIntentMode) { - this.customIntentMode = customIntentMode; - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage intents(Boolean intents) { - this.intents = Optional.ofNullable(intents); - return this; - } - - /** - *

Recognizes speaker intent throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "intents", nulls = Nulls.SKIP) - public _FinalStage intents(Optional intents) { - this.intents = intents; - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopicMode(MediaTranscribeRequestCustomTopicMode customTopicMode) { - this.customTopicMode = Optional.ofNullable(customTopicMode); - return this; - } - - /** - *

Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic_mode", nulls = Nulls.SKIP) - public _FinalStage customTopicMode(Optional customTopicMode) { - this.customTopicMode = customTopicMode; - return this; - } - - /** - *

Detect topics throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage topics(Boolean topics) { - this.topics = Optional.ofNullable(topics); - return this; - } - - /** - *

Detect topics throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "topics", nulls = Nulls.SKIP) - public _FinalStage topics(Optional topics) { - this.topics = topics; - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage summarize(MediaTranscribeRequestSummarize summarize) { - this.summarize = Optional.ofNullable(summarize); - return this; - } - - /** - *

Summarize content. For Listen API, supports string version option. For Read API, accepts boolean only.

- */ - @java.lang.Override - @JsonSetter(value = "summarize", nulls = Nulls.SKIP) - public _FinalStage summarize(Optional summarize) { - this.summarize = summarize; - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sentiment(Boolean sentiment) { - this.sentiment = Optional.ofNullable(sentiment); - return this; - } - - /** - *

Recognizes the sentiment throughout a transcript or text

- */ - @java.lang.Override - @JsonSetter(value = "sentiment", nulls = Nulls.SKIP) - public _FinalStage sentiment(Optional sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - *

HTTP method by which the callback request will be made

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callbackMethod(MediaTranscribeRequestCallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - /** - *

HTTP method by which the callback request will be made

- */ - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - /** - *

URL to which we'll make the callback request

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage callback(String callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - /** - *

URL to which we'll make the callback request

- */ - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public _FinalStage search(String search) { - this.search = Optional.of(Collections.singletonList(search)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage search(List search) { - this.search = Optional.ofNullable(search); - return this; - } - - /** - *

Search for terms or phrases in submitted audio

- */ - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional> search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage replace(String replace) { - this.replace = Optional.of(Collections.singletonList(replace)); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage replace(List replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - /** - *

Search for terms or phrases in submitted audio and replaces them

- */ - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional> replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(String languageHint) { - this.languageHint = Optional.of(Collections.singletonList(languageHint)); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage languageHint(List languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Repeat the parameter to pass several codes, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list fails the request with HTTP 400. See Nova-3 Language Prompting.

- */ - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional> languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage keywords(String keywords) { - this.keywords = Optional.of(Collections.singletonList(keywords)); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keywords(List keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - /** - *

Keywords can boost or suppress specialized terminology and brands. keywords is not supported with Nova-3 models; use keyterm instead.

- */ - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional> keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(String keyterm) { - this.keyterm = Optional.of(Collections.singletonList(keyterm)); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage keyterm(List keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - /** - *

Key term prompting improves recognition of specialized terminology and brands. Only compatible with Nova-3.

- *

keyterm accepts plain terms only. Unlike the legacy keywords feature, it does not support weights or intensifiers. Appending one (for example, keyterm=term:0.15) is not rejected—the weight is silently ignored and the entire value is treated as a literal keyterm.

- *

To boost multiple separate keyterms, repeat the keyterm parameter (for example, keyterm=term1&keyterm=term2). To boost one multi-word phrase as a single keyterm, join the words with %20 or + (for example, keyterm=customer%20service). Do not separate keyterms with commas, semicolons, or line breaks.

- */ - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional> keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage customIntent(String customIntent) { - this.customIntent = Optional.of(Collections.singletonList(customIntent)); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customIntent(List customIntent) { - this.customIntent = Optional.ofNullable(customIntent); - return this; - } - - /** - *

Custom intents you want the model to detect within your input audio if present

- */ - @java.lang.Override - @JsonSetter(value = "custom_intent", nulls = Nulls.SKIP) - public _FinalStage customIntent(Optional> customIntent) { - this.customIntent = customIntent; - return this; - } - - @java.lang.Override - public _FinalStage customTopic(String customTopic) { - this.customTopic = Optional.of(Collections.singletonList(customTopic)); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTopic(List customTopic) { - this.customTopic = Optional.ofNullable(customTopic); - return this; - } - - /** - *

Custom topics you want the model to detect within your input audio or text if present Submit up to 100.

- */ - @java.lang.Override - @JsonSetter(value = "custom_topic", nulls = Nulls.SKIP) - public _FinalStage customTopic(Optional> customTopic) { - this.customTopic = customTopic; - return this; - } - - @java.lang.Override - public _FinalStage tag(String tag) { - this.tag = Optional.of(Collections.singletonList(tag)); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tag(List tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - /** - *

Label your requests for the purpose of identification during usage reporting

- */ - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional> tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage extra(String extra) { - this.extra = Optional.of(Collections.singletonList(extra)); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage extra(List extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - /** - *

Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

- */ - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional> extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public MediaTranscribeRequestOctetStream build() { - return new MediaTranscribeRequestOctetStream( - extra, - tag, - customTopic, - customIntent, - keyterm, - keywords, - languageHint, - replace, - search, - callback, - callbackMethod, - sentiment, - summarize, - topics, - customTopicMode, - intents, - customIntentMode, - detectEntities, - detectLanguage, - diarize, - diarizeModel, - dictation, - encoding, - fillerWords, - language, - measurements, - model, - multichannel, - numerals, - paragraphs, - profanityFilter, - punctuate, - redact, - smartFormat, - utterances, - uttSplit, - version, - mipOptOut, - body, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java index 7ac9aa5..878f85e 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java @@ -515,9 +515,13 @@ public interface _FinalStage { _FinalStage language(ListenV1Language language); - _FinalStage languageHint(Optional languageHint); + default _FinalStage languageHint(Optional languageHint) { + return this; + } - _FinalStage languageHint(ListenV1LanguageHint languageHint); + default _FinalStage languageHint(ListenV1LanguageHint languageHint) { + return this; + } _FinalStage mipOptOut(Optional mipOptOut); diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak deleted file mode 100644 index 2694721..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1ConnectOptions.java.bak +++ /dev/null @@ -1,1129 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.websocket; - -import com.deepgram.core.ObjectMappers; -import com.deepgram.resources.listen.v1.types.DiarizeModel; -import com.deepgram.types.ListenV1Callback; -import com.deepgram.types.ListenV1CallbackMethod; -import com.deepgram.types.ListenV1Channels; -import com.deepgram.types.ListenV1DetectEntities; -import com.deepgram.types.ListenV1Diarize; -import com.deepgram.types.ListenV1Dictation; -import com.deepgram.types.ListenV1Encoding; -import com.deepgram.types.ListenV1Endpointing; -import com.deepgram.types.ListenV1Extra; -import com.deepgram.types.ListenV1InterimResults; -import com.deepgram.types.ListenV1Keyterm; -import com.deepgram.types.ListenV1Keywords; -import com.deepgram.types.ListenV1Language; -import com.deepgram.types.ListenV1LanguageHint; -import com.deepgram.types.ListenV1MipOptOut; -import com.deepgram.types.ListenV1Model; -import com.deepgram.types.ListenV1Multichannel; -import com.deepgram.types.ListenV1Numerals; -import com.deepgram.types.ListenV1ProfanityFilter; -import com.deepgram.types.ListenV1Punctuate; -import com.deepgram.types.ListenV1Redact; -import com.deepgram.types.ListenV1Replace; -import com.deepgram.types.ListenV1SampleRate; -import com.deepgram.types.ListenV1Search; -import com.deepgram.types.ListenV1SmartFormat; -import com.deepgram.types.ListenV1Tag; -import com.deepgram.types.ListenV1UtteranceEndMs; -import com.deepgram.types.ListenV1VadEvents; -import com.deepgram.types.ListenV1Version; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = V1ConnectOptions.Builder.class) -public final class V1ConnectOptions { - private final Optional callback; - - private final Optional callbackMethod; - - private final Optional channels; - - private final Optional detectEntities; - - private final Optional diarize; - - private final Optional diarizeModel; - - private final Optional dictation; - - private final Optional encoding; - - private final Optional endpointing; - - private final Optional extra; - - private final Optional interimResults; - - private final Optional keyterm; - - private final Optional keywords; - - private final Optional language; - - private final Optional languageHint; - - private final Optional mipOptOut; - - private final ListenV1Model model; - - private final Optional multichannel; - - private final Optional numerals; - - private final Optional profanityFilter; - - private final Optional punctuate; - - private final Optional redact; - - private final Optional replace; - - private final Optional sampleRate; - - private final Optional search; - - private final Optional smartFormat; - - private final Optional tag; - - private final Optional utteranceEndMs; - - private final Optional vadEvents; - - private final Optional version; - - private final Map additionalProperties; - - private V1ConnectOptions( - Optional callback, - Optional callbackMethod, - Optional channels, - Optional detectEntities, - Optional diarize, - Optional diarizeModel, - Optional dictation, - Optional encoding, - Optional endpointing, - Optional extra, - Optional interimResults, - Optional keyterm, - Optional keywords, - Optional language, - Optional languageHint, - Optional mipOptOut, - ListenV1Model model, - Optional multichannel, - Optional numerals, - Optional profanityFilter, - Optional punctuate, - Optional redact, - Optional replace, - Optional sampleRate, - Optional search, - Optional smartFormat, - Optional tag, - Optional utteranceEndMs, - Optional vadEvents, - Optional version, - Map additionalProperties) { - this.callback = callback; - this.callbackMethod = callbackMethod; - this.channels = channels; - this.detectEntities = detectEntities; - this.diarize = diarize; - this.diarizeModel = diarizeModel; - this.dictation = dictation; - this.encoding = encoding; - this.endpointing = endpointing; - this.extra = extra; - this.interimResults = interimResults; - this.keyterm = keyterm; - this.keywords = keywords; - this.language = language; - this.languageHint = languageHint; - this.mipOptOut = mipOptOut; - this.model = model; - this.multichannel = multichannel; - this.numerals = numerals; - this.profanityFilter = profanityFilter; - this.punctuate = punctuate; - this.redact = redact; - this.replace = replace; - this.sampleRate = sampleRate; - this.search = search; - this.smartFormat = smartFormat; - this.tag = tag; - this.utteranceEndMs = utteranceEndMs; - this.vadEvents = vadEvents; - this.version = version; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("callback") - public Optional getCallback() { - return callback; - } - - @JsonProperty("callback_method") - public Optional getCallbackMethod() { - return callbackMethod; - } - - @JsonProperty("channels") - public Optional getChannels() { - return channels; - } - - @JsonProperty("detect_entities") - public Optional getDetectEntities() { - return detectEntities; - } - - /** - * @return Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0. - */ - @JsonProperty("diarize") - public Optional getDiarize() { - return diarize; - } - - /** - * @return Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error. - */ - @JsonProperty("diarize_model") - public Optional getDiarizeModel() { - return diarizeModel; - } - - @JsonProperty("dictation") - public Optional getDictation() { - return dictation; - } - - @JsonProperty("encoding") - public Optional getEncoding() { - return encoding; - } - - @JsonProperty("endpointing") - public Optional getEndpointing() { - return endpointing; - } - - @JsonProperty("extra") - public Optional getExtra() { - return extra; - } - - @JsonProperty("interim_results") - public Optional getInterimResults() { - return interimResults; - } - - @JsonProperty("keyterm") - public Optional getKeyterm() { - return keyterm; - } - - @JsonProperty("keywords") - public Optional getKeywords() { - return keywords; - } - - @JsonProperty("language") - public Optional getLanguage() { - return language; - } - - @JsonProperty("language_hint") - public Optional getLanguageHint() { - return languageHint; - } - - @JsonProperty("mip_opt_out") - public Optional getMipOptOut() { - return mipOptOut; - } - - /** - * @return AI model to use for the transcription - */ - @JsonProperty("model") - public ListenV1Model getModel() { - return model; - } - - @JsonProperty("multichannel") - public Optional getMultichannel() { - return multichannel; - } - - @JsonProperty("numerals") - public Optional getNumerals() { - return numerals; - } - - @JsonProperty("profanity_filter") - public Optional getProfanityFilter() { - return profanityFilter; - } - - @JsonProperty("punctuate") - public Optional getPunctuate() { - return punctuate; - } - - @JsonProperty("redact") - public Optional getRedact() { - return redact; - } - - @JsonProperty("replace") - public Optional getReplace() { - return replace; - } - - @JsonProperty("sample_rate") - public Optional getSampleRate() { - return sampleRate; - } - - @JsonProperty("search") - public Optional getSearch() { - return search; - } - - @JsonProperty("smart_format") - public Optional getSmartFormat() { - return smartFormat; - } - - @JsonProperty("tag") - public Optional getTag() { - return tag; - } - - @JsonProperty("utterance_end_ms") - public Optional getUtteranceEndMs() { - return utteranceEndMs; - } - - @JsonProperty("vad_events") - public Optional getVadEvents() { - return vadEvents; - } - - @JsonProperty("version") - public Optional getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof V1ConnectOptions && equalTo((V1ConnectOptions) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(V1ConnectOptions other) { - return callback.equals(other.callback) - && callbackMethod.equals(other.callbackMethod) - && channels.equals(other.channels) - && detectEntities.equals(other.detectEntities) - && diarize.equals(other.diarize) - && diarizeModel.equals(other.diarizeModel) - && dictation.equals(other.dictation) - && encoding.equals(other.encoding) - && endpointing.equals(other.endpointing) - && extra.equals(other.extra) - && interimResults.equals(other.interimResults) - && keyterm.equals(other.keyterm) - && keywords.equals(other.keywords) - && language.equals(other.language) - && languageHint.equals(other.languageHint) - && mipOptOut.equals(other.mipOptOut) - && model.equals(other.model) - && multichannel.equals(other.multichannel) - && numerals.equals(other.numerals) - && profanityFilter.equals(other.profanityFilter) - && punctuate.equals(other.punctuate) - && redact.equals(other.redact) - && replace.equals(other.replace) - && sampleRate.equals(other.sampleRate) - && search.equals(other.search) - && smartFormat.equals(other.smartFormat) - && tag.equals(other.tag) - && utteranceEndMs.equals(other.utteranceEndMs) - && vadEvents.equals(other.vadEvents) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.callback, - this.callbackMethod, - this.channels, - this.detectEntities, - this.diarize, - this.diarizeModel, - this.dictation, - this.encoding, - this.endpointing, - this.extra, - this.interimResults, - this.keyterm, - this.keywords, - this.language, - this.languageHint, - this.mipOptOut, - this.model, - this.multichannel, - this.numerals, - this.profanityFilter, - this.punctuate, - this.redact, - this.replace, - this.sampleRate, - this.search, - this.smartFormat, - this.tag, - this.utteranceEndMs, - this.vadEvents, - this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ModelStage builder() { - return new Builder(); - } - - public interface ModelStage { - /** - *

AI model to use for the transcription

- */ - _FinalStage model(@NotNull ListenV1Model model); - - Builder from(V1ConnectOptions other); - } - - public interface _FinalStage { - V1ConnectOptions build(); - - _FinalStage additionalProperty(String key, Object value); - - _FinalStage additionalProperties(Map additionalProperties); - - _FinalStage callback(Optional callback); - - _FinalStage callback(ListenV1Callback callback); - - _FinalStage callbackMethod(Optional callbackMethod); - - _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod); - - _FinalStage channels(Optional channels); - - _FinalStage channels(ListenV1Channels channels); - - _FinalStage detectEntities(Optional detectEntities); - - _FinalStage detectEntities(ListenV1DetectEntities detectEntities); - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - _FinalStage diarize(Optional diarize); - - _FinalStage diarize(ListenV1Diarize diarize); - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- */ - _FinalStage diarizeModel(Optional diarizeModel); - - _FinalStage diarizeModel(DiarizeModel diarizeModel); - - _FinalStage dictation(Optional dictation); - - _FinalStage dictation(ListenV1Dictation dictation); - - _FinalStage encoding(Optional encoding); - - _FinalStage encoding(ListenV1Encoding encoding); - - _FinalStage endpointing(Optional endpointing); - - _FinalStage endpointing(ListenV1Endpointing endpointing); - - _FinalStage extra(Optional extra); - - _FinalStage extra(ListenV1Extra extra); - - _FinalStage interimResults(Optional interimResults); - - _FinalStage interimResults(ListenV1InterimResults interimResults); - - _FinalStage keyterm(Optional keyterm); - - _FinalStage keyterm(ListenV1Keyterm keyterm); - - _FinalStage keywords(Optional keywords); - - _FinalStage keywords(ListenV1Keywords keywords); - - _FinalStage language(Optional language); - - _FinalStage language(ListenV1Language language); - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(Optional languageHint) { - return this; - } - - /** - *

Biases language detection toward one or more languages on Nova-3 multilingual (model=nova-3&language=multi); ignored with any other language. Hints bias detection and do not restrict it. A list is sent as repeated language_hint query parameters, for example language_hint=en&language_hint=es. A code that is not in the Nova-3 multilingual list rejects the WebSocket connection with HTTP 400. See Nova-3 Language Prompting.

- */ - default _FinalStage languageHint(ListenV1LanguageHint languageHint) { - return this; - } - - _FinalStage mipOptOut(Optional mipOptOut); - - _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut); - - _FinalStage multichannel(Optional multichannel); - - _FinalStage multichannel(ListenV1Multichannel multichannel); - - _FinalStage numerals(Optional numerals); - - _FinalStage numerals(ListenV1Numerals numerals); - - _FinalStage profanityFilter(Optional profanityFilter); - - _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter); - - _FinalStage punctuate(Optional punctuate); - - _FinalStage punctuate(ListenV1Punctuate punctuate); - - _FinalStage redact(Optional redact); - - _FinalStage redact(ListenV1Redact redact); - - _FinalStage replace(Optional replace); - - _FinalStage replace(ListenV1Replace replace); - - _FinalStage sampleRate(Optional sampleRate); - - _FinalStage sampleRate(ListenV1SampleRate sampleRate); - - _FinalStage search(Optional search); - - _FinalStage search(ListenV1Search search); - - _FinalStage smartFormat(Optional smartFormat); - - _FinalStage smartFormat(ListenV1SmartFormat smartFormat); - - _FinalStage tag(Optional tag); - - _FinalStage tag(ListenV1Tag tag); - - _FinalStage utteranceEndMs(Optional utteranceEndMs); - - _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs); - - _FinalStage vadEvents(Optional vadEvents); - - _FinalStage vadEvents(ListenV1VadEvents vadEvents); - - _FinalStage version(Optional version); - - _FinalStage version(ListenV1Version version); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ModelStage, _FinalStage { - private ListenV1Model model; - - private Optional version = Optional.empty(); - - private Optional vadEvents = Optional.empty(); - - private Optional utteranceEndMs = Optional.empty(); - - private Optional tag = Optional.empty(); - - private Optional smartFormat = Optional.empty(); - - private Optional search = Optional.empty(); - - private Optional sampleRate = Optional.empty(); - - private Optional replace = Optional.empty(); - - private Optional redact = Optional.empty(); - - private Optional punctuate = Optional.empty(); - - private Optional profanityFilter = Optional.empty(); - - private Optional numerals = Optional.empty(); - - private Optional multichannel = Optional.empty(); - - private Optional mipOptOut = Optional.empty(); - - private Optional languageHint = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional keywords = Optional.empty(); - - private Optional keyterm = Optional.empty(); - - private Optional interimResults = Optional.empty(); - - private Optional extra = Optional.empty(); - - private Optional endpointing = Optional.empty(); - - private Optional encoding = Optional.empty(); - - private Optional dictation = Optional.empty(); - - private Optional diarizeModel = Optional.empty(); - - private Optional diarize = Optional.empty(); - - private Optional detectEntities = Optional.empty(); - - private Optional channels = Optional.empty(); - - private Optional callbackMethod = Optional.empty(); - - private Optional callback = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(V1ConnectOptions other) { - callback(other.getCallback()); - callbackMethod(other.getCallbackMethod()); - channels(other.getChannels()); - detectEntities(other.getDetectEntities()); - diarize(other.getDiarize()); - diarizeModel(other.getDiarizeModel()); - dictation(other.getDictation()); - encoding(other.getEncoding()); - endpointing(other.getEndpointing()); - extra(other.getExtra()); - interimResults(other.getInterimResults()); - keyterm(other.getKeyterm()); - keywords(other.getKeywords()); - language(other.getLanguage()); - languageHint(other.getLanguageHint()); - mipOptOut(other.getMipOptOut()); - model(other.getModel()); - multichannel(other.getMultichannel()); - numerals(other.getNumerals()); - profanityFilter(other.getProfanityFilter()); - punctuate(other.getPunctuate()); - redact(other.getRedact()); - replace(other.getReplace()); - sampleRate(other.getSampleRate()); - search(other.getSearch()); - smartFormat(other.getSmartFormat()); - tag(other.getTag()); - utteranceEndMs(other.getUtteranceEndMs()); - vadEvents(other.getVadEvents()); - version(other.getVersion()); - return this; - } - - /** - *

AI model to use for the transcription

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("model") - public _FinalStage model(@NotNull ListenV1Model model) { - this.model = Objects.requireNonNull(model, "model must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage version(ListenV1Version version) { - this.version = Optional.ofNullable(version); - return this; - } - - @java.lang.Override - @JsonSetter(value = "version", nulls = Nulls.SKIP) - public _FinalStage version(Optional version) { - this.version = version; - return this; - } - - @java.lang.Override - public _FinalStage vadEvents(ListenV1VadEvents vadEvents) { - this.vadEvents = Optional.ofNullable(vadEvents); - return this; - } - - @java.lang.Override - @JsonSetter(value = "vad_events", nulls = Nulls.SKIP) - public _FinalStage vadEvents(Optional vadEvents) { - this.vadEvents = vadEvents; - return this; - } - - @java.lang.Override - public _FinalStage utteranceEndMs(ListenV1UtteranceEndMs utteranceEndMs) { - this.utteranceEndMs = Optional.ofNullable(utteranceEndMs); - return this; - } - - @java.lang.Override - @JsonSetter(value = "utterance_end_ms", nulls = Nulls.SKIP) - public _FinalStage utteranceEndMs(Optional utteranceEndMs) { - this.utteranceEndMs = utteranceEndMs; - return this; - } - - @java.lang.Override - public _FinalStage tag(ListenV1Tag tag) { - this.tag = Optional.ofNullable(tag); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public _FinalStage tag(Optional tag) { - this.tag = tag; - return this; - } - - @java.lang.Override - public _FinalStage smartFormat(ListenV1SmartFormat smartFormat) { - this.smartFormat = Optional.ofNullable(smartFormat); - return this; - } - - @java.lang.Override - @JsonSetter(value = "smart_format", nulls = Nulls.SKIP) - public _FinalStage smartFormat(Optional smartFormat) { - this.smartFormat = smartFormat; - return this; - } - - @java.lang.Override - public _FinalStage search(ListenV1Search search) { - this.search = Optional.ofNullable(search); - return this; - } - - @java.lang.Override - @JsonSetter(value = "search", nulls = Nulls.SKIP) - public _FinalStage search(Optional search) { - this.search = search; - return this; - } - - @java.lang.Override - public _FinalStage sampleRate(ListenV1SampleRate sampleRate) { - this.sampleRate = Optional.ofNullable(sampleRate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "sample_rate", nulls = Nulls.SKIP) - public _FinalStage sampleRate(Optional sampleRate) { - this.sampleRate = sampleRate; - return this; - } - - @java.lang.Override - public _FinalStage replace(ListenV1Replace replace) { - this.replace = Optional.ofNullable(replace); - return this; - } - - @java.lang.Override - @JsonSetter(value = "replace", nulls = Nulls.SKIP) - public _FinalStage replace(Optional replace) { - this.replace = replace; - return this; - } - - @java.lang.Override - public _FinalStage redact(ListenV1Redact redact) { - this.redact = Optional.ofNullable(redact); - return this; - } - - @java.lang.Override - @JsonSetter(value = "redact", nulls = Nulls.SKIP) - public _FinalStage redact(Optional redact) { - this.redact = redact; - return this; - } - - @java.lang.Override - public _FinalStage punctuate(ListenV1Punctuate punctuate) { - this.punctuate = Optional.ofNullable(punctuate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "punctuate", nulls = Nulls.SKIP) - public _FinalStage punctuate(Optional punctuate) { - this.punctuate = punctuate; - return this; - } - - @java.lang.Override - public _FinalStage profanityFilter(ListenV1ProfanityFilter profanityFilter) { - this.profanityFilter = Optional.ofNullable(profanityFilter); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profanity_filter", nulls = Nulls.SKIP) - public _FinalStage profanityFilter(Optional profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - @java.lang.Override - public _FinalStage numerals(ListenV1Numerals numerals) { - this.numerals = Optional.ofNullable(numerals); - return this; - } - - @java.lang.Override - @JsonSetter(value = "numerals", nulls = Nulls.SKIP) - public _FinalStage numerals(Optional numerals) { - this.numerals = numerals; - return this; - } - - @java.lang.Override - public _FinalStage multichannel(ListenV1Multichannel multichannel) { - this.multichannel = Optional.ofNullable(multichannel); - return this; - } - - @java.lang.Override - @JsonSetter(value = "multichannel", nulls = Nulls.SKIP) - public _FinalStage multichannel(Optional multichannel) { - this.multichannel = multichannel; - return this; - } - - @java.lang.Override - public _FinalStage mipOptOut(ListenV1MipOptOut mipOptOut) { - this.mipOptOut = Optional.ofNullable(mipOptOut); - return this; - } - - @java.lang.Override - @JsonSetter(value = "mip_opt_out", nulls = Nulls.SKIP) - public _FinalStage mipOptOut(Optional mipOptOut) { - this.mipOptOut = mipOptOut; - return this; - } - - @java.lang.Override - public _FinalStage languageHint(ListenV1LanguageHint languageHint) { - this.languageHint = Optional.ofNullable(languageHint); - return this; - } - - @java.lang.Override - @JsonSetter(value = "language_hint", nulls = Nulls.SKIP) - public _FinalStage languageHint(Optional languageHint) { - this.languageHint = languageHint; - return this; - } - - @java.lang.Override - public _FinalStage language(ListenV1Language language) { - this.language = Optional.ofNullable(language); - return this; - } - - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - @java.lang.Override - public _FinalStage keywords(ListenV1Keywords keywords) { - this.keywords = Optional.ofNullable(keywords); - return this; - } - - @java.lang.Override - @JsonSetter(value = "keywords", nulls = Nulls.SKIP) - public _FinalStage keywords(Optional keywords) { - this.keywords = keywords; - return this; - } - - @java.lang.Override - public _FinalStage keyterm(ListenV1Keyterm keyterm) { - this.keyterm = Optional.ofNullable(keyterm); - return this; - } - - @java.lang.Override - @JsonSetter(value = "keyterm", nulls = Nulls.SKIP) - public _FinalStage keyterm(Optional keyterm) { - this.keyterm = keyterm; - return this; - } - - @java.lang.Override - public _FinalStage interimResults(ListenV1InterimResults interimResults) { - this.interimResults = Optional.ofNullable(interimResults); - return this; - } - - @java.lang.Override - @JsonSetter(value = "interim_results", nulls = Nulls.SKIP) - public _FinalStage interimResults(Optional interimResults) { - this.interimResults = interimResults; - return this; - } - - @java.lang.Override - public _FinalStage extra(ListenV1Extra extra) { - this.extra = Optional.ofNullable(extra); - return this; - } - - @java.lang.Override - @JsonSetter(value = "extra", nulls = Nulls.SKIP) - public _FinalStage extra(Optional extra) { - this.extra = extra; - return this; - } - - @java.lang.Override - public _FinalStage endpointing(ListenV1Endpointing endpointing) { - this.endpointing = Optional.ofNullable(endpointing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "endpointing", nulls = Nulls.SKIP) - public _FinalStage endpointing(Optional endpointing) { - this.endpointing = endpointing; - return this; - } - - @java.lang.Override - public _FinalStage encoding(ListenV1Encoding encoding) { - this.encoding = Optional.ofNullable(encoding); - return this; - } - - @java.lang.Override - @JsonSetter(value = "encoding", nulls = Nulls.SKIP) - public _FinalStage encoding(Optional encoding) { - this.encoding = encoding; - return this; - } - - @java.lang.Override - public _FinalStage dictation(ListenV1Dictation dictation) { - this.dictation = Optional.ofNullable(dictation); - return this; - } - - @java.lang.Override - @JsonSetter(value = "dictation", nulls = Nulls.SKIP) - public _FinalStage dictation(Optional dictation) { - this.dictation = dictation; - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarizeModel(DiarizeModel diarizeModel) { - this.diarizeModel = Optional.ofNullable(diarizeModel); - return this; - } - - /** - *

Select and enable a specific diarization model version. Specifying this parameter enables diarization and selects the model — you do not need to also set diarize=true. Supported values for streaming: v1, latest. The v2 value is not supported on streaming and returns a validation error.

- */ - @java.lang.Override - @JsonSetter(value = "diarize_model", nulls = Nulls.SKIP) - public _FinalStage diarizeModel(Optional diarizeModel) { - this.diarizeModel = diarizeModel; - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage diarize(ListenV1Diarize diarize) { - this.diarize = Optional.ofNullable(diarize); - return this; - } - - /** - *

Deprecated: use diarize_model instead. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0.

- */ - @java.lang.Override - @JsonSetter(value = "diarize", nulls = Nulls.SKIP) - public _FinalStage diarize(Optional diarize) { - this.diarize = diarize; - return this; - } - - @java.lang.Override - public _FinalStage detectEntities(ListenV1DetectEntities detectEntities) { - this.detectEntities = Optional.ofNullable(detectEntities); - return this; - } - - @java.lang.Override - @JsonSetter(value = "detect_entities", nulls = Nulls.SKIP) - public _FinalStage detectEntities(Optional detectEntities) { - this.detectEntities = detectEntities; - return this; - } - - @java.lang.Override - public _FinalStage channels(ListenV1Channels channels) { - this.channels = Optional.ofNullable(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage callbackMethod(ListenV1CallbackMethod callbackMethod) { - this.callbackMethod = Optional.ofNullable(callbackMethod); - return this; - } - - @java.lang.Override - @JsonSetter(value = "callback_method", nulls = Nulls.SKIP) - public _FinalStage callbackMethod(Optional callbackMethod) { - this.callbackMethod = callbackMethod; - return this; - } - - @java.lang.Override - public _FinalStage callback(ListenV1Callback callback) { - this.callback = Optional.ofNullable(callback); - return this; - } - - @java.lang.Override - @JsonSetter(value = "callback", nulls = Nulls.SKIP) - public _FinalStage callback(Optional callback) { - this.callback = callback; - return this; - } - - @java.lang.Override - public V1ConnectOptions build() { - return new V1ConnectOptions( - callback, - callbackMethod, - channels, - detectEntities, - diarize, - diarizeModel, - dictation, - encoding, - endpointing, - extra, - interimResults, - keyterm, - keywords, - language, - languageHint, - mipOptOut, - model, - multichannel, - numerals, - profanityFilter, - punctuate, - redact, - replace, - sampleRate, - search, - smartFormat, - tag, - utteranceEndMs, - vadEvents, - version, - additionalProperties); - } - - @java.lang.Override - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - @java.lang.Override - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java index 9100a5b..da76d6a 100644 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java @@ -6,6 +6,7 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -148,8 +149,7 @@ public CompletableFuture connect(V1ConnectOptions options) { "endpointing", String.valueOf(options.getEndpointing().get())); } if (options.getExtra() != null && options.getExtra().isPresent()) { - urlBuilder.addQueryParameter( - "extra", String.valueOf(options.getExtra().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); } if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { urlBuilder.addQueryParameter( @@ -157,20 +157,18 @@ public CompletableFuture connect(V1ConnectOptions options) { String.valueOf(options.getInterimResults().get())); } if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - urlBuilder.addQueryParameter( - "keyterm", String.valueOf(options.getKeyterm().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); } if (options.getKeywords() != null && options.getKeywords().isPresent()) { - urlBuilder.addQueryParameter( - "keywords", String.valueOf(options.getKeywords().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); } if (options.getLanguage() != null && options.getLanguage().isPresent()) { urlBuilder.addQueryParameter( "language", String.valueOf(options.getLanguage().get())); } if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - urlBuilder.addQueryParameter( - "language_hint", String.valueOf(options.getLanguageHint().get())); + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); } if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { urlBuilder.addQueryParameter( @@ -203,23 +201,21 @@ public CompletableFuture connect(V1ConnectOptions options) { "redact_usage", String.valueOf(options.getRedactUsage().get())); } if (options.getReplace() != null && options.getReplace().isPresent()) { - urlBuilder.addQueryParameter( - "replace", String.valueOf(options.getReplace().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); } if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { urlBuilder.addQueryParameter( "sample_rate", String.valueOf(options.getSampleRate().get())); } if (options.getSearch() != null && options.getSearch().isPresent()) { - urlBuilder.addQueryParameter( - "search", String.valueOf(options.getSearch().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); } if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { urlBuilder.addQueryParameter( "smart_format", String.valueOf(options.getSmartFormat().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); } if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { urlBuilder.addQueryParameter( @@ -234,6 +230,13 @@ public CompletableFuture connect(V1ConnectOptions options) { urlBuilder.addQueryParameter( "version", String.valueOf(options.getVersion().get())); } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); final Request request = requestBuilder.build(); @@ -570,6 +573,8 @@ private void handleIncomingMessage(String json) { if (configureFailureHandlerEvent != null) { if (configureFailureHandler != null) { configureFailureHandler.accept(configureFailureHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); } return; } @@ -615,6 +620,8 @@ private void handleIncomingMessage(String json) { if (errorHandlerEvent != null) { if (errorHandler != null) { errorHandler.accept(errorHandlerEvent); + } else if (onErrorHandler != null) { + onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); } return; } diff --git a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index 885f60c..0000000 --- a/src/main/java/com/deepgram/resources/listen/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,650 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.listen.v1.types.ListenV1CloseStream; -import com.deepgram.resources.listen.v1.types.ListenV1Configure; -import com.deepgram.resources.listen.v1.types.ListenV1ConfigureFailure; -import com.deepgram.resources.listen.v1.types.ListenV1ConfigureSuccess; -import com.deepgram.resources.listen.v1.types.ListenV1Error; -import com.deepgram.resources.listen.v1.types.ListenV1Finalize; -import com.deepgram.resources.listen.v1.types.ListenV1KeepAlive; -import com.deepgram.resources.listen.v1.types.ListenV1Metadata; -import com.deepgram.resources.listen.v1.types.ListenV1Results; -import com.deepgram.resources.listen.v1.types.ListenV1SpeechStarted; -import com.deepgram.resources.listen.v1.types.ListenV1UtteranceEnd; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer resultsHandler; - - private volatile Consumer metadataHandler; - - private volatile Consumer utteranceEndHandler; - - private volatile Consumer speechStartedHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V1ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v1/listen"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - if (options.getCallback() != null && options.getCallback().isPresent()) { - urlBuilder.addQueryParameter( - "callback", String.valueOf(options.getCallback().get())); - } - if (options.getCallbackMethod() != null && options.getCallbackMethod().isPresent()) { - urlBuilder.addQueryParameter( - "callback_method", - String.valueOf(options.getCallbackMethod().get())); - } - if (options.getChannels() != null && options.getChannels().isPresent()) { - urlBuilder.addQueryParameter( - "channels", String.valueOf(options.getChannels().get())); - } - if (options.getDetectEntities() != null && options.getDetectEntities().isPresent()) { - urlBuilder.addQueryParameter( - "detect_entities", - String.valueOf(options.getDetectEntities().get())); - } - if (options.getDiarize() != null && options.getDiarize().isPresent()) { - urlBuilder.addQueryParameter( - "diarize", String.valueOf(options.getDiarize().get())); - } - if (options.getDiarizeModel() != null && options.getDiarizeModel().isPresent()) { - urlBuilder.addQueryParameter( - "diarize_model", String.valueOf(options.getDiarizeModel().get())); - } - if (options.getDictation() != null && options.getDictation().isPresent()) { - urlBuilder.addQueryParameter( - "dictation", String.valueOf(options.getDictation().get())); - } - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getEndpointing() != null && options.getEndpointing().isPresent()) { - urlBuilder.addQueryParameter( - "endpointing", String.valueOf(options.getEndpointing().get())); - } - if (options.getExtra() != null && options.getExtra().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "extra", options.getExtra().get().get(), true); - } - if (options.getInterimResults() != null && options.getInterimResults().isPresent()) { - urlBuilder.addQueryParameter( - "interim_results", - String.valueOf(options.getInterimResults().get())); - } - if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keyterm", options.getKeyterm().get().get(), true); - } - if (options.getKeywords() != null && options.getKeywords().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "keywords", options.getKeywords().get().get(), true); - } - if (options.getLanguage() != null && options.getLanguage().isPresent()) { - urlBuilder.addQueryParameter( - "language", String.valueOf(options.getLanguage().get())); - } - if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getMultichannel() != null && options.getMultichannel().isPresent()) { - urlBuilder.addQueryParameter( - "multichannel", String.valueOf(options.getMultichannel().get())); - } - if (options.getNumerals() != null && options.getNumerals().isPresent()) { - urlBuilder.addQueryParameter( - "numerals", String.valueOf(options.getNumerals().get())); - } - if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { - urlBuilder.addQueryParameter( - "profanity_filter", - String.valueOf(options.getProfanityFilter().get())); - } - if (options.getPunctuate() != null && options.getPunctuate().isPresent()) { - urlBuilder.addQueryParameter( - "punctuate", String.valueOf(options.getPunctuate().get())); - } - if (options.getRedact() != null && options.getRedact().isPresent()) { - urlBuilder.addQueryParameter( - "redact", String.valueOf(options.getRedact().get())); - } - if (options.getReplace() != null && options.getReplace().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "replace", options.getReplace().get().get(), true); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSearch() != null && options.getSearch().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "search", options.getSearch().get().get(), true); - } - if (options.getSmartFormat() != null && options.getSmartFormat().isPresent()) { - urlBuilder.addQueryParameter( - "smart_format", String.valueOf(options.getSmartFormat().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getUtteranceEndMs() != null && options.getUtteranceEndMs().isPresent()) { - urlBuilder.addQueryParameter( - "utterance_end_ms", - String.valueOf(options.getUtteranceEndMs().get())); - } - if (options.getVadEvents() != null && options.getVadEvents().isPresent()) { - urlBuilder.addQueryParameter( - "vad_events", String.valueOf(options.getVadEvents().get())); - } - if (options.getVersion() != null && options.getVersion().isPresent()) { - urlBuilder.addQueryParameter( - "version", String.valueOf(options.getVersion().get())); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a ListenV1Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Sends a ListenV1Finalize message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFinalize(ListenV1Finalize message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1CloseStream message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCloseStream(ListenV1CloseStream message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1KeepAlive message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendKeepAlive(ListenV1KeepAlive message) { - return sendMessage(message); - } - - /** - * Sends a ListenV1Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(ListenV1Configure message) { - return sendMessage(message); - } - - /** - * Registers a handler for ListenV1ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for ListenV1ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for ListenV1Results messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onResults(Consumer handler) { - this.resultsHandler = handler; - } - - /** - * Registers a handler for ListenV1Metadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onMetadata(Consumer handler) { - this.metadataHandler = handler; - } - - /** - * Registers a handler for ListenV1UtteranceEnd messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onUtteranceEnd(Consumer handler) { - this.utteranceEndHandler = handler; - } - - /** - * Registers a handler for ListenV1SpeechStarted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechStarted(Consumer handler) { - this.speechStartedHandler = handler; - } - - /** - * Registers a handler for ListenV1Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("transaction_key") - && node.has("request_id") - && node.has("sha256") - && node.has("created") - && node.has("duration") - && node.has("channels") - && "Metadata".equals(node.path("type").asText())) { - ListenV1Metadata metadataHandlerEvent = null; - try { - metadataHandlerEvent = objectMapper.treeToValue(node, ListenV1Metadata.class); - } catch (Exception e) { - } - if (metadataHandlerEvent != null) { - if (metadataHandler != null) { - metadataHandler.accept(metadataHandlerEvent); - } - return; - } - } - if (node.has("channel_index") - && node.has("duration") - && node.has("start") - && node.has("channel") - && node.has("metadata") - && "Results".equals(node.path("type").asText())) { - ListenV1Results resultsHandlerEvent = null; - try { - resultsHandlerEvent = objectMapper.treeToValue(node, ListenV1Results.class); - } catch (Exception e) { - } - if (resultsHandlerEvent != null) { - if (resultsHandler != null) { - resultsHandler.accept(resultsHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("code") - && node.has("description") - && "ConfigureFailure".equals(node.path("type").asText())) { - ListenV1ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ConfigureFailureException(configureFailureHandlerEvent)); - } - return; - } - } - if (node.has("channel") - && node.has("last_word_end") - && "UtteranceEnd".equals(node.path("type").asText())) { - ListenV1UtteranceEnd utteranceEndHandlerEvent = null; - try { - utteranceEndHandlerEvent = objectMapper.treeToValue(node, ListenV1UtteranceEnd.class); - } catch (Exception e) { - } - if (utteranceEndHandlerEvent != null) { - if (utteranceEndHandler != null) { - utteranceEndHandler.accept(utteranceEndHandlerEvent); - } - return; - } - } - if (node.has("channel") - && node.has("timestamp") - && "SpeechStarted".equals(node.path("type").asText())) { - ListenV1SpeechStarted speechStartedHandlerEvent = null; - try { - speechStartedHandlerEvent = objectMapper.treeToValue(node, ListenV1SpeechStarted.class); - } catch (Exception e) { - } - if (speechStartedHandlerEvent != null) { - if (speechStartedHandler != null) { - speechStartedHandler.accept(speechStartedHandlerEvent); - } - return; - } - } - if (node.has("variant") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - ListenV1Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, ListenV1Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } else if (onErrorHandler != null) { - onErrorHandler.accept(new ListenV1ErrorException(errorHandlerEvent)); - } - return; - } - } - if (node.has("request_id") - && "ConfigureSuccess".equals(node.path("type").asText())) { - ListenV1ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV1ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java index e6308e2..c9f2f35 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof ListenV2CloseStream; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak deleted file mode 100644 index c9f2f35..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2CloseStream.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV2CloseStream.Builder.class) -public final class ListenV2CloseStream { - private final Map additionalProperties; - - private ListenV2CloseStream(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "CloseStream"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV2CloseStream; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListenV2CloseStream other) { - return this; - } - - public ListenV2CloseStream build() { - return new ListenV2CloseStream(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java index c3dbd38..894bd3c 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java +++ b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof ListenV2ForceEndTurn; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak b/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak deleted file mode 100644 index 894bd3c..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/types/ListenV2ForceEndTurn.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = ListenV2ForceEndTurn.Builder.class) -public final class ListenV2ForceEndTurn { - private final Map additionalProperties; - - private ListenV2ForceEndTurn(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "ForceEndTurn"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListenV2ForceEndTurn; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListenV2ForceEndTurn other) { - return this; - } - - public ListenV2ForceEndTurn build() { - return new ListenV2ForceEndTurn(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java index d2cc476..b13abba 100644 --- a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java @@ -6,6 +6,7 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -22,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; @@ -59,6 +61,8 @@ public class V2WebSocketClient implements AutoCloseable { private ReconnectingWebSocketListener reconnectingListener; + private final AtomicReference closeStreamSocket = new AtomicReference<>(); + private volatile Consumer connectedHandler; private volatile Consumer turnInfoHandler; @@ -87,6 +91,7 @@ public V2WebSocketClient(ClientOptions clientOptions) { */ public CompletableFuture connect(V2ConnectOptions options) { connectionFuture = new CompletableFuture<>(); + closeStreamSocket.set(null); String baseUrl = clientOptions.environment().getProductionURL(); String fullPath = "/v2/listen"; if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { @@ -129,12 +134,12 @@ public CompletableFuture connect(V2ConnectOptions options) { "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); } if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - urlBuilder.addQueryParameter( - "keyterm", String.valueOf(options.getKeyterm().get())); + QueryStringMapper.addQueryParameter( + urlBuilder, "keyterm", options.getKeyterm().get().get(), true); } if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - urlBuilder.addQueryParameter( - "language_hint", String.valueOf(options.getLanguageHint().get())); + QueryStringMapper.addQueryParameter( + urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); } if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { urlBuilder.addQueryParameter( @@ -158,7 +163,14 @@ public CompletableFuture connect(V2ConnectOptions options) { "mip_opt_out", String.valueOf(options.getMipOptOut().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); @@ -186,6 +198,7 @@ public CompletableFuture connect(V2ConnectOptions options) { clientOptions::isClosed) { @Override protected void onWebSocketOpen(WebSocket webSocket, Response response) { + closeStreamSocket.set(null); readyState = WebSocketReadyState.OPEN; if (onConnectedHandler != null) { onConnectedHandler.run(); @@ -217,6 +230,12 @@ protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { onDisconnectedHandler.accept(new DisconnectReason(code, reason)); } } + + @Override + protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { + return super.shouldReconnectAfterClose(webSocket, code, reason) + && (code != 1005 || closeStreamSocket.get() != webSocket); + } }; clientOptions.registerWebSocket(this); reconnectingListener.connect(); @@ -267,12 +286,13 @@ public CompletableFuture sendMedia(ByteString message) { } /** - * Sends a ListenV2CloseStream message to the server asynchronously. + * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does + * not suppress reconnects because it might never reach the server. * @param message the message to send * @return a CompletableFuture that completes when the message is sent */ public CompletableFuture sendCloseStream(ListenV2CloseStream message) { - return sendMessage(message); + return sendMessage(message, closeStreamSocket::set); } /** @@ -406,12 +426,16 @@ private void assertSocketIsOpen() { } private CompletableFuture sendMessage(Object body) { + return sendMessage(body, null); + } + + private CompletableFuture sendMessage(Object body, Consumer onSent) { CompletableFuture future = new CompletableFuture<>(); try { assertSocketIsOpen(); String json = objectMapper.writeValueAsString(body); // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); + reconnectingListener.send(json, onSent); future.complete(null); } catch (IllegalStateException e) { future.completeExceptionally(e); @@ -532,11 +556,8 @@ private void handleIncomingMessage(String json) { return; } } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. } catch (Exception e) { if (onErrorHandler != null) { onErrorHandler.accept(e); diff --git a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak deleted file mode 100644 index 5f55fea..0000000 --- a/src/main/java/com/deepgram/resources/listen/v2/websocket/V2WebSocketClient.java.bak +++ /dev/null @@ -1,563 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.listen.v2.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.listen.v2.types.ListenV2CloseStream; -import com.deepgram.resources.listen.v2.types.ListenV2Configure; -import com.deepgram.resources.listen.v2.types.ListenV2ConfigureFailure; -import com.deepgram.resources.listen.v2.types.ListenV2ConfigureSuccess; -import com.deepgram.resources.listen.v2.types.ListenV2Connected; -import com.deepgram.resources.listen.v2.types.ListenV2FatalError; -import com.deepgram.resources.listen.v2.types.ListenV2ForceEndTurn; -import com.deepgram.resources.listen.v2.types.ListenV2TurnInfo; -import com.deepgram.resources.listen.v2.types.ListenV2Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v2 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V2WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private final AtomicReference closeStreamSocket = new AtomicReference<>(); - - private volatile Consumer connectedHandler; - - private volatile Consumer turnInfoHandler; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v2 channel. - */ - public V2WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V2ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - closeStreamSocket.set(null); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v2/listen"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getEagerEotThreshold() != null - && options.getEagerEotThreshold().isPresent()) { - urlBuilder.addQueryParameter( - "eager_eot_threshold", - String.valueOf(options.getEagerEotThreshold().get())); - } - if (options.getEotThreshold() != null && options.getEotThreshold().isPresent()) { - urlBuilder.addQueryParameter( - "eot_threshold", String.valueOf(options.getEotThreshold().get())); - } - if (options.getEotTimeoutMs() != null && options.getEotTimeoutMs().isPresent()) { - urlBuilder.addQueryParameter( - "eot_timeout_ms", String.valueOf(options.getEotTimeoutMs().get())); - } - if (options.getKeyterm() != null && options.getKeyterm().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "keyterm", options.getKeyterm().get().get(), true); - } - if (options.getLanguageHint() != null && options.getLanguageHint().isPresent()) { - QueryStringMapper.addQueryParameter( - urlBuilder, "language_hint", options.getLanguageHint().get().get(), true); - } - if (options.getProfanityFilter() != null && options.getProfanityFilter().isPresent()) { - urlBuilder.addQueryParameter( - "profanity_filter", - String.valueOf(options.getProfanityFilter().get())); - } - if (options.getNumerals() != null && options.getNumerals().isPresent()) { - urlBuilder.addQueryParameter( - "numerals", String.valueOf(options.getNumerals().get())); - } - if (options.getRedact() != null && options.getRedact().isPresent()) { - urlBuilder.addQueryParameter( - "redact", String.valueOf(options.getRedact().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - closeStreamSocket.set(null); - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) {} - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - - @Override - protected boolean shouldReconnectAfterClose(WebSocket webSocket, int code, String reason) { - return super.shouldReconnectAfterClose(webSocket, code, reason) - && (code != 1005 || closeStreamSocket.get() != webSocket); - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a ListenV2Media message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendMedia(ByteString message) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - // Use reconnecting listener's sendBinary method which handles queuing - reconnectingListener.sendBinary(message); - future.complete(null); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send binary data", e)); - } - return future; - } - - /** - * Sends a ListenV2CloseStream message to the server asynchronously. A queued CloseStream does - * not suppress reconnects because it might never reach the server. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendCloseStream(ListenV2CloseStream message) { - return sendMessage(message, closeStreamSocket::set); - } - - /** - * Sends a ListenV2ForceEndTurn message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendForceEndTurn(ListenV2ForceEndTurn message) { - return sendMessage(message); - } - - /** - * Sends a ListenV2Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(ListenV2Configure message) { - return sendMessage(message); - } - - /** - * Registers a handler for ListenV2Connected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConnected(Consumer handler) { - this.connectedHandler = handler; - } - - /** - * Registers a handler for ListenV2TurnInfo messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onTurnInfo(Consumer handler) { - this.turnInfoHandler = handler; - } - - /** - * Registers a handler for ListenV2ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for ListenV2ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for ListenV2Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for ListenV2FatalError messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - return sendMessage(body, null); - } - - private CompletableFuture sendMessage(Object body, Consumer onSent) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json, onSent); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("request_id") - && node.has("sequence_id") - && node.has("event") - && node.has("turn_index") - && node.has("audio_window_start") - && node.has("audio_window_end") - && node.has("transcript") - && node.has("words") - && node.has("end_of_turn_confidence") - && "TurnInfo".equals(node.path("type").asText())) { - ListenV2TurnInfo turnInfoHandlerEvent = null; - try { - turnInfoHandlerEvent = objectMapper.treeToValue(node, ListenV2TurnInfo.class); - } catch (Exception e) { - } - if (turnInfoHandlerEvent != null) { - if (turnInfoHandler != null) { - turnInfoHandler.accept(turnInfoHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("thresholds") - && node.has("keyterms") - && node.has("sequence_id") - && "ConfigureSuccess".equals(node.path("type").asText())) { - ListenV2ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && node.has("code") - && node.has("description") - && "Warning".equals(node.path("type").asText())) { - ListenV2Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, ListenV2Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("sequence_id") - && node.has("code") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - ListenV2FatalError errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, ListenV2FatalError.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && "Connected".equals(node.path("type").asText())) { - ListenV2Connected connectedHandlerEvent = null; - try { - connectedHandlerEvent = objectMapper.treeToValue(node, ListenV2Connected.class); - } catch (Exception e) { - } - if (connectedHandlerEvent != null) { - if (connectedHandler != null) { - connectedHandler.accept(connectedHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("sequence_id") - && "ConfigureFailure".equals(node.path("type").asText())) { - ListenV2ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, ListenV2ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } - return; - } - } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java index 6dd298a..e6824a3 100644 --- a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java @@ -6,6 +6,7 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -122,6 +123,13 @@ public CompletableFuture connect(V1ConnectOptions options) { urlBuilder.addQueryParameter( "speed", String.valueOf(options.getSpeed().get())); } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); + } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); final Request request = requestBuilder.build(); diff --git a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak deleted file mode 100644 index e6824a3..0000000 --- a/src/main/java/com/deepgram/resources/speak/v1/websocket/V1WebSocketClient.java.bak +++ /dev/null @@ -1,467 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v1.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.speak.v1.types.SpeakV1Clear; -import com.deepgram.resources.speak.v1.types.SpeakV1Cleared; -import com.deepgram.resources.speak.v1.types.SpeakV1Close; -import com.deepgram.resources.speak.v1.types.SpeakV1Flush; -import com.deepgram.resources.speak.v1.types.SpeakV1Flushed; -import com.deepgram.resources.speak.v1.types.SpeakV1Metadata; -import com.deepgram.resources.speak.v1.types.SpeakV1Text; -import com.deepgram.resources.speak.v1.types.SpeakV1Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v1 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V1WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer speakV1AudioHandler; - - private volatile Consumer metadataHandler; - - private volatile Consumer flushedHandler; - - private volatile Consumer clearedHandler; - - private volatile Consumer warningHandler; - - /** - * Creates a new async WebSocket client for the v1 channel. - */ - public V1WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V1ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v1/speak"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getModel() != null && options.getModel().isPresent()) { - urlBuilder.addQueryParameter( - "model", String.valueOf(options.getModel().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSpeed() != null && options.getSpeed().isPresent()) { - urlBuilder.addQueryParameter( - "speed", String.valueOf(options.getSpeed().get())); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (speakV1AudioHandler != null) { - speakV1AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Establishes the WebSocket connection asynchronously with default options. - * @return a CompletableFuture that completes when the connection is established - */ - public CompletableFuture connect() { - return connect(V1ConnectOptions.builder().build()); - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a SpeakV1Text message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendText(SpeakV1Text message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Flush message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFlush(SpeakV1Flush message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Clear message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClear(SpeakV1Clear message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV1Close message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClose(SpeakV1Close message) { - return sendMessage(message); - } - - /** - * Registers a handler for SpeakV1Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakV1Audio(Consumer handler) { - this.speakV1AudioHandler = handler; - } - - /** - * Registers a handler for SpeakV1Metadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onMetadata(Consumer handler) { - this.metadataHandler = handler; - } - - /** - * Registers a handler for SpeakV1Flushed messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFlushed(Consumer handler) { - this.flushedHandler = handler; - } - - /** - * Registers a handler for SpeakV1Cleared messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onCleared(Consumer handler) { - this.clearedHandler = handler; - } - - /** - * Registers a handler for SpeakV1Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("request_id") - && node.has("model_name") - && node.has("model_version") - && node.has("model_uuid") - && "Metadata".equals(node.path("type").asText())) { - SpeakV1Metadata metadataHandlerEvent = null; - try { - metadataHandlerEvent = objectMapper.treeToValue(node, SpeakV1Metadata.class); - } catch (Exception e) { - } - if (metadataHandlerEvent != null) { - if (metadataHandler != null) { - metadataHandler.accept(metadataHandlerEvent); - } - return; - } - } - if (node.has("description") - && node.has("code") - && "Warning".equals(node.path("type").asText())) { - SpeakV1Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, SpeakV1Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("type") && node.has("sequence_id")) { - SpeakV1Flushed flushedHandlerEvent = null; - try { - flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Flushed.class); - } catch (Exception e) { - } - if (flushedHandlerEvent != null) { - if (flushedHandler != null) { - flushedHandler.accept(flushedHandlerEvent); - } - return; - } - } - if (node.has("type") && node.has("sequence_id")) { - SpeakV1Cleared clearedHandlerEvent = null; - try { - clearedHandlerEvent = objectMapper.treeToValue(node, SpeakV1Cleared.class); - } catch (Exception e) { - } - if (clearedHandlerEvent != null) { - if (clearedHandler != null) { - clearedHandler.accept(clearedHandlerEvent); - } - return; - } - } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java index 2e96a5c..7fecd79 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof SpeakV2Close; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak deleted file mode 100644 index 7fecd79..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Close.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SpeakV2Close.Builder.class) -public final class SpeakV2Close { - private final Map additionalProperties; - - private SpeakV2Close(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "Close"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SpeakV2Close; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SpeakV2Close other) { - return this; - } - - public SpeakV2Close build() { - return new SpeakV2Close(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java index 63ec45a..f678e97 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java @@ -110,7 +110,9 @@ public interface Visitor { T visitSpeedNotSupported(); - T visitControlCombinationInvalid(); + default T visitControlCombinationInvalid() { + return visitUnknown("CONTROL_COMBINATION_INVALID"); + } T visitInternalError(); diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak deleted file mode 100644 index f678e97..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2ConfigureFailureCode.java.bak +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class SpeakV2ConfigureFailureCode { - public static final SpeakV2ConfigureFailureCode CONTROL_COMBINATION_INVALID = - new SpeakV2ConfigureFailureCode(Value.CONTROL_COMBINATION_INVALID, "CONTROL_COMBINATION_INVALID"); - - public static final SpeakV2ConfigureFailureCode SPEED_OUT_OF_RANGE = - new SpeakV2ConfigureFailureCode(Value.SPEED_OUT_OF_RANGE, "SPEED_OUT_OF_RANGE"); - - public static final SpeakV2ConfigureFailureCode SPEED_INCREMENT_INVALID = - new SpeakV2ConfigureFailureCode(Value.SPEED_INCREMENT_INVALID, "SPEED_INCREMENT_INVALID"); - - public static final SpeakV2ConfigureFailureCode INTERNAL_ERROR = - new SpeakV2ConfigureFailureCode(Value.INTERNAL_ERROR, "INTERNAL_ERROR"); - - public static final SpeakV2ConfigureFailureCode SPEED_NOT_SUPPORTED = - new SpeakV2ConfigureFailureCode(Value.SPEED_NOT_SUPPORTED, "SPEED_NOT_SUPPORTED"); - - private final Value value; - - private final String string; - - SpeakV2ConfigureFailureCode(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof SpeakV2ConfigureFailureCode - && this.string.equals(((SpeakV2ConfigureFailureCode) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case CONTROL_COMBINATION_INVALID: - return visitor.visitControlCombinationInvalid(); - case SPEED_OUT_OF_RANGE: - return visitor.visitSpeedOutOfRange(); - case SPEED_INCREMENT_INVALID: - return visitor.visitSpeedIncrementInvalid(); - case INTERNAL_ERROR: - return visitor.visitInternalError(); - case SPEED_NOT_SUPPORTED: - return visitor.visitSpeedNotSupported(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static SpeakV2ConfigureFailureCode valueOf(String value) { - switch (value) { - case "CONTROL_COMBINATION_INVALID": - return CONTROL_COMBINATION_INVALID; - case "SPEED_OUT_OF_RANGE": - return SPEED_OUT_OF_RANGE; - case "SPEED_INCREMENT_INVALID": - return SPEED_INCREMENT_INVALID; - case "INTERNAL_ERROR": - return INTERNAL_ERROR; - case "SPEED_NOT_SUPPORTED": - return SPEED_NOT_SUPPORTED; - default: - return new SpeakV2ConfigureFailureCode(Value.UNKNOWN, value); - } - } - - public enum Value { - SPEED_OUT_OF_RANGE, - - SPEED_INCREMENT_INVALID, - - SPEED_NOT_SUPPORTED, - - CONTROL_COMBINATION_INVALID, - - INTERNAL_ERROR, - - UNKNOWN - } - - public interface Visitor { - T visitSpeedOutOfRange(); - - T visitSpeedIncrementInvalid(); - - T visitSpeedNotSupported(); - - default T visitControlCombinationInvalid() { - return visitUnknown("CONTROL_COMBINATION_INVALID"); - } - - T visitInternalError(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java index acd717d..130da0d 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java +++ b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java @@ -36,6 +36,11 @@ public boolean equals(Object other) { return other instanceof SpeakV2Flush; } + @java.lang.Override + public int hashCode() { + return getClass().hashCode(); + } + @JsonAnyGetter public Map getAdditionalProperties() { return this.additionalProperties; diff --git a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak b/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak deleted file mode 100644 index 130da0d..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/types/SpeakV2Flush.java.bak +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.types; - -import com.deepgram.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SpeakV2Flush.Builder.class) -public final class SpeakV2Flush { - private final Map additionalProperties; - - private SpeakV2Flush(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - /** - * @return Message type identifier - */ - @JsonProperty("type") - public String getType() { - return "Flush"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SpeakV2Flush; - } - - @java.lang.Override - public int hashCode() { - return getClass().hashCode(); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SpeakV2Flush other) { - return this; - } - - public SpeakV2Flush build() { - return new SpeakV2Flush(additionalProperties); - } - - public Builder additionalProperty(String key, Object value) { - this.additionalProperties.put(key, value); - return this; - } - - public Builder additionalProperties(Map additionalProperties) { - this.additionalProperties.putAll(additionalProperties); - return this; - } - } -} diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java index b18eaa5..672fcb7 100644 --- a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java +++ b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java @@ -6,6 +6,7 @@ import com.deepgram.core.ClientOptions; import com.deepgram.core.DisconnectReason; import com.deepgram.core.ObjectMappers; +import com.deepgram.core.QueryStringMapper; import com.deepgram.core.ReconnectingWebSocketListener; import com.deepgram.core.RequestOptions; import com.deepgram.core.WebSocketReadyState; @@ -148,7 +149,14 @@ public CompletableFuture connect(V2ConnectOptions options) { "mip_opt_out", String.valueOf(options.getMipOptOut().get())); } if (options.getTag() != null && options.getTag().isPresent()) { - urlBuilder.addQueryParameter("tag", String.valueOf(options.getTag().get())); + QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); + } + if (options.getAdditionalProperties() != null) { + options.getAdditionalProperties().forEach((key, value) -> { + if (value != null) { + QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); + } + }); } Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); @@ -616,11 +624,8 @@ private void handleIncomingMessage(String json) { return; } } - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException( - "Unrecognized WebSocket message: " + json.substring(0, Math.min(200, json.length())) - + "... Update your SDK version to support new message types.")); - } + // The raw frame is already delivered to onMessage(String), so ignore unknown typed + // frames for forward compatibility with newly added server control messages. } catch (Exception e) { if (onErrorHandler != null) { onErrorHandler.accept(e); diff --git a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak b/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak deleted file mode 100644 index b4e01f7..0000000 --- a/src/main/java/com/deepgram/resources/speak/v2/websocket/V2WebSocketClient.java.bak +++ /dev/null @@ -1,630 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.resources.speak.v2.websocket; - -import com.deepgram.core.ClientOptions; -import com.deepgram.core.DisconnectReason; -import com.deepgram.core.ObjectMappers; -import com.deepgram.core.QueryStringMapper; -import com.deepgram.core.ReconnectingWebSocketListener; -import com.deepgram.core.RequestOptions; -import com.deepgram.core.WebSocketReadyState; -import com.deepgram.resources.speak.v2.types.SpeakV2Close; -import com.deepgram.resources.speak.v2.types.SpeakV2Configure; -import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureFailure; -import com.deepgram.resources.speak.v2.types.SpeakV2ConfigureSuccess; -import com.deepgram.resources.speak.v2.types.SpeakV2Connected; -import com.deepgram.resources.speak.v2.types.SpeakV2Error; -import com.deepgram.resources.speak.v2.types.SpeakV2Flush; -import com.deepgram.resources.speak.v2.types.SpeakV2Flushed; -import com.deepgram.resources.speak.v2.types.SpeakV2Interrupt; -import com.deepgram.resources.speak.v2.types.SpeakV2SessionMetadata; -import com.deepgram.resources.speak.v2.types.SpeakV2Speak; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechInterrupted; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechMetadata; -import com.deepgram.resources.speak.v2.types.SpeakV2SpeechStarted; -import com.deepgram.resources.speak.v2.types.SpeakV2Warning; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Consumer; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.WebSocket; -import okio.ByteString; - -/** - * WebSocket client for the v2 channel. - * Provides real-time bidirectional communication with strongly-typed messages. - */ -public class V2WebSocketClient implements AutoCloseable { - protected final ClientOptions clientOptions; - - private final ObjectMapper objectMapper; - - private final OkHttpClient okHttpClient; - - private ScheduledExecutorService timeoutExecutor; - - private volatile WebSocketReadyState readyState = WebSocketReadyState.CLOSED; - - private volatile Runnable onConnectedHandler; - - private volatile Consumer onDisconnectedHandler; - - private volatile Consumer onErrorHandler; - - private volatile Consumer onMessageHandler; - - private volatile ReconnectingWebSocketListener.ReconnectOptions reconnectOptions; - - private CompletableFuture connectionFuture; - - private ReconnectingWebSocketListener reconnectingListener; - - private volatile Consumer speakV2AudioHandler; - - private volatile Consumer connectedHandler; - - private volatile Consumer speechStartedHandler; - - private volatile Consumer speechMetadataHandler; - - private volatile Consumer speechInterruptedHandler; - - private volatile Consumer flushedHandler; - - private volatile Consumer sessionMetadataHandler; - - private volatile Consumer configureSuccessHandler; - - private volatile Consumer configureFailureHandler; - - private volatile Consumer warningHandler; - - private volatile Consumer errorHandler; - - /** - * Creates a new async WebSocket client for the v2 channel. - */ - public V2WebSocketClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.objectMapper = ObjectMappers.JSON_MAPPER; - this.okHttpClient = clientOptions.httpClient(); - } - - /** - * Establishes the WebSocket connection asynchronously with automatic reconnection. - * @return a CompletableFuture that completes when the connection is established - * @param options connection options including query parameters - */ - public CompletableFuture connect(V2ConnectOptions options) { - connectionFuture = new CompletableFuture<>(); - String baseUrl = clientOptions.environment().getProductionURL(); - String fullPath = "/v2/speak"; - if (baseUrl.endsWith("/") && fullPath.startsWith("/")) { - fullPath = fullPath.substring(1); - } else if (!baseUrl.endsWith("/") && !fullPath.startsWith("/")) { - fullPath = "/" + fullPath; - } - // OkHttp's HttpUrl only supports http/https schemes; convert wss/ws for URL parsing - if (baseUrl.startsWith("wss://")) { - baseUrl = "https://" + baseUrl.substring(6); - } else if (baseUrl.startsWith("ws://")) { - baseUrl = "http://" + baseUrl.substring(5); - } - HttpUrl parsedUrl = HttpUrl.parse(baseUrl + fullPath); - if (parsedUrl == null) { - throw new IllegalArgumentException("Invalid WebSocket URL: " + baseUrl + fullPath); - } - HttpUrl.Builder urlBuilder = parsedUrl.newBuilder(); - urlBuilder.addQueryParameter("model", String.valueOf(options.getModel())); - if (options.getEncoding() != null && options.getEncoding().isPresent()) { - urlBuilder.addQueryParameter( - "encoding", String.valueOf(options.getEncoding().get())); - } - if (options.getSampleRate() != null && options.getSampleRate().isPresent()) { - urlBuilder.addQueryParameter( - "sample_rate", String.valueOf(options.getSampleRate().get())); - } - if (options.getSpeed() != null && options.getSpeed().isPresent()) { - urlBuilder.addQueryParameter( - "speed", String.valueOf(options.getSpeed().get())); - } - if (options.getExpressivity() != null && options.getExpressivity().isPresent()) { - urlBuilder.addQueryParameter( - "expressivity", String.valueOf(options.getExpressivity().get())); - } - if (options.getMipOptOut() != null && options.getMipOptOut().isPresent()) { - urlBuilder.addQueryParameter( - "mip_opt_out", String.valueOf(options.getMipOptOut().get())); - } - if (options.getTag() != null && options.getTag().isPresent()) { - QueryStringMapper.addQueryParameter(urlBuilder, "tag", options.getTag().get().get(), true); - } - if (options.getAdditionalProperties() != null) { - options.getAdditionalProperties().forEach((key, value) -> { - if (value != null) { - QueryStringMapper.addQueryParameter(urlBuilder, key, value, true); - } - }); - } - Request.Builder requestBuilder = new Request.Builder().url(urlBuilder.build()); - clientOptions.headers((RequestOptions) null).forEach(requestBuilder::addHeader); - final Request request = requestBuilder.build(); - this.readyState = WebSocketReadyState.CONNECTING; - ReconnectingWebSocketListener.ReconnectOptions reconnectOpts = this.reconnectOptions != null - ? this.reconnectOptions - : ReconnectingWebSocketListener.ReconnectOptions.builder().build(); - this.reconnectingListener = - new ReconnectingWebSocketListener( - reconnectOpts, - () -> { - if (clientOptions.isClosed()) { - throw new IllegalStateException("root client has been closed"); - } - if (clientOptions.webSocketFactory().isPresent()) { - return clientOptions - .webSocketFactory() - .get() - .create(request, this.reconnectingListener); - } else { - return okHttpClient.newWebSocket(request, this.reconnectingListener); - } - }, - clientOptions::isClosed) { - @Override - protected void onWebSocketOpen(WebSocket webSocket, Response response) { - readyState = WebSocketReadyState.OPEN; - if (onConnectedHandler != null) { - onConnectedHandler.run(); - } - connectionFuture.complete(null); - } - - @Override - protected void onWebSocketMessage(WebSocket webSocket, String text) { - handleIncomingMessage(text); - } - - @Override - protected void onWebSocketBinaryMessage(WebSocket webSocket, ByteString bytes) { - if (speakV2AudioHandler != null) { - speakV2AudioHandler.accept(bytes); - } - } - - @Override - protected void onWebSocketFailure(WebSocket webSocket, Throwable t, Response response) { - readyState = WebSocketReadyState.CLOSED; - if (onErrorHandler != null) { - onErrorHandler.accept(new RuntimeException(t)); - } - connectionFuture.completeExceptionally(t); - } - - @Override - protected void onWebSocketClosed(WebSocket webSocket, int code, String reason) { - readyState = WebSocketReadyState.CLOSED; - if (onDisconnectedHandler != null) { - onDisconnectedHandler.accept(new DisconnectReason(code, reason)); - } - } - }; - clientOptions.registerWebSocket(this); - reconnectingListener.connect(); - return connectionFuture; - } - - /** - * Disconnects the WebSocket connection and releases resources. - */ - public void disconnect() { - clientOptions.unregisterWebSocket(this); - if (reconnectingListener != null) { - reconnectingListener.disconnect(); - } - if (timeoutExecutor != null) { - timeoutExecutor.shutdownNow(); - timeoutExecutor = null; - } - } - - /** - * Gets the current state of the WebSocket connection. - * - * This provides the actual connection state, similar to the W3C WebSocket API. - * - * @return the current WebSocket ready state - */ - public WebSocketReadyState getReadyState() { - return readyState; - } - - /** - * Sends a SpeakV2Speak message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendSpeak(SpeakV2Speak message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Flush message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendFlush(SpeakV2Flush message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Interrupt message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendInterrupt(SpeakV2Interrupt message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Configure message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendConfigure(SpeakV2Configure message) { - return sendMessage(message); - } - - /** - * Sends a SpeakV2Close message to the server asynchronously. - * @param message the message to send - * @return a CompletableFuture that completes when the message is sent - */ - public CompletableFuture sendClose(SpeakV2Close message) { - return sendMessage(message); - } - - /** - * Registers a handler for SpeakV2Audio messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeakV2Audio(Consumer handler) { - this.speakV2AudioHandler = handler; - } - - /** - * Registers a handler for SpeakV2Connected messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConnected(Consumer handler) { - this.connectedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechStarted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechStarted(Consumer handler) { - this.speechStartedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechMetadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechMetadata(Consumer handler) { - this.speechMetadataHandler = handler; - } - - /** - * Registers a handler for SpeakV2SpeechInterrupted messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSpeechInterrupted(Consumer handler) { - this.speechInterruptedHandler = handler; - } - - /** - * Registers a handler for SpeakV2Flushed messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onFlushed(Consumer handler) { - this.flushedHandler = handler; - } - - /** - * Registers a handler for SpeakV2SessionMetadata messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onSessionMetadata(Consumer handler) { - this.sessionMetadataHandler = handler; - } - - /** - * Registers a handler for SpeakV2ConfigureSuccess messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureSuccess(Consumer handler) { - this.configureSuccessHandler = handler; - } - - /** - * Registers a handler for SpeakV2ConfigureFailure messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onConfigureFailure(Consumer handler) { - this.configureFailureHandler = handler; - } - - /** - * Registers a handler for SpeakV2Warning messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onWarning(Consumer handler) { - this.warningHandler = handler; - } - - /** - * Registers a handler for SpeakV2Error messages from the server. - * @param handler the handler to invoke when a message is received - */ - public void onErrorMessage(Consumer handler) { - this.errorHandler = handler; - } - - /** - * Registers a handler called when the connection is established. - * @param handler the handler to invoke when connected - */ - public void onConnected(Runnable handler) { - this.onConnectedHandler = handler; - } - - /** - * Registers a handler called when the connection is closed. - * @param handler the handler to invoke when disconnected - */ - public void onDisconnected(Consumer handler) { - this.onDisconnectedHandler = handler; - } - - /** - * Registers a handler called when an error occurs. - * @param handler the handler to invoke on error - */ - public void onError(Consumer handler) { - this.onErrorHandler = handler; - } - - /** - * Registers a handler called for every incoming text message. - * The handler receives the raw JSON string before type-specific dispatch. - * @param handler the handler to invoke with the raw message JSON - */ - public void onMessage(Consumer handler) { - this.onMessageHandler = handler; - } - - /** - * Configures reconnection behavior. Must be called before {@link #connect}. - * - * @param options the reconnection options (backoff, retries, queue size) - */ - public void reconnectOptions(ReconnectingWebSocketListener.ReconnectOptions options) { - this.reconnectOptions = options; - } - - /** - * Closes this WebSocket client, releasing all resources. - * Equivalent to calling {@link #disconnect()}. - */ - @Override - public void close() { - disconnect(); - } - - /** - * Ensures the WebSocket is connected and ready to send messages. - * @throws IllegalStateException if the socket is not connected or not open - */ - private void assertSocketIsOpen() { - if (reconnectingListener.getWebSocket() == null) { - throw new IllegalStateException("WebSocket is not connected. Call connect() first."); - } - if (readyState != WebSocketReadyState.OPEN) { - throw new IllegalStateException("WebSocket is not open. Current state: " + readyState); - } - } - - private CompletableFuture sendMessage(Object body) { - CompletableFuture future = new CompletableFuture<>(); - try { - assertSocketIsOpen(); - String json = objectMapper.writeValueAsString(body); - // Use reconnecting listener's send method which handles queuing - reconnectingListener.send(json); - future.complete(null); - } catch (IllegalStateException e) { - future.completeExceptionally(e); - } catch (Exception e) { - future.completeExceptionally(new RuntimeException("Failed to send message", e)); - } - return future; - } - - private void handleIncomingMessage(String json) { - try { - if (onMessageHandler != null) { - onMessageHandler.accept(json); - } - JsonNode node = objectMapper.readTree(json); - if (node == null || node.isNull()) { - throw new IllegalArgumentException("Received null or invalid JSON message"); - } - if (node.has("speech_id") - && node.has("audio_duration_ms") - && node.has("input_character_count") - && node.has("billable_character_count") - && node.has("controls_applied") - && "SpeechMetadata".equals(node.path("type").asText())) { - SpeakV2SpeechMetadata speechMetadataHandlerEvent = null; - try { - speechMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechMetadata.class); - } catch (Exception e) { - } - if (speechMetadataHandlerEvent != null) { - if (speechMetadataHandler != null) { - speechMetadataHandler.accept(speechMetadataHandlerEvent); - } - return; - } - } - if (node.has("request_id") - && node.has("model_name") - && node.has("model_version") - && node.has("model_uuids") - && "Connected".equals(node.path("type").asText())) { - SpeakV2Connected connectedHandlerEvent = null; - try { - connectedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Connected.class); - } catch (Exception e) { - } - if (connectedHandlerEvent != null) { - if (connectedHandler != null) { - connectedHandler.accept(connectedHandlerEvent); - } - return; - } - } - if (node.has("total_audio_duration_ms") - && node.has("total_input_character_count") - && node.has("total_billable_character_count") - && "SessionMetadata".equals(node.path("type").asText())) { - SpeakV2SessionMetadata sessionMetadataHandlerEvent = null; - try { - sessionMetadataHandlerEvent = objectMapper.treeToValue(node, SpeakV2SessionMetadata.class); - } catch (Exception e) { - } - if (sessionMetadataHandlerEvent != null) { - if (sessionMetadataHandler != null) { - sessionMetadataHandler.accept(sessionMetadataHandlerEvent); - } - return; - } - } - if (node.has("audio_played_ms") - && node.has("metadata") - && "SpeechInterrupted".equals(node.path("type").asText())) { - SpeakV2SpeechInterrupted speechInterruptedHandlerEvent = null; - try { - speechInterruptedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechInterrupted.class); - } catch (Exception e) { - } - if (speechInterruptedHandlerEvent != null) { - if (speechInterruptedHandler != null) { - speechInterruptedHandler.accept(speechInterruptedHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "ConfigureFailure".equals(node.path("type").asText())) { - SpeakV2ConfigureFailure configureFailureHandlerEvent = null; - try { - configureFailureHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureFailure.class); - } catch (Exception e) { - } - if (configureFailureHandlerEvent != null) { - if (configureFailureHandler != null) { - configureFailureHandler.accept(configureFailureHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "Warning".equals(node.path("type").asText())) { - SpeakV2Warning warningHandlerEvent = null; - try { - warningHandlerEvent = objectMapper.treeToValue(node, SpeakV2Warning.class); - } catch (Exception e) { - } - if (warningHandlerEvent != null) { - if (warningHandler != null) { - warningHandler.accept(warningHandlerEvent); - } - return; - } - } - if (node.has("code") - && node.has("description") - && "Error".equals(node.path("type").asText())) { - SpeakV2Error errorHandlerEvent = null; - try { - errorHandlerEvent = objectMapper.treeToValue(node, SpeakV2Error.class); - } catch (Exception e) { - } - if (errorHandlerEvent != null) { - if (errorHandler != null) { - errorHandler.accept(errorHandlerEvent); - } - return; - } - } - if (node.has("speech_id") - && "SpeechStarted".equals(node.path("type").asText())) { - SpeakV2SpeechStarted speechStartedHandlerEvent = null; - try { - speechStartedHandlerEvent = objectMapper.treeToValue(node, SpeakV2SpeechStarted.class); - } catch (Exception e) { - } - if (speechStartedHandlerEvent != null) { - if (speechStartedHandler != null) { - speechStartedHandler.accept(speechStartedHandlerEvent); - } - return; - } - } - if (node.has("speech_id") && "Flushed".equals(node.path("type").asText())) { - SpeakV2Flushed flushedHandlerEvent = null; - try { - flushedHandlerEvent = objectMapper.treeToValue(node, SpeakV2Flushed.class); - } catch (Exception e) { - } - if (flushedHandlerEvent != null) { - if (flushedHandler != null) { - flushedHandler.accept(flushedHandlerEvent); - } - return; - } - } - if (node.has("applied") - && "ConfigureSuccess".equals(node.path("type").asText())) { - SpeakV2ConfigureSuccess configureSuccessHandlerEvent = null; - try { - configureSuccessHandlerEvent = objectMapper.treeToValue(node, SpeakV2ConfigureSuccess.class); - } catch (Exception e) { - } - if (configureSuccessHandlerEvent != null) { - if (configureSuccessHandler != null) { - configureSuccessHandler.accept(configureSuccessHandlerEvent); - } - return; - } - } - // The raw frame is already delivered to onMessage(String), so ignore unknown typed - // frames for forward compatibility with newly added server control messages. - } catch (Exception e) { - if (onErrorHandler != null) { - onErrorHandler.accept(e); - } - } - } -} diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java b/src/main/java/com/deepgram/types/DeepgramModel.java index 66a7093..b6cce4d 100644 --- a/src/main/java/com/deepgram/types/DeepgramModel.java +++ b/src/main/java/com/deepgram/types/DeepgramModel.java @@ -328,6 +328,13 @@ public final class DeepgramModel { public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); + public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); public static final DeepgramModel FLUX_IRENE_NL = new DeepgramModel(Value.FLUX_IRENE_NL, "flux-irene-nl"); @@ -1026,6 +1033,8 @@ public T visit(Visitor visitor) { return visitor.visitAura2SirioEs(); case FLUX_KELSEY_EN: return visitor.visitFluxKelseyEn(); + case FLUX_RENEE_EN: + return visitor.visitFluxReneeEn(); case FLUX_SIENNA_EN: return visitor.visitFluxSiennaEn(); case FLUX_IRENE_NL: @@ -1693,6 +1702,8 @@ public static DeepgramModel valueOf(String value) { return AURA2SIRIO_ES; case "flux-kelsey-en": return FLUX_KELSEY_EN; + case "flux-renee-en": + return FLUX_RENEE_EN; case "flux-sienna-en": return FLUX_SIENNA_EN; case "flux-irene-nl": @@ -2207,6 +2218,8 @@ public enum Value { FLUX_KELSEY_EN, + FLUX_RENEE_EN, + FLUX_KIT_EN, FLUX_MAEVE_EN, @@ -2869,6 +2882,13 @@ public interface Visitor { T visitFluxKelseyEn(); + /** + * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major + * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. + */ + @Deprecated + T visitFluxReneeEn(); + T visitFluxKitEn(); T visitFluxMaeveEn(); diff --git a/src/main/java/com/deepgram/types/DeepgramModel.java.bak b/src/main/java/com/deepgram/types/DeepgramModel.java.bak deleted file mode 100644 index 9fa2f8b..0000000 --- a/src/main/java/com/deepgram/types/DeepgramModel.java.bak +++ /dev/null @@ -1,1081 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -public final class DeepgramModel { - public static final DeepgramModel AURA2SIRIO_ES = new DeepgramModel(Value.AURA2SIRIO_ES, "aura-2-sirio-es"); - - public static final DeepgramModel AURA2HERA_EN = new DeepgramModel(Value.AURA2HERA_EN, "aura-2-hera-en"); - - public static final DeepgramModel FLUX_KELSEY_EN = new DeepgramModel(Value.FLUX_KELSEY_EN, "flux-kelsey-en"); - - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - public static final DeepgramModel FLUX_RENEE_EN = new DeepgramModel(Value.FLUX_RENEE_EN, "flux-renee-en"); - - public static final DeepgramModel FLUX_SIENNA_EN = new DeepgramModel(Value.FLUX_SIENNA_EN, "flux-sienna-en"); - - public static final DeepgramModel AURA2HARMONIA_EN = - new DeepgramModel(Value.AURA2HARMONIA_EN, "aura-2-harmonia-en"); - - public static final DeepgramModel AURA2CARINA_ES = new DeepgramModel(Value.AURA2CARINA_ES, "aura-2-carina-es"); - - public static final DeepgramModel FLUX_MEENA_EN = new DeepgramModel(Value.FLUX_MEENA_EN, "flux-meena-en"); - - public static final DeepgramModel FLUX_MEGHAN_EN = new DeepgramModel(Value.FLUX_MEGHAN_EN, "flux-meghan-en"); - - public static final DeepgramModel AURA_ZEUS_EN = new DeepgramModel(Value.AURA_ZEUS_EN, "aura-zeus-en"); - - public static final DeepgramModel AURA2HERMES_EN = new DeepgramModel(Value.AURA2HERMES_EN, "aura-2-hermes-en"); - - public static final DeepgramModel FLUX_CONOR_EN = new DeepgramModel(Value.FLUX_CONOR_EN, "flux-conor-en"); - - public static final DeepgramModel AURA2NEPTUNE_EN = new DeepgramModel(Value.AURA2NEPTUNE_EN, "aura-2-neptune-en"); - - public static final DeepgramModel FLUX_BROOKE_EN = new DeepgramModel(Value.FLUX_BROOKE_EN, "flux-brooke-en"); - - public static final DeepgramModel FLUX_RUFUS_EN = new DeepgramModel(Value.FLUX_RUFUS_EN, "flux-rufus-en"); - - public static final DeepgramModel FLUX_WES_EN = new DeepgramModel(Value.FLUX_WES_EN, "flux-wes-en"); - - public static final DeepgramModel AURA2CALLISTA_EN = - new DeepgramModel(Value.AURA2CALLISTA_EN, "aura-2-callista-en"); - - public static final DeepgramModel AURA2AURORA_EN = new DeepgramModel(Value.AURA2AURORA_EN, "aura-2-aurora-en"); - - public static final DeepgramModel AURA2OPHELIA_EN = new DeepgramModel(Value.AURA2OPHELIA_EN, "aura-2-ophelia-en"); - - public static final DeepgramModel FLUX_BRUCE_EN = new DeepgramModel(Value.FLUX_BRUCE_EN, "flux-bruce-en"); - - public static final DeepgramModel AURA2APOLLO_EN = new DeepgramModel(Value.AURA2APOLLO_EN, "aura-2-apollo-en"); - - public static final DeepgramModel AURA2DELIA_EN = new DeepgramModel(Value.AURA2DELIA_EN, "aura-2-delia-en"); - - public static final DeepgramModel AURA2MARS_EN = new DeepgramModel(Value.AURA2MARS_EN, "aura-2-mars-en"); - - public static final DeepgramModel AURA_HERA_EN = new DeepgramModel(Value.AURA_HERA_EN, "aura-hera-en"); - - public static final DeepgramModel FLUX_MAEVE_EN = new DeepgramModel(Value.FLUX_MAEVE_EN, "flux-maeve-en"); - - public static final DeepgramModel FLUX_MARCUS_EN = new DeepgramModel(Value.FLUX_MARCUS_EN, "flux-marcus-en"); - - public static final DeepgramModel AURA2ARIES_EN = new DeepgramModel(Value.AURA2ARIES_EN, "aura-2-aries-en"); - - public static final DeepgramModel FLUX_PAIGE_EN = new DeepgramModel(Value.FLUX_PAIGE_EN, "flux-paige-en"); - - public static final DeepgramModel AURA2JUNO_EN = new DeepgramModel(Value.AURA2JUNO_EN, "aura-2-juno-en"); - - public static final DeepgramModel FLUX_DREW_EN = new DeepgramModel(Value.FLUX_DREW_EN, "flux-drew-en"); - - public static final DeepgramModel AURA2JAVIER_ES = new DeepgramModel(Value.AURA2JAVIER_ES, "aura-2-javier-es"); - - public static final DeepgramModel AURA2ANDROMEDA_EN = - new DeepgramModel(Value.AURA2ANDROMEDA_EN, "aura-2-andromeda-en"); - - public static final DeepgramModel AURA2SATURN_EN = new DeepgramModel(Value.AURA2SATURN_EN, "aura-2-saturn-en"); - - public static final DeepgramModel AURA2IRIS_EN = new DeepgramModel(Value.AURA2IRIS_EN, "aura-2-iris-en"); - - public static final DeepgramModel AURA_ANGUS_EN = new DeepgramModel(Value.AURA_ANGUS_EN, "aura-angus-en"); - - public static final DeepgramModel FLUX_KAI_EN = new DeepgramModel(Value.FLUX_KAI_EN, "flux-kai-en"); - - public static final DeepgramModel FLUX_BRITTANY_EN = new DeepgramModel(Value.FLUX_BRITTANY_EN, "flux-brittany-en"); - - public static final DeepgramModel FLUX_SEAN_EN = new DeepgramModel(Value.FLUX_SEAN_EN, "flux-sean-en"); - - public static final DeepgramModel AURA2HELENA_EN = new DeepgramModel(Value.AURA2HELENA_EN, "aura-2-helena-en"); - - public static final DeepgramModel FLUX_HALEY_EN = new DeepgramModel(Value.FLUX_HALEY_EN, "flux-haley-en"); - - public static final DeepgramModel AURA_STELLA_EN = new DeepgramModel(Value.AURA_STELLA_EN, "aura-stella-en"); - - public static final DeepgramModel FLUX_JACK_EN = new DeepgramModel(Value.FLUX_JACK_EN, "flux-jack-en"); - - public static final DeepgramModel AURA2DRACO_EN = new DeepgramModel(Value.AURA2DRACO_EN, "aura-2-draco-en"); - - public static final DeepgramModel FLUX_PRIYA_EN = new DeepgramModel(Value.FLUX_PRIYA_EN, "flux-priya-en"); - - public static final DeepgramModel AURA_HELIOS_EN = new DeepgramModel(Value.AURA_HELIOS_EN, "aura-helios-en"); - - public static final DeepgramModel AURA2JANUS_EN = new DeepgramModel(Value.AURA2JANUS_EN, "aura-2-janus-en"); - - public static final DeepgramModel AURA2NESTOR_ES = new DeepgramModel(Value.AURA2NESTOR_ES, "aura-2-nestor-es"); - - public static final DeepgramModel AURA2ORION_EN = new DeepgramModel(Value.AURA2ORION_EN, "aura-2-orion-en"); - - public static final DeepgramModel AURA2MINERVA_EN = new DeepgramModel(Value.AURA2MINERVA_EN, "aura-2-minerva-en"); - - public static final DeepgramModel AURA2ALVARO_ES = new DeepgramModel(Value.AURA2ALVARO_ES, "aura-2-alvaro-es"); - - public static final DeepgramModel AURA_PERSEUS_EN = new DeepgramModel(Value.AURA_PERSEUS_EN, "aura-perseus-en"); - - public static final DeepgramModel AURA2VESTA_EN = new DeepgramModel(Value.AURA2VESTA_EN, "aura-2-vesta-en"); - - public static final DeepgramModel FLUX_COLE_EN = new DeepgramModel(Value.FLUX_COLE_EN, "flux-cole-en"); - - public static final DeepgramModel AURA2ZEUS_EN = new DeepgramModel(Value.AURA2ZEUS_EN, "aura-2-zeus-en"); - - public static final DeepgramModel AURA2ORPHEUS_EN = new DeepgramModel(Value.AURA2ORPHEUS_EN, "aura-2-orpheus-en"); - - public static final DeepgramModel AURA2THALIA_EN = new DeepgramModel(Value.AURA2THALIA_EN, "aura-2-thalia-en"); - - public static final DeepgramModel FLUX_NAVEEN_EN = new DeepgramModel(Value.FLUX_NAVEEN_EN, "flux-naveen-en"); - - public static final DeepgramModel AURA2ASTERIA_EN = new DeepgramModel(Value.AURA2ASTERIA_EN, "aura-2-asteria-en"); - - public static final DeepgramModel AURA2SELENA_ES = new DeepgramModel(Value.AURA2SELENA_ES, "aura-2-selena-es"); - - public static final DeepgramModel FLUX_MARCELO_EN = new DeepgramModel(Value.FLUX_MARCELO_EN, "flux-marcelo-en"); - - public static final DeepgramModel FLUX_ELISE_EN = new DeepgramModel(Value.FLUX_ELISE_EN, "flux-elise-en"); - - public static final DeepgramModel FLUX_ALEXIS_EN = new DeepgramModel(Value.FLUX_ALEXIS_EN, "flux-alexis-en"); - - public static final DeepgramModel AURA_LUNA_EN = new DeepgramModel(Value.AURA_LUNA_EN, "aura-luna-en"); - - public static final DeepgramModel AURA_ORPHEUS_EN = new DeepgramModel(Value.AURA_ORPHEUS_EN, "aura-orpheus-en"); - - public static final DeepgramModel AURA2AMALTHEA_EN = - new DeepgramModel(Value.AURA2AMALTHEA_EN, "aura-2-amalthea-en"); - - public static final DeepgramModel FLUX_DONOVAN_EN = new DeepgramModel(Value.FLUX_DONOVAN_EN, "flux-donovan-en"); - - public static final DeepgramModel AURA2SELENE_EN = new DeepgramModel(Value.AURA2SELENE_EN, "aura-2-selene-en"); - - public static final DeepgramModel FLUX_TANNER_EN = new DeepgramModel(Value.FLUX_TANNER_EN, "flux-tanner-en"); - - public static final DeepgramModel FLUX_SHARON_EN = new DeepgramModel(Value.FLUX_SHARON_EN, "flux-sharon-en"); - - public static final DeepgramModel AURA2LUNA_EN = new DeepgramModel(Value.AURA2LUNA_EN, "aura-2-luna-en"); - - public static final DeepgramModel AURA2PHOEBE_EN = new DeepgramModel(Value.AURA2PHOEBE_EN, "aura-2-phoebe-en"); - - public static final DeepgramModel FLUX_HANNAH_EN = new DeepgramModel(Value.FLUX_HANNAH_EN, "flux-hannah-en"); - - public static final DeepgramModel AURA2DIANA_ES = new DeepgramModel(Value.AURA2DIANA_ES, "aura-2-diana-es"); - - public static final DeepgramModel AURA_ORION_EN = new DeepgramModel(Value.AURA_ORION_EN, "aura-orion-en"); - - public static final DeepgramModel AURA2ATHENA_EN = new DeepgramModel(Value.AURA2ATHENA_EN, "aura-2-athena-en"); - - public static final DeepgramModel AURA_ARCAS_EN = new DeepgramModel(Value.AURA_ARCAS_EN, "aura-arcas-en"); - - public static final DeepgramModel AURA2THEIA_EN = new DeepgramModel(Value.AURA2THEIA_EN, "aura-2-theia-en"); - - public static final DeepgramModel FLUX_WADE_EN = new DeepgramModel(Value.FLUX_WADE_EN, "flux-wade-en"); - - public static final DeepgramModel FLUX_HEATHER_EN = new DeepgramModel(Value.FLUX_HEATHER_EN, "flux-heather-en"); - - public static final DeepgramModel FLUX_CLIFF_EN = new DeepgramModel(Value.FLUX_CLIFF_EN, "flux-cliff-en"); - - public static final DeepgramModel AURA2JUPITER_EN = new DeepgramModel(Value.AURA2JUPITER_EN, "aura-2-jupiter-en"); - - public static final DeepgramModel FLUX_KIT_EN = new DeepgramModel(Value.FLUX_KIT_EN, "flux-kit-en"); - - public static final DeepgramModel AURA2AQUILA_ES = new DeepgramModel(Value.AURA2AQUILA_ES, "aura-2-aquila-es"); - - public static final DeepgramModel AURA2CORA_EN = new DeepgramModel(Value.AURA2CORA_EN, "aura-2-cora-en"); - - public static final DeepgramModel AURA2CORDELIA_EN = - new DeepgramModel(Value.AURA2CORDELIA_EN, "aura-2-cordelia-en"); - - public static final DeepgramModel AURA2ATLAS_EN = new DeepgramModel(Value.AURA2ATLAS_EN, "aura-2-atlas-en"); - - public static final DeepgramModel AURA2HYPERION_EN = - new DeepgramModel(Value.AURA2HYPERION_EN, "aura-2-hyperion-en"); - - public static final DeepgramModel AURA2CELESTE_ES = new DeepgramModel(Value.AURA2CELESTE_ES, "aura-2-celeste-es"); - - public static final DeepgramModel AURA2PLUTO_EN = new DeepgramModel(Value.AURA2PLUTO_EN, "aura-2-pluto-en"); - - public static final DeepgramModel FLUX_BREE_EN = new DeepgramModel(Value.FLUX_BREE_EN, "flux-bree-en"); - - public static final DeepgramModel AURA2ARCAS_EN = new DeepgramModel(Value.AURA2ARCAS_EN, "aura-2-arcas-en"); - - public static final DeepgramModel FLUX_COLIN_EN = new DeepgramModel(Value.FLUX_COLIN_EN, "flux-colin-en"); - - public static final DeepgramModel AURA_ATHENA_EN = new DeepgramModel(Value.AURA_ATHENA_EN, "aura-athena-en"); - - public static final DeepgramModel AURA2ODYSSEUS_EN = - new DeepgramModel(Value.AURA2ODYSSEUS_EN, "aura-2-odysseus-en"); - - public static final DeepgramModel AURA2PANDORA_EN = new DeepgramModel(Value.AURA2PANDORA_EN, "aura-2-pandora-en"); - - public static final DeepgramModel FLUX_MILES_EN = new DeepgramModel(Value.FLUX_MILES_EN, "flux-miles-en"); - - public static final DeepgramModel AURA_ASTERIA_EN = new DeepgramModel(Value.AURA_ASTERIA_EN, "aura-asteria-en"); - - public static final DeepgramModel AURA2ELECTRA_EN = new DeepgramModel(Value.AURA2ELECTRA_EN, "aura-2-electra-en"); - - public static final DeepgramModel FLUX_GEMMA_EN = new DeepgramModel(Value.FLUX_GEMMA_EN, "flux-gemma-en"); - - public static final DeepgramModel AURA2ESTRELLA_ES = - new DeepgramModel(Value.AURA2ESTRELLA_ES, "aura-2-estrella-es"); - - private final Value value; - - private final String string; - - DeepgramModel(Value value, String string) { - this.value = value; - this.string = string; - } - - public Value getEnumValue() { - return value; - } - - @java.lang.Override - @JsonValue - public String toString() { - return this.string; - } - - @java.lang.Override - public boolean equals(Object other) { - return (this == other) - || (other instanceof DeepgramModel && this.string.equals(((DeepgramModel) other).string)); - } - - @java.lang.Override - public int hashCode() { - return this.string.hashCode(); - } - - public T visit(Visitor visitor) { - switch (value) { - case AURA2SIRIO_ES: - return visitor.visitAura2SirioEs(); - case AURA2HERA_EN: - return visitor.visitAura2HeraEn(); - case FLUX_KELSEY_EN: - return visitor.visitFluxKelseyEn(); - case FLUX_RENEE_EN: - return visitor.visitFluxReneeEn(); - case FLUX_SIENNA_EN: - return visitor.visitFluxSiennaEn(); - case AURA2HARMONIA_EN: - return visitor.visitAura2HarmoniaEn(); - case AURA2CARINA_ES: - return visitor.visitAura2CarinaEs(); - case FLUX_MEENA_EN: - return visitor.visitFluxMeenaEn(); - case FLUX_MEGHAN_EN: - return visitor.visitFluxMeghanEn(); - case AURA_ZEUS_EN: - return visitor.visitAuraZeusEn(); - case AURA2HERMES_EN: - return visitor.visitAura2HermesEn(); - case FLUX_CONOR_EN: - return visitor.visitFluxConorEn(); - case AURA2NEPTUNE_EN: - return visitor.visitAura2NeptuneEn(); - case FLUX_BROOKE_EN: - return visitor.visitFluxBrookeEn(); - case FLUX_RUFUS_EN: - return visitor.visitFluxRufusEn(); - case FLUX_WES_EN: - return visitor.visitFluxWesEn(); - case AURA2CALLISTA_EN: - return visitor.visitAura2CallistaEn(); - case AURA2AURORA_EN: - return visitor.visitAura2AuroraEn(); - case AURA2OPHELIA_EN: - return visitor.visitAura2OpheliaEn(); - case FLUX_BRUCE_EN: - return visitor.visitFluxBruceEn(); - case AURA2APOLLO_EN: - return visitor.visitAura2ApolloEn(); - case AURA2DELIA_EN: - return visitor.visitAura2DeliaEn(); - case AURA2MARS_EN: - return visitor.visitAura2MarsEn(); - case AURA_HERA_EN: - return visitor.visitAuraHeraEn(); - case FLUX_MAEVE_EN: - return visitor.visitFluxMaeveEn(); - case FLUX_MARCUS_EN: - return visitor.visitFluxMarcusEn(); - case AURA2ARIES_EN: - return visitor.visitAura2AriesEn(); - case FLUX_PAIGE_EN: - return visitor.visitFluxPaigeEn(); - case AURA2JUNO_EN: - return visitor.visitAura2JunoEn(); - case FLUX_DREW_EN: - return visitor.visitFluxDrewEn(); - case AURA2JAVIER_ES: - return visitor.visitAura2JavierEs(); - case AURA2ANDROMEDA_EN: - return visitor.visitAura2AndromedaEn(); - case AURA2SATURN_EN: - return visitor.visitAura2SaturnEn(); - case AURA2IRIS_EN: - return visitor.visitAura2IrisEn(); - case AURA_ANGUS_EN: - return visitor.visitAuraAngusEn(); - case FLUX_KAI_EN: - return visitor.visitFluxKaiEn(); - case FLUX_BRITTANY_EN: - return visitor.visitFluxBrittanyEn(); - case FLUX_SEAN_EN: - return visitor.visitFluxSeanEn(); - case AURA2HELENA_EN: - return visitor.visitAura2HelenaEn(); - case FLUX_HALEY_EN: - return visitor.visitFluxHaleyEn(); - case AURA_STELLA_EN: - return visitor.visitAuraStellaEn(); - case FLUX_JACK_EN: - return visitor.visitFluxJackEn(); - case AURA2DRACO_EN: - return visitor.visitAura2DracoEn(); - case FLUX_PRIYA_EN: - return visitor.visitFluxPriyaEn(); - case AURA_HELIOS_EN: - return visitor.visitAuraHeliosEn(); - case AURA2JANUS_EN: - return visitor.visitAura2JanusEn(); - case AURA2NESTOR_ES: - return visitor.visitAura2NestorEs(); - case AURA2ORION_EN: - return visitor.visitAura2OrionEn(); - case AURA2MINERVA_EN: - return visitor.visitAura2MinervaEn(); - case AURA2ALVARO_ES: - return visitor.visitAura2AlvaroEs(); - case AURA_PERSEUS_EN: - return visitor.visitAuraPerseusEn(); - case AURA2VESTA_EN: - return visitor.visitAura2VestaEn(); - case FLUX_COLE_EN: - return visitor.visitFluxColeEn(); - case AURA2ZEUS_EN: - return visitor.visitAura2ZeusEn(); - case AURA2ORPHEUS_EN: - return visitor.visitAura2OrpheusEn(); - case AURA2THALIA_EN: - return visitor.visitAura2ThaliaEn(); - case FLUX_NAVEEN_EN: - return visitor.visitFluxNaveenEn(); - case AURA2ASTERIA_EN: - return visitor.visitAura2AsteriaEn(); - case AURA2SELENA_ES: - return visitor.visitAura2SelenaEs(); - case FLUX_MARCELO_EN: - return visitor.visitFluxMarceloEn(); - case FLUX_ELISE_EN: - return visitor.visitFluxEliseEn(); - case FLUX_ALEXIS_EN: - return visitor.visitFluxAlexisEn(); - case AURA_LUNA_EN: - return visitor.visitAuraLunaEn(); - case AURA_ORPHEUS_EN: - return visitor.visitAuraOrpheusEn(); - case AURA2AMALTHEA_EN: - return visitor.visitAura2AmaltheaEn(); - case FLUX_DONOVAN_EN: - return visitor.visitFluxDonovanEn(); - case AURA2SELENE_EN: - return visitor.visitAura2SeleneEn(); - case FLUX_TANNER_EN: - return visitor.visitFluxTannerEn(); - case FLUX_SHARON_EN: - return visitor.visitFluxSharonEn(); - case AURA2LUNA_EN: - return visitor.visitAura2LunaEn(); - case AURA2PHOEBE_EN: - return visitor.visitAura2PhoebeEn(); - case FLUX_HANNAH_EN: - return visitor.visitFluxHannahEn(); - case AURA2DIANA_ES: - return visitor.visitAura2DianaEs(); - case AURA_ORION_EN: - return visitor.visitAuraOrionEn(); - case AURA2ATHENA_EN: - return visitor.visitAura2AthenaEn(); - case AURA_ARCAS_EN: - return visitor.visitAuraArcasEn(); - case AURA2THEIA_EN: - return visitor.visitAura2TheiaEn(); - case FLUX_WADE_EN: - return visitor.visitFluxWadeEn(); - case FLUX_HEATHER_EN: - return visitor.visitFluxHeatherEn(); - case FLUX_CLIFF_EN: - return visitor.visitFluxCliffEn(); - case AURA2JUPITER_EN: - return visitor.visitAura2JupiterEn(); - case FLUX_KIT_EN: - return visitor.visitFluxKitEn(); - case AURA2AQUILA_ES: - return visitor.visitAura2AquilaEs(); - case AURA2CORA_EN: - return visitor.visitAura2CoraEn(); - case AURA2CORDELIA_EN: - return visitor.visitAura2CordeliaEn(); - case AURA2ATLAS_EN: - return visitor.visitAura2AtlasEn(); - case AURA2HYPERION_EN: - return visitor.visitAura2HyperionEn(); - case AURA2CELESTE_ES: - return visitor.visitAura2CelesteEs(); - case AURA2PLUTO_EN: - return visitor.visitAura2PlutoEn(); - case FLUX_BREE_EN: - return visitor.visitFluxBreeEn(); - case AURA2ARCAS_EN: - return visitor.visitAura2ArcasEn(); - case FLUX_COLIN_EN: - return visitor.visitFluxColinEn(); - case AURA_ATHENA_EN: - return visitor.visitAuraAthenaEn(); - case AURA2ODYSSEUS_EN: - return visitor.visitAura2OdysseusEn(); - case AURA2PANDORA_EN: - return visitor.visitAura2PandoraEn(); - case FLUX_MILES_EN: - return visitor.visitFluxMilesEn(); - case AURA_ASTERIA_EN: - return visitor.visitAuraAsteriaEn(); - case AURA2ELECTRA_EN: - return visitor.visitAura2ElectraEn(); - case FLUX_GEMMA_EN: - return visitor.visitFluxGemmaEn(); - case AURA2ESTRELLA_ES: - return visitor.visitAura2EstrellaEs(); - case UNKNOWN: - default: - return visitor.visitUnknown(string); - } - } - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - public static DeepgramModel valueOf(String value) { - switch (value) { - case "aura-2-sirio-es": - return AURA2SIRIO_ES; - case "aura-2-hera-en": - return AURA2HERA_EN; - case "flux-kelsey-en": - return FLUX_KELSEY_EN; - case "flux-renee-en": - return FLUX_RENEE_EN; - case "flux-sienna-en": - return FLUX_SIENNA_EN; - case "aura-2-harmonia-en": - return AURA2HARMONIA_EN; - case "aura-2-carina-es": - return AURA2CARINA_ES; - case "flux-meena-en": - return FLUX_MEENA_EN; - case "flux-meghan-en": - return FLUX_MEGHAN_EN; - case "aura-zeus-en": - return AURA_ZEUS_EN; - case "aura-2-hermes-en": - return AURA2HERMES_EN; - case "flux-conor-en": - return FLUX_CONOR_EN; - case "aura-2-neptune-en": - return AURA2NEPTUNE_EN; - case "flux-brooke-en": - return FLUX_BROOKE_EN; - case "flux-rufus-en": - return FLUX_RUFUS_EN; - case "flux-wes-en": - return FLUX_WES_EN; - case "aura-2-callista-en": - return AURA2CALLISTA_EN; - case "aura-2-aurora-en": - return AURA2AURORA_EN; - case "aura-2-ophelia-en": - return AURA2OPHELIA_EN; - case "flux-bruce-en": - return FLUX_BRUCE_EN; - case "aura-2-apollo-en": - return AURA2APOLLO_EN; - case "aura-2-delia-en": - return AURA2DELIA_EN; - case "aura-2-mars-en": - return AURA2MARS_EN; - case "aura-hera-en": - return AURA_HERA_EN; - case "flux-maeve-en": - return FLUX_MAEVE_EN; - case "flux-marcus-en": - return FLUX_MARCUS_EN; - case "aura-2-aries-en": - return AURA2ARIES_EN; - case "flux-paige-en": - return FLUX_PAIGE_EN; - case "aura-2-juno-en": - return AURA2JUNO_EN; - case "flux-drew-en": - return FLUX_DREW_EN; - case "aura-2-javier-es": - return AURA2JAVIER_ES; - case "aura-2-andromeda-en": - return AURA2ANDROMEDA_EN; - case "aura-2-saturn-en": - return AURA2SATURN_EN; - case "aura-2-iris-en": - return AURA2IRIS_EN; - case "aura-angus-en": - return AURA_ANGUS_EN; - case "flux-kai-en": - return FLUX_KAI_EN; - case "flux-brittany-en": - return FLUX_BRITTANY_EN; - case "flux-sean-en": - return FLUX_SEAN_EN; - case "aura-2-helena-en": - return AURA2HELENA_EN; - case "flux-haley-en": - return FLUX_HALEY_EN; - case "aura-stella-en": - return AURA_STELLA_EN; - case "flux-jack-en": - return FLUX_JACK_EN; - case "aura-2-draco-en": - return AURA2DRACO_EN; - case "flux-priya-en": - return FLUX_PRIYA_EN; - case "aura-helios-en": - return AURA_HELIOS_EN; - case "aura-2-janus-en": - return AURA2JANUS_EN; - case "aura-2-nestor-es": - return AURA2NESTOR_ES; - case "aura-2-orion-en": - return AURA2ORION_EN; - case "aura-2-minerva-en": - return AURA2MINERVA_EN; - case "aura-2-alvaro-es": - return AURA2ALVARO_ES; - case "aura-perseus-en": - return AURA_PERSEUS_EN; - case "aura-2-vesta-en": - return AURA2VESTA_EN; - case "flux-cole-en": - return FLUX_COLE_EN; - case "aura-2-zeus-en": - return AURA2ZEUS_EN; - case "aura-2-orpheus-en": - return AURA2ORPHEUS_EN; - case "aura-2-thalia-en": - return AURA2THALIA_EN; - case "flux-naveen-en": - return FLUX_NAVEEN_EN; - case "aura-2-asteria-en": - return AURA2ASTERIA_EN; - case "aura-2-selena-es": - return AURA2SELENA_ES; - case "flux-marcelo-en": - return FLUX_MARCELO_EN; - case "flux-elise-en": - return FLUX_ELISE_EN; - case "flux-alexis-en": - return FLUX_ALEXIS_EN; - case "aura-luna-en": - return AURA_LUNA_EN; - case "aura-orpheus-en": - return AURA_ORPHEUS_EN; - case "aura-2-amalthea-en": - return AURA2AMALTHEA_EN; - case "flux-donovan-en": - return FLUX_DONOVAN_EN; - case "aura-2-selene-en": - return AURA2SELENE_EN; - case "flux-tanner-en": - return FLUX_TANNER_EN; - case "flux-sharon-en": - return FLUX_SHARON_EN; - case "aura-2-luna-en": - return AURA2LUNA_EN; - case "aura-2-phoebe-en": - return AURA2PHOEBE_EN; - case "flux-hannah-en": - return FLUX_HANNAH_EN; - case "aura-2-diana-es": - return AURA2DIANA_ES; - case "aura-orion-en": - return AURA_ORION_EN; - case "aura-2-athena-en": - return AURA2ATHENA_EN; - case "aura-arcas-en": - return AURA_ARCAS_EN; - case "aura-2-theia-en": - return AURA2THEIA_EN; - case "flux-wade-en": - return FLUX_WADE_EN; - case "flux-heather-en": - return FLUX_HEATHER_EN; - case "flux-cliff-en": - return FLUX_CLIFF_EN; - case "aura-2-jupiter-en": - return AURA2JUPITER_EN; - case "flux-kit-en": - return FLUX_KIT_EN; - case "aura-2-aquila-es": - return AURA2AQUILA_ES; - case "aura-2-cora-en": - return AURA2CORA_EN; - case "aura-2-cordelia-en": - return AURA2CORDELIA_EN; - case "aura-2-atlas-en": - return AURA2ATLAS_EN; - case "aura-2-hyperion-en": - return AURA2HYPERION_EN; - case "aura-2-celeste-es": - return AURA2CELESTE_ES; - case "aura-2-pluto-en": - return AURA2PLUTO_EN; - case "flux-bree-en": - return FLUX_BREE_EN; - case "aura-2-arcas-en": - return AURA2ARCAS_EN; - case "flux-colin-en": - return FLUX_COLIN_EN; - case "aura-athena-en": - return AURA_ATHENA_EN; - case "aura-2-odysseus-en": - return AURA2ODYSSEUS_EN; - case "aura-2-pandora-en": - return AURA2PANDORA_EN; - case "flux-miles-en": - return FLUX_MILES_EN; - case "aura-asteria-en": - return AURA_ASTERIA_EN; - case "aura-2-electra-en": - return AURA2ELECTRA_EN; - case "flux-gemma-en": - return FLUX_GEMMA_EN; - case "aura-2-estrella-es": - return AURA2ESTRELLA_ES; - default: - return new DeepgramModel(Value.UNKNOWN, value); - } - } - - public enum Value { - AURA_ASTERIA_EN, - - AURA_LUNA_EN, - - AURA_STELLA_EN, - - AURA_ATHENA_EN, - - AURA_HERA_EN, - - AURA_ORION_EN, - - AURA_ARCAS_EN, - - AURA_PERSEUS_EN, - - AURA_ANGUS_EN, - - AURA_ORPHEUS_EN, - - AURA_HELIOS_EN, - - AURA_ZEUS_EN, - - AURA2AMALTHEA_EN, - - AURA2ANDROMEDA_EN, - - AURA2APOLLO_EN, - - AURA2ARCAS_EN, - - AURA2ARIES_EN, - - AURA2ASTERIA_EN, - - AURA2ATHENA_EN, - - AURA2ATLAS_EN, - - AURA2AURORA_EN, - - AURA2CALLISTA_EN, - - AURA2CORA_EN, - - AURA2CORDELIA_EN, - - AURA2DELIA_EN, - - AURA2DRACO_EN, - - AURA2ELECTRA_EN, - - AURA2HARMONIA_EN, - - AURA2HELENA_EN, - - AURA2HERA_EN, - - AURA2HERMES_EN, - - AURA2HYPERION_EN, - - AURA2IRIS_EN, - - AURA2JANUS_EN, - - AURA2JUNO_EN, - - AURA2JUPITER_EN, - - AURA2LUNA_EN, - - AURA2MARS_EN, - - AURA2MINERVA_EN, - - AURA2NEPTUNE_EN, - - AURA2ODYSSEUS_EN, - - AURA2OPHELIA_EN, - - AURA2ORION_EN, - - AURA2ORPHEUS_EN, - - AURA2PANDORA_EN, - - AURA2PHOEBE_EN, - - AURA2PLUTO_EN, - - AURA2SATURN_EN, - - AURA2SELENE_EN, - - AURA2THALIA_EN, - - AURA2THEIA_EN, - - AURA2VESTA_EN, - - AURA2ZEUS_EN, - - AURA2SIRIO_ES, - - AURA2NESTOR_ES, - - AURA2CARINA_ES, - - AURA2CELESTE_ES, - - AURA2ALVARO_ES, - - AURA2DIANA_ES, - - AURA2AQUILA_ES, - - AURA2SELENA_ES, - - AURA2ESTRELLA_ES, - - AURA2JAVIER_ES, - - FLUX_ALEXIS_EN, - - FLUX_BREE_EN, - - FLUX_BRITTANY_EN, - - FLUX_BROOKE_EN, - - FLUX_BRUCE_EN, - - FLUX_CLIFF_EN, - - FLUX_COLE_EN, - - FLUX_COLIN_EN, - - FLUX_CONOR_EN, - - FLUX_DONOVAN_EN, - - FLUX_DREW_EN, - - FLUX_ELISE_EN, - - FLUX_GEMMA_EN, - - FLUX_HALEY_EN, - - FLUX_HANNAH_EN, - - FLUX_HEATHER_EN, - - FLUX_JACK_EN, - - FLUX_KAI_EN, - - FLUX_KELSEY_EN, - - FLUX_RENEE_EN, - - FLUX_KIT_EN, - - FLUX_MAEVE_EN, - - FLUX_MARCELO_EN, - - FLUX_MARCUS_EN, - - FLUX_MEENA_EN, - - FLUX_MEGHAN_EN, - - FLUX_MILES_EN, - - FLUX_NAVEEN_EN, - - FLUX_PAIGE_EN, - - FLUX_PRIYA_EN, - - FLUX_RUFUS_EN, - - FLUX_SEAN_EN, - - FLUX_SHARON_EN, - - FLUX_SIENNA_EN, - - FLUX_TANNER_EN, - - FLUX_WADE_EN, - - FLUX_WES_EN, - - UNKNOWN - } - - public interface Visitor { - T visitAuraAsteriaEn(); - - T visitAuraLunaEn(); - - T visitAuraStellaEn(); - - T visitAuraAthenaEn(); - - T visitAuraHeraEn(); - - T visitAuraOrionEn(); - - T visitAuraArcasEn(); - - T visitAuraPerseusEn(); - - T visitAuraAngusEn(); - - T visitAuraOrpheusEn(); - - T visitAuraHeliosEn(); - - T visitAuraZeusEn(); - - T visitAura2AmaltheaEn(); - - T visitAura2AndromedaEn(); - - T visitAura2ApolloEn(); - - T visitAura2ArcasEn(); - - T visitAura2AriesEn(); - - T visitAura2AsteriaEn(); - - T visitAura2AthenaEn(); - - T visitAura2AtlasEn(); - - T visitAura2AuroraEn(); - - T visitAura2CallistaEn(); - - T visitAura2CoraEn(); - - T visitAura2CordeliaEn(); - - T visitAura2DeliaEn(); - - T visitAura2DracoEn(); - - T visitAura2ElectraEn(); - - T visitAura2HarmoniaEn(); - - T visitAura2HelenaEn(); - - T visitAura2HeraEn(); - - T visitAura2HermesEn(); - - T visitAura2HyperionEn(); - - T visitAura2IrisEn(); - - T visitAura2JanusEn(); - - T visitAura2JunoEn(); - - T visitAura2JupiterEn(); - - T visitAura2LunaEn(); - - T visitAura2MarsEn(); - - T visitAura2MinervaEn(); - - T visitAura2NeptuneEn(); - - T visitAura2OdysseusEn(); - - T visitAura2OpheliaEn(); - - T visitAura2OrionEn(); - - T visitAura2OrpheusEn(); - - T visitAura2PandoraEn(); - - T visitAura2PhoebeEn(); - - T visitAura2PlutoEn(); - - T visitAura2SaturnEn(); - - T visitAura2SeleneEn(); - - T visitAura2ThaliaEn(); - - T visitAura2TheiaEn(); - - T visitAura2VestaEn(); - - T visitAura2ZeusEn(); - - T visitAura2SirioEs(); - - T visitAura2NestorEs(); - - T visitAura2CarinaEs(); - - T visitAura2CelesteEs(); - - T visitAura2AlvaroEs(); - - T visitAura2DianaEs(); - - T visitAura2AquilaEs(); - - T visitAura2SelenaEs(); - - T visitAura2EstrellaEs(); - - T visitAura2JavierEs(); - - T visitFluxAlexisEn(); - - T visitFluxBreeEn(); - - T visitFluxBrittanyEn(); - - T visitFluxBrookeEn(); - - T visitFluxBruceEn(); - - T visitFluxCliffEn(); - - T visitFluxColeEn(); - - T visitFluxColinEn(); - - T visitFluxConorEn(); - - T visitFluxDonovanEn(); - - T visitFluxDrewEn(); - - T visitFluxEliseEn(); - - T visitFluxGemmaEn(); - - T visitFluxHaleyEn(); - - T visitFluxHannahEn(); - - T visitFluxHeatherEn(); - - T visitFluxJackEn(); - - T visitFluxKaiEn(); - - T visitFluxKelseyEn(); - - /** - * @deprecated {@code flux-renee-en} is an unlisted voice and may be removed in a future major - * release. Prefer a listed Flux voice; {@code GET /v2/models} returns the current catalog. - */ - @Deprecated - T visitFluxReneeEn(); - - T visitFluxKitEn(); - - T visitFluxMaeveEn(); - - T visitFluxMarceloEn(); - - T visitFluxMarcusEn(); - - T visitFluxMeenaEn(); - - T visitFluxMeghanEn(); - - T visitFluxMilesEn(); - - T visitFluxNaveenEn(); - - T visitFluxPaigeEn(); - - T visitFluxPriyaEn(); - - T visitFluxRufusEn(); - - T visitFluxSeanEn(); - - T visitFluxSharonEn(); - - T visitFluxSiennaEn(); - - T visitFluxTannerEn(); - - T visitFluxWadeEn(); - - T visitFluxWesEn(); - - T visitUnknown(String unknownType); - } -} diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java index 6591875..a236c7e 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java @@ -13,6 +13,13 @@ public final class DeepgramThinkProviderModel { public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA2FP8 = new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA2FP8, "phonellm-mini-alpha-2-fp8"); + /** + * @deprecated Use {@link #PHONELLM_MINI_ALPHA2FP8}. Retained for source compatibility with + * SDK versions that used an underscore before {@code 2}. + */ + @Deprecated + public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA_2_FP8 = PHONELLM_MINI_ALPHA2FP8; + private final Value value; private final String string; diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java index 44acbff..d093a02 100644 --- a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java +++ b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java @@ -159,7 +159,9 @@ public interface Visitor { T visitGroq(Groq groq); - T visitDeepgram(DeepgramThinkProvider deepgram); + default T visitDeepgram(DeepgramThinkProvider deepgram) { + return _visitUnknown(deepgram); + } T _visitUnknown(Object unknownType); } diff --git a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak b/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak deleted file mode 100644 index d093a02..0000000 --- a/src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java.bak +++ /dev/null @@ -1,458 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.deepgram.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class ThinkSettingsV1Provider { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private ThinkSettingsV1Provider(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static ThinkSettingsV1Provider openAi(OpenAiThinkProvider value) { - return new ThinkSettingsV1Provider(new OpenAiValue(value)); - } - - public static ThinkSettingsV1Provider awsBedrock(AwsBedrockThinkProvider value) { - return new ThinkSettingsV1Provider(new AwsBedrockValue(value)); - } - - public static ThinkSettingsV1Provider anthropic(Anthropic value) { - return new ThinkSettingsV1Provider(new AnthropicValue(value)); - } - - public static ThinkSettingsV1Provider google(Google value) { - return new ThinkSettingsV1Provider(new GoogleValue(value)); - } - - public static ThinkSettingsV1Provider groq(Groq value) { - return new ThinkSettingsV1Provider(new GroqValue(value)); - } - - public static ThinkSettingsV1Provider deepgram(DeepgramThinkProvider value) { - return new ThinkSettingsV1Provider(new DeepgramValue(value)); - } - - public boolean isOpenAi() { - return value instanceof OpenAiValue; - } - - public boolean isAwsBedrock() { - return value instanceof AwsBedrockValue; - } - - public boolean isAnthropic() { - return value instanceof AnthropicValue; - } - - public boolean isGoogle() { - return value instanceof GoogleValue; - } - - public boolean isGroq() { - return value instanceof GroqValue; - } - - public boolean isDeepgram() { - return value instanceof DeepgramValue; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getOpenAi() { - if (isOpenAi()) { - return Optional.of(((OpenAiValue) value).value); - } - return Optional.empty(); - } - - public Optional getAwsBedrock() { - if (isAwsBedrock()) { - return Optional.of(((AwsBedrockValue) value).value); - } - return Optional.empty(); - } - - public Optional getAnthropic() { - if (isAnthropic()) { - return Optional.of(((AnthropicValue) value).value); - } - return Optional.empty(); - } - - public Optional getGoogle() { - if (isGoogle()) { - return Optional.of(((GoogleValue) value).value); - } - return Optional.empty(); - } - - public Optional getGroq() { - if (isGroq()) { - return Optional.of(((GroqValue) value).value); - } - return Optional.empty(); - } - - public Optional getDeepgram() { - if (isDeepgram()) { - return Optional.of(((DeepgramValue) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ThinkSettingsV1Provider && value.equals(((ThinkSettingsV1Provider) other).value); - } - - @Override - public int hashCode() { - return Objects.hash(value); - } - - @Override - public String toString() { - return value.toString(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitOpenAi(OpenAiThinkProvider openAi); - - T visitAwsBedrock(AwsBedrockThinkProvider awsBedrock); - - T visitAnthropic(Anthropic anthropic); - - T visitGoogle(Google google); - - T visitGroq(Groq groq); - - default T visitDeepgram(DeepgramThinkProvider deepgram) { - return _visitUnknown(deepgram); - } - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) - @JsonSubTypes({ - @JsonSubTypes.Type(OpenAiValue.class), - @JsonSubTypes.Type(AwsBedrockValue.class), - @JsonSubTypes.Type(AnthropicValue.class), - @JsonSubTypes.Type(GoogleValue.class), - @JsonSubTypes.Type(GroqValue.class), - @JsonSubTypes.Type(DeepgramValue.class) - }) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("open_ai") - @JsonIgnoreProperties("type") - private static final class OpenAiValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private OpenAiThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private OpenAiValue() {} - - private OpenAiValue(OpenAiThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitOpenAi(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof OpenAiValue && equalTo((OpenAiValue) other); - } - - private boolean equalTo(OpenAiValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("aws_bedrock") - @JsonIgnoreProperties("type") - private static final class AwsBedrockValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private AwsBedrockThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private AwsBedrockValue() {} - - private AwsBedrockValue(AwsBedrockThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitAwsBedrock(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AwsBedrockValue && equalTo((AwsBedrockValue) other); - } - - private boolean equalTo(AwsBedrockValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("anthropic") - @JsonIgnoreProperties("type") - private static final class AnthropicValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Anthropic value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private AnthropicValue() {} - - private AnthropicValue(Anthropic value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitAnthropic(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AnthropicValue && equalTo((AnthropicValue) other); - } - - private boolean equalTo(AnthropicValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("google") - @JsonIgnoreProperties("type") - private static final class GoogleValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Google value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private GoogleValue() {} - - private GoogleValue(Google value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitGoogle(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GoogleValue && equalTo((GoogleValue) other); - } - - private boolean equalTo(GoogleValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("groq") - @JsonIgnoreProperties("type") - private static final class GroqValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private Groq value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private GroqValue() {} - - private GroqValue(Groq value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitGroq(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GroqValue && equalTo((GroqValue) other); - } - - private boolean equalTo(GroqValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonTypeName("deepgram") - @JsonIgnoreProperties("type") - private static final class DeepgramValue implements Value { - @JsonUnwrapped - @JsonIgnoreProperties(value = "type", allowSetters = true) - private DeepgramThinkProvider value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private DeepgramValue() {} - - private DeepgramValue(DeepgramThinkProvider value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitDeepgram(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeepgramValue && equalTo((DeepgramValue) other); - } - - private boolean equalTo(DeepgramValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "value: " + value + "}"; - } - } - - @JsonIgnoreProperties("type") - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "ThinkSettingsV1Provider{" + "type: " + type + ", value: " + value + "}"; - } - } -} From 35d7e2ca5a26fd2c655602da44c7a043733e2325 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 12 Nov 2026 13:02:22 +0000 Subject: [PATCH 5/8] test(regen): cover regenerated API surface --- .fern/metadata.json | 4 +- examples/agent/ProviderCombinations.java | 2 +- .../IntegrationTestAgentThinkProvider.java | 2 +- .../com/deepgram/ListenV1ConnectWireTest.java | 12 ++++++ .../ListenV1LanguageHintRestWireTest.java | 17 +++++--- .../com/deepgram/ListenV2ConnectWireTest.java | 12 ++++++ .../ListenV2ControlFrameWireTest.java | 9 ++++ .../deepgram/ListenV2ForwardCompatTest.java | 21 ++++++++++ .../java/com/deepgram/RegenTypesTest.java | 42 ++++++++++++++++++- .../java/com/deepgram/SpeakV2BatchTest.java | 32 ++++++++++++++ .../com/deepgram/SpeakV2ConnectWireTest.java | 18 ++++++-- 11 files changed, 156 insertions(+), 15 deletions(-) diff --git a/.fern/metadata.json b/.fern/metadata.json index 889baac..2ad9c1e 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -15,5 +15,5 @@ "originGitCommit": "229defd4c32f220af07902c24efca5e94b4c47a4", "originGitCommitIsDirty": true, "invokedBy": "manual", - "sdkVersion": "0.11.5" -} \ No newline at end of file + "sdkVersion": "0.11.4" +} diff --git a/examples/agent/ProviderCombinations.java b/examples/agent/ProviderCombinations.java index 79e8de4..c1dfff5 100644 --- a/examples/agent/ProviderCombinations.java +++ b/examples/agent/ProviderCombinations.java @@ -95,7 +95,7 @@ public static void main(String[] args) { // Combination 4: Deepgram Think + Deepgram Speak System.out.println("=== Combination 4: Deepgram Think + Deepgram ==="); DeepgramThinkProvider deepgramThinkProvider = DeepgramThinkProvider.builder() - .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8) + .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8) .reasoningMode(DeepgramThinkProviderReasoningMode.NONE) .build(); diff --git a/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java index 3ab78f0..9a14781 100644 --- a/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java +++ b/src/test/java/com/deepgram/IntegrationTestAgentThinkProvider.java @@ -46,7 +46,7 @@ void appliesSettingsForEveryDeepgramThinkModelAndReasoningMode() throws Exceptio DeepgramThinkProviderReasoningMode.MEDIUM, DeepgramThinkProviderReasoningMode.HIGH); for (DeepgramThinkProviderModel model : List.of( - DeepgramThinkProviderModel.THINK_FAST, DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8)) { + DeepgramThinkProviderModel.THINK_FAST, DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8)) { for (DeepgramThinkProviderReasoningMode reasoningMode : reasoningModes) { assertSettingsApplied(model, reasoningMode, model.equals(DeepgramThinkProviderModel.THINK_FAST)); } diff --git a/src/test/java/com/deepgram/ListenV1ConnectWireTest.java b/src/test/java/com/deepgram/ListenV1ConnectWireTest.java index 88bf917..68bc617 100644 --- a/src/test/java/com/deepgram/ListenV1ConnectWireTest.java +++ b/src/test/java/com/deepgram/ListenV1ConnectWireTest.java @@ -11,6 +11,7 @@ import com.deepgram.types.ListenV1LanguageHint; import com.deepgram.types.ListenV1Model; import com.deepgram.types.ListenV1Replace; +import com.deepgram.types.ListenV1RedactUsage; import com.deepgram.types.ListenV1Search; import com.deepgram.types.ListenV1Tag; import java.util.List; @@ -175,4 +176,15 @@ void extraListSentAsRepeatedParams() throws Exception { assertThat(url.queryParameterValues("extra")).containsExactly("a:1", "b:2"); } + + @Test + @DisplayName("redact_usage is sent on the connect URL as its wire value when set") + void redactUsagePresentWhenSet() throws Exception { + HttpUrl url = connectAndCaptureUrl(V1ConnectOptions.builder() + .model(ListenV1Model.NOVA3) + .redactUsage(ListenV1RedactUsage.FALSE) + .build()); + + assertThat(url.queryParameterValues("redact_usage")).containsExactly("false"); + } } diff --git a/src/test/java/com/deepgram/ListenV1LanguageHintRestWireTest.java b/src/test/java/com/deepgram/ListenV1LanguageHintRestWireTest.java index 0b7e3fc..a5bfae3 100644 --- a/src/test/java/com/deepgram/ListenV1LanguageHintRestWireTest.java +++ b/src/test/java/com/deepgram/ListenV1LanguageHintRestWireTest.java @@ -41,18 +41,19 @@ void tearDown() throws Exception { } @Test - void sendsRepeatedHintsForEveryUrlAndFileRequestPath() throws Exception { + void sendsLanguageHintsAndRedactUsageForEveryUrlAndFileRequestPath() throws Exception { server.enqueue(new MockResponse().setResponseCode(500).setBody("{}")); try { client.listen().v1().media().transcribeUrl(ListenV1RequestUrl.builder() .url("https://example.com/audio.wav") .model(MediaTranscribeRequestModel.NOVA3) .languageHint(List.of("en", "es")) + .redactUsage(false) .build()); } catch (RuntimeException ignored) { // The response is intentionally an error; this test only captures the outbound URL. } - assertLanguageHints(server.takeRequest(5, TimeUnit.SECONDS)); + assertQueryParameters(server.takeRequest(5, TimeUnit.SECONDS)); server.enqueue(new MockResponse().setResponseCode(500).setBody("{}")); try { @@ -60,11 +61,12 @@ void sendsRepeatedHintsForEveryUrlAndFileRequestPath() throws Exception { .body(new byte[] {1, 2, 3}) .model(MediaTranscribeRequestModel.NOVA3) .languageHint(List.of("en", "es")) + .redactUsage(false) .build()); } catch (RuntimeException ignored) { // The response is intentionally an error; this test only captures the outbound URL. } - assertLanguageHints(server.takeRequest(5, TimeUnit.SECONDS)); + assertQueryParameters(server.takeRequest(5, TimeUnit.SECONDS)); server.enqueue(new MockResponse().setResponseCode(500).setBody("{}")); try { @@ -72,12 +74,13 @@ void sendsRepeatedHintsForEveryUrlAndFileRequestPath() throws Exception { .url("https://example.com/audio.wav") .model(MediaTranscribeRequestModel.NOVA3) .languageHint(List.of("en", "es")) + .redactUsage(false) .build()) .get(5, TimeUnit.SECONDS); } catch (Exception ignored) { // The response is intentionally an error; this test only captures the outbound URL. } - assertLanguageHints(server.takeRequest(5, TimeUnit.SECONDS)); + assertQueryParameters(server.takeRequest(5, TimeUnit.SECONDS)); server.enqueue(new MockResponse().setResponseCode(500).setBody("{}")); try { @@ -85,16 +88,18 @@ void sendsRepeatedHintsForEveryUrlAndFileRequestPath() throws Exception { .body(new byte[] {1, 2, 3}) .model(MediaTranscribeRequestModel.NOVA3) .languageHint(List.of("en", "es")) + .redactUsage(false) .build()) .get(5, TimeUnit.SECONDS); } catch (Exception ignored) { // The response is intentionally an error; this test only captures the outbound URL. } - assertLanguageHints(server.takeRequest(5, TimeUnit.SECONDS)); + assertQueryParameters(server.takeRequest(5, TimeUnit.SECONDS)); } - private void assertLanguageHints(RecordedRequest request) { + private void assertQueryParameters(RecordedRequest request) { assertThat(request).isNotNull(); assertThat(request.getRequestUrl().queryParameterValues("language_hint")).containsExactly("en", "es"); + assertThat(request.getRequestUrl().queryParameterValues("redact_usage")).containsExactly("false"); } } diff --git a/src/test/java/com/deepgram/ListenV2ConnectWireTest.java b/src/test/java/com/deepgram/ListenV2ConnectWireTest.java index 19f8a22..1ba7e50 100644 --- a/src/test/java/com/deepgram/ListenV2ConnectWireTest.java +++ b/src/test/java/com/deepgram/ListenV2ConnectWireTest.java @@ -9,6 +9,7 @@ import com.deepgram.types.ListenV2Model; import com.deepgram.types.ListenV2Numerals; import com.deepgram.types.ListenV2Redact; +import com.deepgram.types.ListenV2RedactUsage; import com.deepgram.types.ListenV2Tag; import java.util.List; import java.util.concurrent.TimeUnit; @@ -172,4 +173,15 @@ void redactOmittedWhenAbsent() throws Exception { assertThat(url.queryParameterNames()).doesNotContain("redact"); } + + @Test + @DisplayName("redact_usage is sent on the connect URL as its wire value when set") + void redactUsagePresentWhenSet() throws Exception { + HttpUrl url = connectAndCaptureUrl(V2ConnectOptions.builder() + .model(ListenV2Model.FLUX_GENERAL_EN) + .redactUsage(ListenV2RedactUsage.FALSE) + .build()); + + assertThat(url.queryParameterValues("redact_usage")).containsExactly("false"); + } } diff --git a/src/test/java/com/deepgram/ListenV2ControlFrameWireTest.java b/src/test/java/com/deepgram/ListenV2ControlFrameWireTest.java index 8c6763b..4bc6a4e 100644 --- a/src/test/java/com/deepgram/ListenV2ControlFrameWireTest.java +++ b/src/test/java/com/deepgram/ListenV2ControlFrameWireTest.java @@ -134,6 +134,15 @@ void sendConfigureNumeralsFalseFrame() throws Exception { assertThat(frame).isEqualTo("{\"numerals\":false,\"type\":\"Configure\"}"); } + @Test + @DisplayName("sendConfigure serializes redact_usage false") + void sendConfigureRedactUsageFalseFrame() throws Exception { + String frame = connectAndCaptureSentFrame(ws -> ws.sendConfigure( + ListenV2Configure.builder().redactUsage(false).build())); + + assertThat(frame).isEqualTo("{\"redact_usage\":false,\"type\":\"Configure\"}"); + } + @Test @DisplayName("sendConfigure serializes no unconfigured fields") void sendConfigureWithoutFieldsFrame() throws Exception { diff --git a/src/test/java/com/deepgram/ListenV2ForwardCompatTest.java b/src/test/java/com/deepgram/ListenV2ForwardCompatTest.java index d603347..8045289 100644 --- a/src/test/java/com/deepgram/ListenV2ForwardCompatTest.java +++ b/src/test/java/com/deepgram/ListenV2ForwardCompatTest.java @@ -3,9 +3,11 @@ import static org.assertj.core.api.Assertions.assertThat; import com.deepgram.core.ClientOptions; +import com.deepgram.resources.listen.v2.types.ListenV2ConfigureSuccess; import com.deepgram.resources.listen.v2.types.ListenV2Warning; import com.deepgram.resources.listen.v2.websocket.V2WebSocketClient; import java.lang.reflect.Method; +import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.DisplayName; @@ -65,4 +67,23 @@ void warningMessageReachesWarningHandler() throws Exception { assertThat(warning.get().getCode()).isEqualTo("FORCE_END_TURN_NO_ACTIVE_TURN"); assertThat(errorCount).hasValue(0); } + + @Test + @DisplayName("ConfigureSuccess redact_usage reaches the typed handler") + void configureSuccessRedactUsageReachesTypedHandler() throws Exception { + V2WebSocketClient client = new V2WebSocketClient(ClientOptions.builder().build()); + + AtomicReference configureSuccess = new AtomicReference<>(); + client.onConfigureSuccess(configureSuccess::set); + + Method handle = V2WebSocketClient.class.getDeclaredMethod("handleIncomingMessage", String.class); + handle.setAccessible(true); + handle.invoke( + client, + "{\"type\":\"ConfigureSuccess\",\"request_id\":\"request-123\",\"thresholds\":{}," + + "\"keyterms\":[\"Deepgram\"],\"redact_usage\":true,\"sequence_id\":1}"); + + assertThat(configureSuccess.get()).isNotNull(); + assertThat(configureSuccess.get().getRedactUsage()).isEqualTo(Optional.of(true)); + } } diff --git a/src/test/java/com/deepgram/RegenTypesTest.java b/src/test/java/com/deepgram/RegenTypesTest.java index 913dc50..072bea8 100644 --- a/src/test/java/com/deepgram/RegenTypesTest.java +++ b/src/test/java/com/deepgram/RegenTypesTest.java @@ -51,6 +51,8 @@ import com.deepgram.types.ThinkSettingsV1FunctionsItem; import com.deepgram.types.ThinkSettingsV1Provider; import com.fasterxml.jackson.databind.ObjectMapper; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -280,7 +282,7 @@ class DeepgramThinkProviderShape { @DisplayName("PhoneLLM round-trips its supported settings") void phoneLlmRoundTrips() throws Exception { DeepgramThinkProvider provider = DeepgramThinkProvider.builder() - .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8) + .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8) .version("v1") .temperature(0.4) .reasoningMode(DeepgramThinkProviderReasoningMode.NONE) @@ -338,6 +340,42 @@ void reasoningModesRoundTrip() throws Exception { assertThat(MAPPER.readValue(json, DeepgramThinkProviderReasoningMode.class)).isEqualTo(reasoningMode); } } + + @Test + @DisplayName("canonical PhoneLLM constant and deprecated alias share the wire value") + void phoneLlmCanonicalConstantAndAliasRoundTrip() throws Exception { + DeepgramThinkProviderModel canonical = DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8; + DeepgramThinkProviderModel deprecated = DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8; + + assertThat(canonical).isSameAs(deprecated); + assertThat(DeepgramThinkProviderModel.valueOf(canonical.toString())).isSameAs(canonical); + assertThat(DeepgramThinkProviderModel.valueOf(deprecated.toString())).isSameAs(canonical); + assertThat(MAPPER.writeValueAsString(canonical)).isEqualTo("\"phonellm-mini-alpha-2-fp8\""); + assertThat(MAPPER.writeValueAsString(deprecated)).isEqualTo("\"phonellm-mini-alpha-2-fp8\""); + assertThat(MAPPER.readValue("\"phonellm-mini-alpha-2-fp8\"", DeepgramThinkProviderModel.class)) + .isSameAs(canonical); + } + } + + @Nested + @DisplayName("DeepgramModel public constants") + class DeepgramModelConstants { + + @Test + @DisplayName("all public constants parse and JSON round-trip as known values") + void publicConstantsRoundTrip() throws Exception { + for (Field field : DeepgramModel.class.getFields()) { + if (field.getType() != DeepgramModel.class || !Modifier.isStatic(field.getModifiers())) { + continue; + } + DeepgramModel model = (DeepgramModel) field.get(null); + + assertThat(model.getEnumValue()).as(field.getName()).isNotEqualTo(DeepgramModel.Value.UNKNOWN); + assertThat(DeepgramModel.valueOf(model.toString())).as(field.getName()).isEqualTo(model); + String json = MAPPER.writeValueAsString(model); + assertThat(MAPPER.readValue(json, DeepgramModel.class)).as(field.getName()).isEqualTo(model); + } + } } @Nested @@ -686,7 +724,7 @@ public String _visitUnknown(Object unknownType) { }; DeepgramThinkProvider deepgram = DeepgramThinkProvider.builder() - .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8) + .model(DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8) .build(); assertThat(ThinkSettingsV1Provider.deepgram(deepgram).visit(visitor)) diff --git a/src/test/java/com/deepgram/SpeakV2BatchTest.java b/src/test/java/com/deepgram/SpeakV2BatchTest.java index 0c26ba1..7489933 100644 --- a/src/test/java/com/deepgram/SpeakV2BatchTest.java +++ b/src/test/java/com/deepgram/SpeakV2BatchTest.java @@ -32,6 +32,7 @@ class SpeakV2BatchTest { private MockWebServer server; private DeepgramClient client; + private AsyncDeepgramClient asyncClient; @BeforeEach void setUp() throws Exception { @@ -40,6 +41,7 @@ void setUp() throws Exception { String base = server.url("/").toString().replaceAll("/$", ""); Environment env = Environment.custom().base(base).production(base).agent(base).agentRest(base).build(); client = DeepgramClient.builder().apiKey("test").environment(env).build(); + asyncClient = AsyncDeepgramClient.builder().apiKey("test").environment(env).build(); } @AfterEach @@ -103,4 +105,34 @@ void integerSampleRateAndBitRate() throws Exception { assertThat(url.queryParameter("sample_rate")).doesNotContain("."); assertThat(url.queryParameter("bit_rate")).doesNotContain("."); } + + @Test + @DisplayName("sync and async batch generation serialize normalize_volume false") + void normalizeVolumeFalse() throws Exception { + enqueueAudio(); + client.speak() + .v2() + .audio() + .generate(SpeakV2Request.builder() + .model("flux-alexis-en") + .text("sync") + .normalizeVolume(false) + .build()) + .readAllBytes(); + + enqueueAudio(); + asyncClient.speak() + .v2() + .audio() + .generate(SpeakV2Request.builder() + .model("flux-alexis-en") + .text("async") + .normalizeVolume(false) + .build()) + .get() + .readAllBytes(); + + assertThat(server.takeRequest().getRequestUrl().queryParameter("normalize_volume")).isEqualTo("false"); + assertThat(server.takeRequest().getRequestUrl().queryParameter("normalize_volume")).isEqualTo("false"); + } } diff --git a/src/test/java/com/deepgram/SpeakV2ConnectWireTest.java b/src/test/java/com/deepgram/SpeakV2ConnectWireTest.java index 5d899ef..6bd8176 100644 --- a/src/test/java/com/deepgram/SpeakV2ConnectWireTest.java +++ b/src/test/java/com/deepgram/SpeakV2ConnectWireTest.java @@ -8,6 +8,7 @@ import com.deepgram.resources.speak.v2.types.SpeakV2InterruptPlaybackOffset; import com.deepgram.resources.speak.v2.websocket.V2ConnectOptions; import com.deepgram.resources.speak.v2.websocket.V2WebSocketClient; +import com.deepgram.types.SpeakV2NormalizeVolume; import com.deepgram.types.SpeakV2Tag; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -116,12 +117,23 @@ void expressivityPresentWhenSet() throws Exception { } @Test - @DisplayName("speed/expressivity are omitted from the connect URL when not set") - void speedExpressivityOmittedWhenAbsent() throws Exception { + @DisplayName("speed, expressivity, and normalize_volume are omitted from the connect URL when not set") + void optionalParametersOmittedWhenAbsent() throws Exception { HttpUrl url = connectAndCaptureUrl( V2ConnectOptions.builder().model("flux-alexis-en").build()); - assertThat(url.queryParameterNames()).doesNotContain("speed", "expressivity"); + assertThat(url.queryParameterNames()).doesNotContain("speed", "expressivity", "normalize_volume"); + } + + @Test + @DisplayName("normalize_volume is sent on the connect URL as its wire value when set") + void normalizeVolumePresentWhenSet() throws Exception { + HttpUrl url = connectAndCaptureUrl(V2ConnectOptions.builder() + .model("flux-alexis-en") + .normalizeVolume(SpeakV2NormalizeVolume.FALSE) + .build()); + + assertThat(url.queryParameter("normalize_volume")).isEqualTo("false"); } /** Connects, keeps the socket open, runs {@code action}, and returns the first frame the server received. */ From 6ca044f96524bb4329778acaa9f3896072a7e193 Mon Sep 17 00:00:00 2001 From: Corey Weathers Date: Thu, 12 Nov 2026 10:03:42 -0500 Subject: [PATCH 6/8] fix: preserve Value enum constant name for Think-provider model binary compat Fern's regen renamed the DeepgramThinkProviderModel.Value enum constant from PHONELLM_MINI_ALPHA_2_FP8 to PHONELLM_MINI_ALPHA2FP8 alongside the public static field rename. The static field already carries a deprecated alias, but the enum constant itself has no such shim: code compiled against the previous release that switches on getEnumValue() using the old constant name silently falls through to the default case instead of matching, because Java's enum-switch desugaring resolves the old field name via a direct field reference at the caller's class-load time. Keep the Value enum constant named PHONELLM_MINI_ALPHA_2_FP8 (matching the previous release) while keeping the new PHONELLM_MINI_ALPHA2FP8 name only on the public static field, the same compatibility pattern already used elsewhere in this file. --- AGENTS.md | 2 +- .../java/com/deepgram/types/DeepgramThinkProviderModel.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7e14b27..ffddc39 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,7 @@ Current temporarily frozen files: - `src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java` - Agent V1 already delivers every raw control frame through `onMessage(String)`. Suppress generic errors for unknown frames only when a raw handler is registered; otherwise retain legacy `onError` delivery. Preserve the generated Think Live, dynamic-injection, and frustration handlers during reconciliation. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java` restores the legacy `content(...): _FinalStage` builder stage and defaults omitted or empty `conversational_behavior` to `default`. The schema now requires the wire field, while this shim preserves source and binary compatibility for callers compiled before Think Live existed. `ConversationalBehaviorStage` remains as an intentionally retained generated type, even though the restored legacy stage no longer returns it. - `src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java` makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility with implementations compiled before the provider existed. Fern now generates the distinct Think provider and model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`; retain only this Visitor default until Fern generates it or the next major release. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`. -- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. Guarded by the Think-provider regression tests. +- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` static-field alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. The patch also keeps the internal `Value` enum constant named `PHONELLM_MINI_ALPHA_2_FP8` (not renamed to match the static field) because a Java enum-switch resolves by the old ordinal/name at the bytecode level: code compiled against the previous release that switches on `getEnumValue()` using the old name silently falls through to `default` instead of erroring if the enum constant is renamed, even though the public static field alias keeps "pass it as a value" usage working. Re-apply both the alias and the un-renamed `Value` constant after regen until Fern stops renaming enum constants outright on this kind of rename. Guarded by the Think-provider regression tests. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java` - fields-less event type with a manual `hashCode()` patch. Fern generates `equals()` but no matching `hashCode()`, violating the Object contract; retain the patch, freeze entry, and `RegenTypesTest.FieldsLessMessageContract` assertion until Fern fixes the pattern. - `src/main/java/com/deepgram/core/ClientOptions.java` - preserves release-please version markers, correct SDK header constants, and the accurate `close()` lifecycle Javadoc that Fern currently overwrites; use the standard `.bak` swap/restore workflow during regen review. Since generator 4.18.0 Fern emits a `getSdkVersion()` helper reading `Package.getImplementationVersion()` instead of a literal. That *does* resolve in the published artifact (CI publishes via `./mvnw deploy -P release`, and `pom.xml`'s maven-jar-plugin sets `addDefaultImplementationEntries=true`, so the JAR manifest carries `Implementation-Version`), but it resolves to `null` under Gradle and in tests, where it silently falls back to a hardcoded literal the generator does not keep current. We keep the explicit literals because they are correct in every context and because `.github/release-please-config.json` already lists this file in `extra-files`, so release-please bumps it alongside `pom.xml`, `build.gradle`, and `.fern/metadata.json`. Fern also emits `User-Agent` with a `com.deepgram.` prefix while leaving `X-Fern-SDK-Name` on the `com.deepgram:` Maven-coordinate form; we keep both on the colon form. Fern 4.22.1 tracks and closes child WebSockets before shutting down SDK-owned OkHttp resources; the permanent custom client wrappers inherit it, so do not add wrapper-local lifecycle code and retain Fern's lifecycle implementation during reconciliation. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` - carries bug fixes for `maxRetries(0)` semantics ("connect once, don't retry") and a configurable `connectionTimeoutMs` field (was hardcoded 4000ms), plus an `applyOptionsOverride(...)` hook used by `TransportWebSocketFactory` to apply per-transport reconnect policy; pull this back out once the fixes are upstreamed into the Fern generator. Use the standard `.bak` swap/restore workflow during regen review. diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java index a236c7e..f910809 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java @@ -11,7 +11,7 @@ public final class DeepgramThinkProviderModel { new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA2FP8 = - new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA2FP8, "phonellm-mini-alpha-2-fp8"); + new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); /** * @deprecated Use {@link #PHONELLM_MINI_ALPHA2FP8}. Retained for source compatibility with @@ -55,7 +55,7 @@ public T visit(Visitor visitor) { switch (value) { case THINK_FAST: return visitor.visitThinkFast(); - case PHONELLM_MINI_ALPHA2FP8: + case PHONELLM_MINI_ALPHA_2_FP8: return visitor.visitPhonellmMiniAlpha2Fp8(); case UNKNOWN: default: @@ -78,7 +78,7 @@ public static DeepgramThinkProviderModel valueOf(String value) { public enum Value { THINK_FAST, - PHONELLM_MINI_ALPHA2FP8, + PHONELLM_MINI_ALPHA_2_FP8, UNKNOWN } From cc93e3a01ab27fd27f65edec827e31c9e3095d6e Mon Sep 17 00:00:00 2001 From: Corey Weathers Date: Thu, 12 Nov 2026 10:33:15 -0500 Subject: [PATCH 7/8] Revert "fix: preserve Value enum constant name for Think-provider model binary compat" This reverts commit 6ca044f96524bb4329778acaa9f3896072a7e193. --- AGENTS.md | 2 +- .../java/com/deepgram/types/DeepgramThinkProviderModel.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ffddc39..7e14b27 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,7 @@ Current temporarily frozen files: - `src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java` - Agent V1 already delivers every raw control frame through `onMessage(String)`. Suppress generic errors for unknown frames only when a raw handler is registered; otherwise retain legacy `onError` delivery. Preserve the generated Think Live, dynamic-injection, and frustration handlers during reconciliation. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java` restores the legacy `content(...): _FinalStage` builder stage and defaults omitted or empty `conversational_behavior` to `default`. The schema now requires the wire field, while this shim preserves source and binary compatibility for callers compiled before Think Live existed. `ConversationalBehaviorStage` remains as an intentionally retained generated type, even though the restored legacy stage no longer returns it. - `src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java` makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility with implementations compiled before the provider existed. Fern now generates the distinct Think provider and model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`; retain only this Visitor default until Fern generates it or the next major release. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`. -- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` static-field alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. The patch also keeps the internal `Value` enum constant named `PHONELLM_MINI_ALPHA_2_FP8` (not renamed to match the static field) because a Java enum-switch resolves by the old ordinal/name at the bytecode level: code compiled against the previous release that switches on `getEnumValue()` using the old name silently falls through to `default` instead of erroring if the enum constant is renamed, even though the public static field alias keeps "pass it as a value" usage working. Re-apply both the alias and the un-renamed `Value` constant after regen until Fern stops renaming enum constants outright on this kind of rename. Guarded by the Think-provider regression tests. +- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. Guarded by the Think-provider regression tests. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java` - fields-less event type with a manual `hashCode()` patch. Fern generates `equals()` but no matching `hashCode()`, violating the Object contract; retain the patch, freeze entry, and `RegenTypesTest.FieldsLessMessageContract` assertion until Fern fixes the pattern. - `src/main/java/com/deepgram/core/ClientOptions.java` - preserves release-please version markers, correct SDK header constants, and the accurate `close()` lifecycle Javadoc that Fern currently overwrites; use the standard `.bak` swap/restore workflow during regen review. Since generator 4.18.0 Fern emits a `getSdkVersion()` helper reading `Package.getImplementationVersion()` instead of a literal. That *does* resolve in the published artifact (CI publishes via `./mvnw deploy -P release`, and `pom.xml`'s maven-jar-plugin sets `addDefaultImplementationEntries=true`, so the JAR manifest carries `Implementation-Version`), but it resolves to `null` under Gradle and in tests, where it silently falls back to a hardcoded literal the generator does not keep current. We keep the explicit literals because they are correct in every context and because `.github/release-please-config.json` already lists this file in `extra-files`, so release-please bumps it alongside `pom.xml`, `build.gradle`, and `.fern/metadata.json`. Fern also emits `User-Agent` with a `com.deepgram.` prefix while leaving `X-Fern-SDK-Name` on the `com.deepgram:` Maven-coordinate form; we keep both on the colon form. Fern 4.22.1 tracks and closes child WebSockets before shutting down SDK-owned OkHttp resources; the permanent custom client wrappers inherit it, so do not add wrapper-local lifecycle code and retain Fern's lifecycle implementation during reconciliation. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` - carries bug fixes for `maxRetries(0)` semantics ("connect once, don't retry") and a configurable `connectionTimeoutMs` field (was hardcoded 4000ms), plus an `applyOptionsOverride(...)` hook used by `TransportWebSocketFactory` to apply per-transport reconnect policy; pull this back out once the fixes are upstreamed into the Fern generator. Use the standard `.bak` swap/restore workflow during regen review. diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java index f910809..a236c7e 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java @@ -11,7 +11,7 @@ public final class DeepgramThinkProviderModel { new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA2FP8 = - new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); + new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA2FP8, "phonellm-mini-alpha-2-fp8"); /** * @deprecated Use {@link #PHONELLM_MINI_ALPHA2FP8}. Retained for source compatibility with @@ -55,7 +55,7 @@ public T visit(Visitor visitor) { switch (value) { case THINK_FAST: return visitor.visitThinkFast(); - case PHONELLM_MINI_ALPHA_2_FP8: + case PHONELLM_MINI_ALPHA2FP8: return visitor.visitPhonellmMiniAlpha2Fp8(); case UNKNOWN: default: @@ -78,7 +78,7 @@ public static DeepgramThinkProviderModel valueOf(String value) { public enum Value { THINK_FAST, - PHONELLM_MINI_ALPHA_2_FP8, + PHONELLM_MINI_ALPHA2FP8, UNKNOWN } From b9a8acef5cb15e32a4da2de843ecf4be51cb2ac6 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Thu, 12 Nov 2026 16:37:50 +0000 Subject: [PATCH 8/8] fix: preserve PhoneLLM enum switch compatibility --- AGENTS.md | 2 +- .../types/DeepgramThinkProviderModel.java | 6 +++--- .../java/com/deepgram/RegenTypesTest.java | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 7e14b27..ffddc39 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -52,7 +52,7 @@ Current temporarily frozen files: - `src/main/java/com/deepgram/resources/agent/v1/websocket/V1WebSocketClient.java` - Agent V1 already delivers every raw control frame through `onMessage(String)`. Suppress generic errors for unknown frames only when a raw handler is registered; otherwise retain legacy `onError` delivery. Preserve the generated Think Live, dynamic-injection, and frustration handlers during reconciliation. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ConversationText.java` restores the legacy `content(...): _FinalStage` builder stage and defaults omitted or empty `conversational_behavior` to `default`. The schema now requires the wire field, while this shim preserves source and binary compatibility for callers compiled before Think Live existed. `ConversationalBehaviorStage` remains as an intentionally retained generated type, even though the restored legacy stage no longer returns it. - `src/main/java/com/deepgram/types/ThinkSettingsV1Provider.java` makes `Visitor.visitDeepgram(DeepgramThinkProvider)` default to `_visitUnknown` for source and binary compatibility with implementations compiled before the provider existed. Fern now generates the distinct Think provider and model types (`think-fast` and `phonellm-mini-alpha-2-fp8`), including `temperature`, `reasoning_mode`, and `voice_prompt_opt_out`; retain only this Visitor default until Fern generates it or the next major release. Guarded by `src/test/java/com/deepgram/RegenTypesTest.java` and `AgentV1ThinkLiveWireTest.java`. -- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. Guarded by the Think-provider regression tests. +- `src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java` retains the deprecated `PHONELLM_MINI_ALPHA_2_FP8` static-field alias after Fern renamed the generated constant to `PHONELLM_MINI_ALPHA2FP8`. Both represent `phonellm-mini-alpha-2-fp8`; keep the alias until the next major release to avoid a source break. The patch also keeps the internal `Value` enum constant named `PHONELLM_MINI_ALPHA_2_FP8` (not renamed to match the static field) because a Java enum-switch resolves by the old ordinal/name at the bytecode level: code compiled against the previous release that switches on `getEnumValue()` using the old name silently falls through to `default` instead of erroring if the enum constant is renamed, even though the public static field alias keeps "pass it as a value" usage working. Re-apply both the alias and the un-renamed `Value` constant after regen until Fern stops renaming enum constants outright on this kind of rename. Guarded by the Think-provider regression tests. - `src/main/java/com/deepgram/resources/agent/v1/types/AgentV1ThinkLiveUpdated.java` - fields-less event type with a manual `hashCode()` patch. Fern generates `equals()` but no matching `hashCode()`, violating the Object contract; retain the patch, freeze entry, and `RegenTypesTest.FieldsLessMessageContract` assertion until Fern fixes the pattern. - `src/main/java/com/deepgram/core/ClientOptions.java` - preserves release-please version markers, correct SDK header constants, and the accurate `close()` lifecycle Javadoc that Fern currently overwrites; use the standard `.bak` swap/restore workflow during regen review. Since generator 4.18.0 Fern emits a `getSdkVersion()` helper reading `Package.getImplementationVersion()` instead of a literal. That *does* resolve in the published artifact (CI publishes via `./mvnw deploy -P release`, and `pom.xml`'s maven-jar-plugin sets `addDefaultImplementationEntries=true`, so the JAR manifest carries `Implementation-Version`), but it resolves to `null` under Gradle and in tests, where it silently falls back to a hardcoded literal the generator does not keep current. We keep the explicit literals because they are correct in every context and because `.github/release-please-config.json` already lists this file in `extra-files`, so release-please bumps it alongside `pom.xml`, `build.gradle`, and `.fern/metadata.json`. Fern also emits `User-Agent` with a `com.deepgram.` prefix while leaving `X-Fern-SDK-Name` on the `com.deepgram:` Maven-coordinate form; we keep both on the colon form. Fern 4.22.1 tracks and closes child WebSockets before shutting down SDK-owned OkHttp resources; the permanent custom client wrappers inherit it, so do not add wrapper-local lifecycle code and retain Fern's lifecycle implementation during reconciliation. - `src/main/java/com/deepgram/core/ReconnectingWebSocketListener.java` - carries bug fixes for `maxRetries(0)` semantics ("connect once, don't retry") and a configurable `connectionTimeoutMs` field (was hardcoded 4000ms), plus an `applyOptionsOverride(...)` hook used by `TransportWebSocketFactory` to apply per-transport reconnect policy; pull this back out once the fixes are upstreamed into the Fern generator. Use the standard `.bak` swap/restore workflow during regen review. diff --git a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java index a236c7e..f910809 100644 --- a/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java +++ b/src/main/java/com/deepgram/types/DeepgramThinkProviderModel.java @@ -11,7 +11,7 @@ public final class DeepgramThinkProviderModel { new DeepgramThinkProviderModel(Value.THINK_FAST, "think-fast"); public static final DeepgramThinkProviderModel PHONELLM_MINI_ALPHA2FP8 = - new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA2FP8, "phonellm-mini-alpha-2-fp8"); + new DeepgramThinkProviderModel(Value.PHONELLM_MINI_ALPHA_2_FP8, "phonellm-mini-alpha-2-fp8"); /** * @deprecated Use {@link #PHONELLM_MINI_ALPHA2FP8}. Retained for source compatibility with @@ -55,7 +55,7 @@ public T visit(Visitor visitor) { switch (value) { case THINK_FAST: return visitor.visitThinkFast(); - case PHONELLM_MINI_ALPHA2FP8: + case PHONELLM_MINI_ALPHA_2_FP8: return visitor.visitPhonellmMiniAlpha2Fp8(); case UNKNOWN: default: @@ -78,7 +78,7 @@ public static DeepgramThinkProviderModel valueOf(String value) { public enum Value { THINK_FAST, - PHONELLM_MINI_ALPHA2FP8, + PHONELLM_MINI_ALPHA_2_FP8, UNKNOWN } diff --git a/src/test/java/com/deepgram/RegenTypesTest.java b/src/test/java/com/deepgram/RegenTypesTest.java index 072bea8..8221791 100644 --- a/src/test/java/com/deepgram/RegenTypesTest.java +++ b/src/test/java/com/deepgram/RegenTypesTest.java @@ -348,6 +348,8 @@ void phoneLlmCanonicalConstantAndAliasRoundTrip() throws Exception { DeepgramThinkProviderModel deprecated = DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA_2_FP8; assertThat(canonical).isSameAs(deprecated); + assertThat(canonical.getEnumValue()) + .isEqualTo(DeepgramThinkProviderModel.Value.PHONELLM_MINI_ALPHA_2_FP8); assertThat(DeepgramThinkProviderModel.valueOf(canonical.toString())).isSameAs(canonical); assertThat(DeepgramThinkProviderModel.valueOf(deprecated.toString())).isSameAs(canonical); assertThat(MAPPER.writeValueAsString(canonical)).isEqualTo("\"phonellm-mini-alpha-2-fp8\""); @@ -355,6 +357,23 @@ void phoneLlmCanonicalConstantAndAliasRoundTrip() throws Exception { assertThat(MAPPER.readValue("\"phonellm-mini-alpha-2-fp8\"", DeepgramThinkProviderModel.class)) .isSameAs(canonical); } + + @Test + @DisplayName("canonical PhoneLLM constant matches legacy enum switch cases") + void phoneLlmMatchesLegacyEnumSwitchCase() { + DeepgramThinkProviderModel model = DeepgramThinkProviderModel.PHONELLM_MINI_ALPHA2FP8; + + String result; + switch (model.getEnumValue()) { + case PHONELLM_MINI_ALPHA_2_FP8: + result = "phonellm"; + break; + default: + result = "unknown"; + } + + assertThat(result).isEqualTo("phonellm"); + } } @Nested