UNPKG

openai

Version:

The official TypeScript library for the OpenAI API

50 lines • 1.89 kB
"use strict"; // File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. Object.defineProperty(exports, "__esModule", { value: true }); exports.Speech = void 0; const resource_1 = require("../../core/resource.js"); const headers_1 = require("../../internal/headers.js"); function resolveResourceRequestOptions(options, buildOptions) { return Promise.resolve(options).then(buildOptions); } /** * Turn audio into text or text into audio. */ class Speech extends resource_1.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: (0, headers_1.buildHeaders)([{ Accept: 'application/octet-stream' }, options?.headers]), __security: { bearerAuth: true }, __binaryResponse: true, }))); } } exports.Speech = Speech; //# sourceMappingURL=speech.js.map