speech.d.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { APIResource } from "../../core/resource.js";
  2. import { APIPromise } from "../../core/api-promise.js";
  3. import { RequestOptions } from "../../internal/request-options.js";
  4. export declare class Speech extends APIResource {
  5. /**
  6. * Generates audio from the input text.
  7. *
  8. * @example
  9. * ```ts
  10. * const speech = await client.audio.speech.create({
  11. * input: 'input',
  12. * model: 'string',
  13. * voice: 'ash',
  14. * });
  15. *
  16. * const content = await speech.blob();
  17. * console.log(content);
  18. * ```
  19. */
  20. create(body: SpeechCreateParams, options?: RequestOptions): APIPromise<Response>;
  21. }
  22. export type SpeechModel = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | 'gpt-4o-mini-tts-2025-12-15';
  23. export interface SpeechCreateParams {
  24. /**
  25. * The text to generate audio for. The maximum length is 4096 characters.
  26. */
  27. input: string;
  28. /**
  29. * One of the available [TTS models](https://platform.openai.com/docs/models#tts):
  30. * `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
  31. */
  32. model: (string & {}) | SpeechModel;
  33. /**
  34. * The voice to use when generating the audio. Supported built-in voices are
  35. * `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`,
  36. * `shimmer`, `verse`, `marin`, and `cedar`. Previews of the voices are available
  37. * in the
  38. * [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
  39. */
  40. voice: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'sage' | 'shimmer' | 'verse' | 'marin' | 'cedar';
  41. /**
  42. * Control the voice of your generated audio with additional instructions. Does not
  43. * work with `tts-1` or `tts-1-hd`.
  44. */
  45. instructions?: string;
  46. /**
  47. * The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
  48. * `wav`, and `pcm`.
  49. */
  50. response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
  51. /**
  52. * The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
  53. * the default.
  54. */
  55. speed?: number;
  56. /**
  57. * The format to stream the audio in. Supported formats are `sse` and `audio`.
  58. * `sse` is not supported for `tts-1` or `tts-1-hd`.
  59. */
  60. stream_format?: 'sse' | 'audio';
  61. }
  62. export declare namespace Speech {
  63. export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
  64. }
  65. //# sourceMappingURL=speech.d.ts.map