UNPKG

openai

Version:

The official TypeScript library for the OpenAI API

46 lines • 1.75 kB
// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { buildHeaders } from "../../internal/headers.mjs"; function resolveResourceRequestOptions(options, buildOptions) { return Promise.resolve(options).then(buildOptions); } /** * Turn audio into text or text into audio. */ export class Speech extends APIResource { /** * Generates audio from the input text. * * Returns the audio file content, or a stream of audio events. * * The `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, `gpt-4o-mini-tts-2025-03-20`, and * `gpt-4o-mini-tts-2025-12-15` models are deprecated and scheduled to shut down on * January 6, 2027. These examples use the existing Speech API; for new * integrations, migrate to `gpt-realtime-2.1-mini` through the * [Realtime API](https://developers.openai.com/api/docs/guides/realtime). See the * [deprecation schedule](https://developers.openai.com/api/docs/deprecations) for * migration details. * * @example * ```ts * const speech = await client.audio.speech.create({ * input: 'input', * model: 'tts-1', * voice: 'ash', * }); * * const content = await speech.blob(); * console.log(content); * ``` */ create(body, options) { return this._client.post('/audio/speech', resolveResourceRequestOptions(options, (options) => ({ body, ...options, headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]), __security: { bearerAuth: true }, __binaryResponse: true, }))); } } //# sourceMappingURL=speech.mjs.map