Skip to main content

Class: OpenAITranscriptionModel

Create a transcription model that calls the OpenAI transcription API.

See

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

Example

const data = await fs.promises.readFile("data/test.mp3");

const transcription = await transcribe(
new OpenAITranscriptionModel({ model: "whisper-1" }),
{
type: "mp3",
data,
}
);

Hierarchy

Implements

Accessors

modelInformation

get modelInformation(): ModelInformation

Returns

ModelInformation

Implementation of

TranscriptionModel.modelInformation

Inherited from

AbstractModel.modelInformation

Defined in

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


modelName

get modelName(): "whisper-1"

Returns

"whisper-1"

Overrides

AbstractModel.modelName

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:81


settingsForEvent

get settingsForEvent(): Partial<OpenAITranscriptionModelSettings>

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

Returns

Partial<OpenAITranscriptionModelSettings>

Implementation of

TranscriptionModel.settingsForEvent

Overrides

AbstractModel.settingsForEvent

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:175

Constructors

constructor

new OpenAITranscriptionModel(settings): OpenAITranscriptionModel

Parameters

NameType
settingsOpenAITranscriptionModelSettings

Returns

OpenAITranscriptionModel

Overrides

AbstractModel&lt;OpenAITranscriptionModelSettings&gt;.constructor

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:76

Methods

callAPI

callAPI<RESULT>(input, callOptions, options): Promise<RESULT>

Type parameters

Name
RESULT

Parameters

NameType
inputObject
input.audioDataUint8Array
input.fileExtensionstring
callOptionsFunctionCallOptions
optionsObject
options.responseFormatOpenAITranscriptionResponseFormatType<RESULT>

Returns

Promise<RESULT>

Defined in

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


doTranscribe

doTranscribe(«destructured», options): Promise<{ rawResponse: { duration: number ; language: string ; segments: { avg_logprob: number ; compression_ratio: number ; end: number ; id: number ; no_speech_prob: number ; seek: number ; start: number ; temperature: number ; text: string ; tokens: number[] ; transient?: boolean }[] ; task: "transcribe" ; text: string } ; transcription: string = rawResponse.text }>

Parameters

NameType
«destructured»Object
› audioDataDataContent
› mimeTypestring
optionsFunctionCallOptions

Returns

Promise<{ rawResponse: { duration: number ; language: string ; segments: { avg_logprob: number ; compression_ratio: number ; end: number ; id: number ; no_speech_prob: number ; seek: number ; start: number ; temperature: number ; text: string ; tokens: number[] ; transient?: boolean }[] ; task: "transcribe" ; text: string } ; transcription: string = rawResponse.text }>

Implementation of

TranscriptionModel.doTranscribe

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:85


withSettings

withSettings(additionalSettings): OpenAITranscriptionModel

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

Parameters

NameType
additionalSettingsOpenAITranscriptionModelSettings

Returns

OpenAITranscriptionModel

Example

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

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

Implementation of

TranscriptionModel.withSettings

Overrides

AbstractModel.withSettings

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:182

Properties

provider

Readonly provider: "openai"

Overrides

AbstractModel.provider

Defined in

packages/modelfusion/src/model-provider/openai/OpenAITranscriptionModel.ts:80


settings

Readonly settings: OpenAITranscriptionModelSettings

Implementation of

TranscriptionModel.settings

Inherited from

AbstractModel.settings

Defined in

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