Skip to main content

Class: OpenAISpeechModel

Synthesize speech using the OpenAI API.

See

https://platform.openai.com/docs/api-reference/audio/createSpeech

Hierarchy

Implements

Accessors

modelInformation

get modelInformation(): ModelInformation

Returns

ModelInformation

Implementation of

SpeechGenerationModel.modelInformation

Inherited from

AbstractModel.modelInformation

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:17


modelName

get modelName(): OpenAISpeechModelType

Returns

OpenAISpeechModelType

Overrides

AbstractModel.modelName

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:64


settingsForEvent

get settingsForEvent(): Partial<OpenAISpeechModelSettings>

Returns settings that should be recorded in observability events. Security-related settings (e.g. API keys) should not be included here.

Returns

Partial<OpenAISpeechModelSettings>

Implementation of

SpeechGenerationModel.settingsForEvent

Overrides

AbstractModel.settingsForEvent

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:101


voice

get voice(): OpenAISpeechVoice

Returns

OpenAISpeechVoice

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:60

Constructors

constructor

new OpenAISpeechModel(settings): OpenAISpeechModel

Parameters

NameType
settingsOpenAISpeechModelSettings

Returns

OpenAISpeechModel

Overrides

AbstractModel&lt;OpenAISpeechModelSettings&gt;.constructor

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:54

Methods

doGenerateSpeechStandard

doGenerateSpeechStandard(text, options): Promise<Uint8Array>

Generates an mp3 audio Uint8Array that contains the speech for the given text.

Parameters

NameType
textstring
optionsFunctionCallOptions

Returns

Promise<Uint8Array>

Implementation of

SpeechGenerationModel.doGenerateSpeechStandard

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:110


withSettings

withSettings(additionalSettings): OpenAISpeechModel

The withSettings method creates a new model with the same configuration as the original model, but with the specified settings changed.

Parameters

NameType
additionalSettingsPartial<OpenAISpeechModelSettings>

Returns

OpenAISpeechModel

Example

const model = new OpenAICompletionModel({
model: "gpt-3.5-turbo-instruct",
maxGenerationTokens: 500,
});

const modelWithMoreTokens = model.withSettings({
maxGenerationTokens: 1000,
});

Implementation of

SpeechGenerationModel.withSettings

Overrides

AbstractModel.withSettings

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:114

Properties

provider

Readonly provider: "openai"

Overrides

AbstractModel.provider

Defined in

packages/modelfusion/src/model-provider/openai/OpenAISpeechModel.ts:58


settings

Readonly settings: OpenAISpeechModelSettings

Implementation of

SpeechGenerationModel.settings

Inherited from

AbstractModel.settings

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:7