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
-
AbstractModel
<OpenAITranscriptionModelSettings
>↳
OpenAITranscriptionModel
Implements
Accessors
modelInformation
• get
modelInformation(): ModelInformation
Returns
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
Name | Type |
---|---|
settings | OpenAITranscriptionModelSettings |
Returns
Overrides
AbstractModel<OpenAITranscriptionModelSettings>.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
Name | Type |
---|---|
input | Object |
input.audioData | Uint8Array |
input.fileExtension | string |
callOptions | FunctionCallOptions |
options | Object |
options.responseFormat | OpenAITranscriptionResponseFormatType <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
Name | Type |
---|---|
«destructured» | Object |
› audioData | DataContent |
› mimeType | string |
options | FunctionCallOptions |
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
Name | Type |
---|---|
additionalSettings | OpenAITranscriptionModelSettings |
Returns
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
Inherited from
AbstractModel.settings