Table of Contents

Class SpeechRequest

Namespace
OpenAI.Audio
Assembly
OpenAI-DotNet.dll
public sealed class SpeechRequest
Inheritance
SpeechRequest
Inherited Members

Constructors

SpeechRequest(string, Model, Voice, SpeechResponseFormat, float?)

[Obsolete("use new .ctr overload with instructions parameter")]
public SpeechRequest(string input, Model model, Voice voice, SpeechResponseFormat responseFormat, float? speed = null)

Parameters

input string
model Model
voice Voice
responseFormat SpeechResponseFormat
speed float?

SpeechRequest(string, Model, Voice, string, SpeechResponseFormat, float?)

Constructor.

public SpeechRequest(string input, Model model = null, Voice voice = null, string instructions = null, SpeechResponseFormat responseFormat = SpeechResponseFormat.MP3, float? speed = null)

Parameters

input string

The text to generate audio for. The maximum length is 4096 characters.

model Model

One of the available TTS models. Defaults to tts-1.

voice Voice

The voice to use when generating the audio.

instructions string

Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

responseFormat SpeechResponseFormat

The format to audio in. Supported formats are mp3, opus, aac, flac, wav and pcm.

speed float?

The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.

Properties

Input

The text to generate audio for. The maximum length is 4096 characters.

[JsonPropertyName("input")]
[FunctionProperty("The text to generate audio for. The maximum length is 4096 characters.", true, null, new object[] { })]
public string Input { get; }

Property Value

string

Instructions

Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

[JsonPropertyName("instructions")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[FunctionProperty("Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.", false, null, new object[] { })]
public string Instructions { get; }

Property Value

string

Model

One of the available TTS models. Defaults to tts-1.

[JsonPropertyName("model")]
[FunctionProperty("One of the available TTS models. Defaults to tts-1.", true, "tts-1", new object[] { "tts-1-hd" })]
public string Model { get; }

Property Value

string

ResponseFormat

The format to audio in. Supported formats are mp3, opus, aac, flac, wav and pcm.

[JsonPropertyName("response_format")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter<SpeechResponseFormat>))]
[FunctionProperty("The format to audio in. Supported formats are mp3, opus, aac, flac, wav and pcm.", false, SpeechResponseFormat.MP3, new object[] { })]
public SpeechResponseFormat ResponseFormat { get; }

Property Value

SpeechResponseFormat

Speed

The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.

[JsonPropertyName("speed")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[FunctionProperty("The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.", false, 1, new object[] { })]
public float? Speed { get; }

Property Value

float?

Voice

The voice to use when generating the audio.

[JsonPropertyName("voice")]
[FunctionProperty("The voice to use when generating the audio.", true, "alloy", new object[] { "echo", "fable", "onyx", "nova", "shimmer" })]
public string Voice { get; }

Property Value

string