Text to Voice API - Calling different languages

Hello!

Does anyone know how to invoke a different language for text to voice?

My current call for reference:

response = await async_openai_client.audio.speech.create(
model=“tts-1-hd-1106”,
voice=“nova”,
input=text,
response_format=‘opus’
)

Thank you!

1 Like

I found my answer, “You can generate spoken audio in these languages by providing the input text in the language of your choice.”

That’s easy :slight_smile:

there is no language parameter

import { APIResource } from ‘…/…/resource’;
import * as Core from ‘…/…/core’;
import { type Response } from ‘…/…/_shims/index’;

export class Speech extends APIResource {
/**

  • Generates audio from the input text.
    */
    create(body: SpeechCreateParams, options?: Core.RequestOptions): Core.APIPromise {
    return this._client.post(‘/audio/speech’, { body, …options, __binaryResponse: true });
    }
    }

export type SpeechModel = ‘tts-1’ | ‘tts-1-hd’;

export interface SpeechCreateParams {
/**

  • The text to generate audio for. The maximum length is 4096 characters.
    */
    input: string;

/**

  • One of the available TTS models:
  • tts-1 or tts-1-hd
    */
    model: (string & {}) | SpeechModel;

/**

  • The voice to use when generating the audio. Supported voices are alloy,
  • echo, fable, onyx, nova, and shimmer. Previews of the voices are
  • available in the
  • Text to speech guide.
    */
    voice: ‘alloy’ | ‘echo’ | ‘fable’ | ‘onyx’ | ‘nova’ | ‘shimmer’;

/**

  • The format to audio in. Supported formats are mp3, opus, aac, flac,
  • wav, and pcm.
    */
    response_format?: ‘mp3’ | ‘opus’ | ‘aac’ | ‘flac’ | ‘wav’ | ‘pcm’;

/**

  • The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is
  • the default.
    */
    speed?: number;
    }

export declare namespace Speech {
export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
}

but problem starts when you want to tell 23 without any further context