forked from openai/openai-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speech.ts
55 lines (46 loc) · 1.7 KB
/
speech.ts
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as SpeechAPI from './speech';
import { type Response } from '../../_shims/index';
export class Speech extends APIResource {
/**
* Generates audio from the input text.
*/
create(body: SpeechCreateParams, options?: Core.RequestOptions): Core.APIPromise<Response> {
return this._client.post('/audio/speech', { body, ...options, __binaryResponse: true });
}
}
export type SpeechModel = 'tts-1' | 'tts-1-hd';
export interface SpeechCreateParams {
/**
* The text to generate audio for. The maximum length is 4096 characters.
*/
input: string;
/**
* One of the available [TTS models](https://platform.openai.com/docs/models/tts):
* `tts-1` or `tts-1-hd`
*/
model: (string & {}) | SpeechModel;
/**
* The voice to use when generating the audio. Supported voices are `alloy`,
* `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
* available in the
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
*/
voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
/**
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
* `wav`, and `pcm`.
*/
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
/**
* The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
* the default.
*/
speed?: number;
}
export namespace Speech {
export import SpeechModel = SpeechAPI.SpeechModel;
export import SpeechCreateParams = SpeechAPI.SpeechCreateParams;
}