Skip to content

Commit cd4306b

Browse files
tomc98davidzhao
andauthored
feat(openai): add new TTS model and voices, include optional instruct… (#351)
Co-authored-by: David Zhao <dz@livekit.io>
1 parent 3cf9fe9 commit cd4306b

File tree

5 files changed

+46
-22
lines changed

5 files changed

+46
-22
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/agents-plugin-openai": patch
3+
---
4+
5+
feat(openai): add new TTS model and voices, include optional instruct…

plugins/openai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"typescript": "^5.0.0"
4141
},
4242
"dependencies": {
43-
"openai": "^4.70.2",
43+
"openai": "^4.91.1",
4444
"sharp": "^0.33.5",
4545
"ws": "^8.16.0"
4646
},

plugins/openai/src/models.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@ export type ChatModels =
2929

3030
export type WhisperModels = 'whisper-1';
3131

32-
export type TTSModels = 'tts-1' | 'tts-1-hd';
32+
export type TTSModels = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts';
3333

34-
export type TTSVoices = 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
34+
export type TTSVoices =
35+
| 'alloy'
36+
| 'ash'
37+
| 'ballad'
38+
| 'coral'
39+
| 'echo'
40+
| 'fable'
41+
| 'nova'
42+
| 'onyx'
43+
| 'sage'
44+
| 'shimmer'
45+
| 'verse';
3546

3647
// adapters for OpenAI-compatible LLMs, TTSs, STTs
3748

plugins/openai/src/tts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface TTSOptions {
1414
model: TTSModels | string;
1515
voice: TTSVoices;
1616
speed: number;
17+
instructions?: string;
1718
baseURL?: string;
1819
client?: OpenAI;
1920
apiKey?: string;
@@ -66,6 +67,7 @@ export class TTS extends tts.TTS {
6667
input: text,
6768
model: this.#opts.model,
6869
voice: this.#opts.voice,
70+
instructions: this.#opts.instructions,
6971
response_format: 'pcm',
7072
speed: this.#opts.speed,
7173
}),

pnpm-lock.yaml

Lines changed: 25 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)