Skip to content

Commit a27336e

Browse files
feat(regen): add Flux TTS batch (REST) endpoint and agent latency report (#519)
* chore: initialize SDK regeneration branch * chore: unfreeze files pending regen * SDK regeneration * chore: re-apply manual patches after regen * test: add Flux TTS batch (REST) wire coverage --------- Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 7bba2d2 commit a27336e

27 files changed

Lines changed: 441 additions & 7 deletions

.fern/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"shouldGenerateWebsocketClients": true,
1212
"enableForwardCompatibleEnums": true
1313
},
14-
"originGitCommit": "335af96251466afae7a9f71badb65c630a48626e",
14+
"originGitCommit": "14c0ca94fcd0279d99570389d7b688dc3a18ea41",
1515
"originGitCommitIsDirty": true,
1616
"invokedBy": "manual",
17-
"sdkVersion": "5.5.0"
17+
"sdkVersion": "5.5.1"
1818
}

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tests/unit/error-handling.test.ts
2727
tests/unit/multiple-keyterms.test.ts
2828
tests/unit/nodejs-version-compatibility.test.ts
2929
tests/unit/regen-constraints.test.ts
30+
tests/unit/speak-v2-batch.test.ts
3031
tests/unit/transport-factory.test.ts
3132
tests/unit/websocket-reconnection.test.ts
3233
tests/unit/websocket-wrappers.test.ts

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,17 @@
463463
},
464464
"default": "./dist/cjs/api/resources/speak/resources/v1/resources/audio/exports.js"
465465
},
466+
"./speak/v2/audio": {
467+
"import": {
468+
"types": "./dist/esm/api/resources/speak/resources/v2/resources/audio/exports.d.mts",
469+
"default": "./dist/esm/api/resources/speak/resources/v2/resources/audio/exports.mjs"
470+
},
471+
"require": {
472+
"types": "./dist/cjs/api/resources/speak/resources/v2/resources/audio/exports.d.ts",
473+
"default": "./dist/cjs/api/resources/speak/resources/v2/resources/audio/exports.js"
474+
},
475+
"default": "./dist/cjs/api/resources/speak/resources/v2/resources/audio/exports.js"
476+
},
466477
"./voiceAgent": {
467478
"import": {
468479
"types": "./dist/esm/api/resources/voiceAgent/exports.d.mts",

reference.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,6 +2930,73 @@ await client.speak.v1.audio.generate({
29302930
</dl>
29312931

29322932

2933+
</dd>
2934+
</dl>
2935+
</details>
2936+
2937+
## Speak V2 Audio
2938+
<details><summary><code>client.speak.v2.audio.<a href="/src/api/resources/speak/resources/v2/resources/audio/client/Client.ts">generate</a>({ ...params }) -> core.BinaryResponse</code></summary>
2939+
<dl>
2940+
<dd>
2941+
2942+
#### 📝 Description
2943+
2944+
<dl>
2945+
<dd>
2946+
2947+
<dl>
2948+
<dd>
2949+
2950+
Synthesize a complete block of text into a single audio response using Deepgram's Flux TTS batch (REST) API. Use this for pre-rendering fixed audio (IVR prompts, notifications, narration) where the whole text is known up front and you don't need incremental playback or interruption.
2951+
</dd>
2952+
</dl>
2953+
</dd>
2954+
</dl>
2955+
2956+
#### 🔌 Usage
2957+
2958+
<dl>
2959+
<dd>
2960+
2961+
<dl>
2962+
<dd>
2963+
2964+
```typescript
2965+
await client.speak.v2.audio.generate({
2966+
model: "model",
2967+
text: "text"
2968+
});
2969+
2970+
```
2971+
</dd>
2972+
</dl>
2973+
</dd>
2974+
</dl>
2975+
2976+
#### ⚙️ Parameters
2977+
2978+
<dl>
2979+
<dd>
2980+
2981+
<dl>
2982+
<dd>
2983+
2984+
**request:** `Deepgram.speak.v2.SpeakV2Request`
2985+
2986+
</dd>
2987+
</dl>
2988+
2989+
<dl>
2990+
<dd>
2991+
2992+
**requestOptions:** `AudioClient.RequestOptions`
2993+
2994+
</dd>
2995+
</dl>
2996+
</dd>
2997+
</dl>
2998+
2999+
29333000
</dd>
29343001
</dl>
29353002
</details>

src/api/resources/agent/resources/v1/client/Socket.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export declare namespace V1Socket {
2121
| Deepgram.agent.AgentV1ConversationText
2222
| Deepgram.agent.AgentV1UserStartedSpeaking
2323
| Deepgram.agent.AgentV1AgentThinking
24+
| Deepgram.agent.AgentV1LatencyReport
2425
| Deepgram.agent.AgentV1FunctionCallRequest
2526
| Deepgram.agent.AgentV1AgentStartedSpeaking
2627
| Deepgram.agent.AgentV1AgentAudioDone

src/api/resources/agent/resources/v1/types/AgentV1InjectAgentMessage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface AgentV1InjectAgentMessage {
1010
*
1111
* * `default` — The agent speaks only if neither the user nor the agent is mid-turn. If a turn is in progress, the server replies with `InjectionRefused`.
1212
* * `queue` — The message is appended after any already-queued `ConversationText` without interrupting the current agent turn or think response. If nothing is queued, the message plays immediately.
13+
* * `interrupt` — The agent immediately speaks. If the agent was already speaking, it interrupts the current speech and replaces it with the new message. If the user is speaking, the agent interrupts with the new message, but the user's continued speech triggers `UserStartedSpeaking`, which quickly interrupts the agent.
1314
*/
1415
behavior?: AgentV1InjectAgentMessage.Behavior | undefined;
1516
}
@@ -20,10 +21,12 @@ export namespace AgentV1InjectAgentMessage {
2021
*
2122
* * `default` — The agent speaks only if neither the user nor the agent is mid-turn. If a turn is in progress, the server replies with `InjectionRefused`.
2223
* * `queue` — The message is appended after any already-queued `ConversationText` without interrupting the current agent turn or think response. If nothing is queued, the message plays immediately.
24+
* * `interrupt` — The agent immediately speaks. If the agent was already speaking, it interrupts the current speech and replaces it with the new message. If the user is speaking, the agent interrupts with the new message, but the user's continued speech triggers `UserStartedSpeaking`, which quickly interrupts the agent.
2325
*/
2426
export const Behavior = {
2527
Default: "default",
2628
Queue: "queue",
29+
Interrupt: "interrupt",
2730
} as const;
2831
export type Behavior = (typeof Behavior)[keyof typeof Behavior] | string;
2932
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
export interface AgentV1LatencyReport {
4+
/** Message type identifier for the latency report */
5+
type: "LatencyReport";
6+
/** Speech-to-text: time from audio received to transcript produced, in seconds */
7+
stt_latency?: number | undefined;
8+
/** Time to first token of any type (text, tool call, or thinking), in seconds */
9+
ttt_token_latency?: number | undefined;
10+
/** Time to first text token from the LLM, in seconds */
11+
ttt_text_latency?: number | undefined;
12+
/** Time to first tool-call token from the LLM, in seconds */
13+
ttt_tool_latency?: number | undefined;
14+
/** Time to first thinking token from the LLM, in seconds */
15+
ttt_thinking_latency?: number | undefined;
16+
/** Text-to-speech: time from first text token to first audio byte, in seconds */
17+
tts_latency?: number | undefined;
18+
/** End-to-end: time from user utterance end to first audio byte, in seconds */
19+
total_latency?: number | undefined;
20+
}

src/api/resources/agent/resources/v1/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./AgentV1InjectAgentMessage.js";
99
export * from "./AgentV1InjectionRefused.js";
1010
export * from "./AgentV1InjectUserMessage.js";
1111
export * from "./AgentV1KeepAlive.js";
12+
export * from "./AgentV1LatencyReport.js";
1213
export * from "./AgentV1ListenUpdated.js";
1314
export * from "./AgentV1PromptUpdated.js";
1415
export * from "./AgentV1ReceiveFunctionCallResponse.js";

src/api/resources/speak/resources/v2/client/Client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// This file was auto-generated by Fern from our API Definition.
22

33
import type { BaseClientOptions } from "../../../../../../BaseClient.js";
4-
import { type NormalizedClientOptions, normalizeClientOptions } from "../../../../../../BaseClient.js";
4+
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js";
55
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js";
66
import * as core from "../../../../../../core/index.js";
77
import { toJson } from "../../../../../../core/json.js";
88
import * as environments from "../../../../../../environments.js";
99
import type * as Deepgram from "../../../../../index.js";
10+
import { AudioClient } from "../resources/audio/client/Client.js";
1011
import { V2Socket } from "./Socket.js";
1112

1213
export declare namespace V2Client {
@@ -37,10 +38,15 @@ export declare namespace V2Client {
3738
}
3839

3940
export class V2Client {
40-
protected readonly _options: NormalizedClientOptions<V2Client.Options>;
41+
protected readonly _options: NormalizedClientOptionsWithAuth<V2Client.Options>;
42+
protected _audio: AudioClient | undefined;
4143

4244
constructor(options: V2Client.Options = {}) {
43-
this._options = normalizeClientOptions(options);
45+
this._options = normalizeClientOptionsWithAuth(options);
46+
}
47+
48+
public get audio(): AudioClient {
49+
return (this._audio ??= new AudioClient(this._options));
4450
}
4551

4652
public async connect(args: V2Client.ConnectArgs): Promise<V2Socket> {

src/api/resources/speak/resources/v2/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
export { V2Client } from "./client/Client.js";
44
export * from "./client/index.js";
55
export { V2Socket } from "./client/Socket.js";
6+
export * from "./resources/index.js";

0 commit comments

Comments
 (0)