import { APIResource } from "../resource.js"; import * as Core from "../core.js"; import { type Response } from "../_shims/index.js"; import { Sessions, SpeechSessionParams } from "./sessions.js"; export declare class Speech extends APIResource { /** * Generates speech from text and streams the audio as binary data chunks in * real-time as they are generated. * * This is the recommended endpoint for most text-to-speech use cases. You can * either stream the chunks for low-latency playback or collect all chunks to get * the complete audio file. * * @example * ```ts * const response = await client.speech.generate({ * text: 'Uhh, did you see the weather in Palo Alto tomorrow? Yeah, can\'t believe it\'s gonna rain, dude. Like what?', * voice: 'leah', * }); * * const content = await response.blob(); * console.log(content); * ``` */ generate(body: SpeechGenerateParams, options?: Core.RequestOptions): Core.APIPromise; /** * Generates speech from text and returns a JSON object that contains a * base64-encoded audio string and optionally word-level timestamps. This endpoint * waits for all speech to be generated before responding, so it is not ideal for * latency-sensitive applications. * * @example * ```ts * const response = await client.speech.generateDetailed({ * text: 'Uhh, did you see the weather in Palo Alto tomorrow? Yeah, can\'t believe it\'s gonna rain, dude. Like what?', * voice: 'leah', * }); * ``` */ generateDetailed(body: SpeechGenerateDetailedParams, options?: Core.RequestOptions): Core.APIPromise; sessions: Sessions; } export interface SpeechGenerateDetailedResponse { /** * The base64-encoded audio file; the format is determined by the `format` * parameter. */ audio: string; /** * An array describing where each generated input element (words and non-words like * spaces, punctuation, etc.) falls in the audio. */ timestamps?: Array; } export declare namespace SpeechGenerateDetailedResponse { interface Timestamp { /** * The spoken duration of the generated input element, in seconds. */ duration: number; /** * The start time of the generated input element, in seconds. */ start: number; /** * The generated input element; beginning and ending with a short silence. */ text: string; } } export interface SpeechGenerateParams { /** * The text to generate speech from; max 5000 characters per request (including * spaces). */ text: string; /** * The voice id of the voice to use; voice ids can be retrieved by calls to * `List voices` or `Voice info`. */ voice: string; /** * When set to true, the generated speech will also be saved to your * [clip library](https://app.lmnt.com/clips) in the LMNT playground. */ debug?: boolean; /** * The desired output format of the audio. If you are using a streaming endpoint, * you'll generate audio faster by selecting a streamable format since chunks are * encoded and returned as they're generated. For non-streamable formats, all * speech will be generated before encoding. * * Streamable formats: * * - `mp3`: 96kbps MP3 audio. * - `ulaw`: 8-bit G711 µ-law audio with a WAV header. * - `webm`: WebM format with Opus audio codec. * - `pcm_s16le`: PCM signed 16-bit little-endian audio. * - `pcm_f32le`: PCM 32-bit floating-point little-endian audio. * * Non-streamable formats: * * - `aac`: AAC audio codec. * - `wav`: 16-bit PCM audio in WAV container. */ format?: 'aac' | 'mp3' | 'ulaw' | 'wav' | 'webm' | 'pcm_s16le' | 'pcm_f32le'; /** * The desired language. Two letter ISO 639-1 code. Defaults to auto language * detection, but specifying the language is recommended for faster generation. */ language?: 'auto' | 'ar' | 'as' | 'bn' | 'cs' | 'da' | 'de' | 'en' | 'es' | 'fi' | 'fr' | 'hi' | 'id' | 'it' | 'ja' | 'ko' | 'ml' | 'mr' | 'nl' | 'pl' | 'pt' | 'ru' | 'sk' | 'sv' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'vi' | 'zh'; /** * The model to use for speech generation. Learn more about models * [here](https://docs.lmnt.com/models/overview). */ model?: 'blizzard'; /** * The desired output sample rate in Hz. Defaults to `24000` for all formats except * `mulaw` which defaults to `8000`. */ sample_rate?: 8000 | 16000 | 24000; /** * Influences how expressive and emotionally varied the speech becomes. Lower * values (like 0.3) create more neutral, consistent speaking styles. Higher values * (like 1.0) allow for more dynamic emotional range and speaking styles. */ temperature?: number; /** * Controls the stability of the generated speech. A lower value (like 0.3) * produces more consistent, reliable speech. A higher value (like 0.9) gives more * flexibility in how words are spoken, but might occasionally produce unusual * intonations or speech patterns. */ top_p?: number; } export interface SpeechGenerateDetailedParams { /** * The text to generate speech from; max 5000 characters per request (including * spaces). */ text: string; /** * The voice id of the voice to use; voice ids can be retrieved by calls to * `List voices` or `Voice info`. */ voice: string; /** * When set to true, the generated speech will also be saved to your * [clip library](https://app.lmnt.com/clips) in the LMNT playground. */ debug?: boolean; /** * The desired output format of the audio. If you are using a streaming endpoint, * you'll generate audio faster by selecting a streamable format since chunks are * encoded and returned as they're generated. For non-streamable formats, all * speech will be generated before encoding. * * Streamable formats: * * - `mp3`: 96kbps MP3 audio. * - `ulaw`: 8-bit G711 µ-law audio with a WAV header. * - `webm`: WebM format with Opus audio codec. * - `pcm_s16le`: PCM signed 16-bit little-endian audio. * - `pcm_f32le`: PCM 32-bit floating-point little-endian audio. * * Non-streamable formats: * * - `aac`: AAC audio codec. * - `wav`: 16-bit PCM audio in WAV container. */ format?: 'aac' | 'mp3' | 'ulaw' | 'wav' | 'webm' | 'pcm_s16le' | 'pcm_f32le'; /** * The desired language. Two letter ISO 639-1 code. Defaults to auto language * detection, but specifying the language is recommended for faster generation. */ language?: 'auto' | 'ar' | 'as' | 'bn' | 'cs' | 'da' | 'de' | 'en' | 'es' | 'fi' | 'fr' | 'hi' | 'id' | 'it' | 'ja' | 'ko' | 'ml' | 'mr' | 'nl' | 'pl' | 'pt' | 'ru' | 'sk' | 'sv' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'vi' | 'zh'; /** * The model to use for speech generation. Learn more about models * [here](https://docs.lmnt.com/models/overview). */ model?: 'blizzard'; /** * If set as `true`, the response will contain a `timestamps` array describing * where each input element falls in the generated audio. */ return_timestamps?: boolean; /** * The desired output sample rate in Hz. Defaults to `24000` for all formats except * `mulaw` which defaults to `8000`. */ sample_rate?: 8000 | 16000 | 24000; /** * Influences how expressive and emotionally varied the speech becomes. Lower * values (like 0.3) create more neutral, consistent speaking styles. Higher values * (like 1.0) allow for more dynamic emotional range and speaking styles. */ temperature?: number; /** * Controls the stability of the generated speech. A lower value (like 0.3) * produces more consistent, reliable speech. A higher value (like 0.9) gives more * flexibility in how words are spoken, but might occasionally produce unusual * intonations or speech patterns. */ top_p?: number; } export declare namespace Speech { export { type SpeechGenerateDetailedResponse as SpeechGenerateDetailedResponse, type SpeechGenerateParams as SpeechGenerateParams, type SpeechGenerateDetailedParams as SpeechGenerateDetailedParams, }; export { Sessions as Sessions, type SpeechSessionParams as SpeechSessionParams }; } //# sourceMappingURL=speech.d.ts.map