-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudioAdapters.ts
More file actions
82 lines (70 loc) · 1.51 KB
/
audioAdapters.ts
File metadata and controls
82 lines (70 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
export type SpeechToTextInput = {
buffer: Buffer;
filename: string;
mimeType: string;
language?: string;
prompt?: string;
abortSignal?: AbortSignal;
};
export type SpeechToTextResult = {
text: string;
language?: string;
raw?: unknown;
};
export interface SpeechToTextAdapter {
name: string;
transcribe(input: SpeechToTextInput): Promise<SpeechToTextResult>;
}
export type OpenAITtsVoice =
| "alloy"
| "ash"
| "ballad"
| "coral"
| "echo"
| "fable"
| "onyx"
| "nova"
| "sage"
| "shimmer"
| "verse"
| "marin"
| "cedar";
export type TtsAudioFormat =
| "mp3"
| "opus"
| "aac"
| "flac"
| "wav"
| "pcm";
export type TextToSpeechInput = {
text: string;
voice?: OpenAITtsVoice;
format?: TtsAudioFormat;
speed?: number;
instructions?: string;
abortSignal?: AbortSignal;
stream?: false;
};
export type TextToSpeechResult = {
audio: Buffer;
mimeType: string;
format: TtsAudioFormat;
raw?: unknown;
};
export type TtsStreamFormat = "audio" | "sse";
export type TextToSpeechStreamInput = Omit<TextToSpeechInput, "stream"> & {
stream: true;
streamFormat?: TtsStreamFormat;
};
export type TextToSpeechStreamResult = {
audioStream: ReadableStream<Uint8Array>;
mimeType: string;
format: TtsAudioFormat;
streamFormat: TtsStreamFormat;
raw?: unknown;
};
export interface TextToSpeechAdapter {
name: string;
synthesize(input: TextToSpeechStreamInput): Promise<TextToSpeechStreamResult>;
synthesize(input: TextToSpeechInput): Promise<TextToSpeechResult>;
}