speech.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { APIResource } from "../../resource.js";
  2. import * as Core from "../../core.js";
  3. import { type Response } from "../../_shims/index.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?: Core.RequestOptions): Core.APIPromise<Response>;
  21. }
  22. export type SpeechModel = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts';
  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` or `gpt-4o-mini-tts`.
  31. */
  32. model: (string & {}) | SpeechModel;
  33. /**
  34. * The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
  35. * `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
  36. * `verse`. Previews of the voices are available in the
  37. * [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
  38. */
  39. voice: (string & {}) | 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer' | 'verse';
  40. /**
  41. * Control the voice of your generated audio with additional instructions. Does not
  42. * work with `tts-1` or `tts-1-hd`.
  43. */
  44. instructions?: string;
  45. /**
  46. * The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
  47. * `wav`, and `pcm`.
  48. */
  49. response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
  50. /**
  51. * The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
  52. * the default. Does not work with `gpt-4o-mini-tts`.
  53. */
  54. speed?: number;
  55. }
  56. export declare namespace Speech {
  57. export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
  58. }
  59. //# sourceMappingURL=speech.d.ts.map