Skip to content

OpenAISpeechModel

Namespace: Vercel.AI.OpenAI

public sealed class OpenAISpeechModel : ISpeechModel

OpenAI speech model.

Inheritance: object

Implements: ISpeechModel

View source

OpenAISpeechModel(OpenAIProvider, string, Func<DateTimeOffset>?)

Section titled “OpenAISpeechModel(OpenAIProvider, string, Func<DateTimeOffset>?)”
public OpenAISpeechModel(OpenAIProvider provider, string modelId, Func<DateTimeOffset>? clock = null)

Creates a speech model.

Parameters

Name Type Description
provider OpenAIProvider
modelId string
clock Func<DateTimeOffset>

View source

public string ModelId { get; }

Model id.

Value: string

View source

public string Provider { get; }

Provider id.

Value: string

View source

DoGenerateAsync(SpeechCallOptions, CancellationToken)

Section titled “DoGenerateAsync(SpeechCallOptions, CancellationToken)”
public Task<SpeechResult> DoGenerateAsync(SpeechCallOptions options, CancellationToken cancellationToken)

Synthesizes speech.

Parameters

Name Type Description
options SpeechCallOptions
cancellationToken CancellationToken

Returns: Task<SpeechResult>

View source

GenerateAsync(OpenAISpeechCall, CancellationToken)

Section titled “GenerateAsync(OpenAISpeechCall, CancellationToken)”
public Task<OpenAISpeechResult> GenerateAsync(OpenAISpeechCall call, CancellationToken cancellationToken)

Synthesizes speech and returns the audio bytes, warnings, and response headers.

Parameters

Name Type Description
call OpenAISpeechCall
cancellationToken CancellationToken

Returns: Task<OpenAISpeechResult>

View source

public DateTimeOffset Now()

Clock used when a caller records a response timestamp.

Returns: DateTimeOffset

View source

public static OpenAISpeechPreparation Prepare(string modelId, OpenAISpeechCall call)

Builds the speech request body.

Parameters

Name Type Description
modelId string
call OpenAISpeechCall

Returns: OpenAISpeechPreparation

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product