API
Media Element Transcriber

undefined

Class: MediaElementTranscriber

Defined in: mediaElementTranscriber.ts:7

Transcribes the output of an <audio> or <video> HTML element.

Extends

Constructors

new MediaElementTranscriber()

new MediaElementTranscriber(
   mediaElement, 
   modelURL, 
   callbacks, 
   useVAD): MediaElementTranscriber

Defined in: mediaElementTranscriber.ts:17

Parameters

Parameter Type Default value Description
mediaElement HTMLMediaElement undefined
modelURL string undefined
callbacks Partial<TranscriberCallbacks> {}
useVAD boolean false

Returns

MediaElementTranscriber

Overrides

StreamTranscriber.constructor

Properties

Property Modifier Type Default value Inherited from Defined in
audioContext protected AudioContext undefined StreamTranscriber.audioContext streamTranscriber.ts:14
callbacks public TranscriberCallbacks undefined StreamTranscriber.callbacks transcriber.ts:81
isActive public boolean false StreamTranscriber.isActive streamTranscriber.ts:18
mediaRecorder protected MediaRecorder undefined StreamTranscriber.mediaRecorder streamTranscriber.ts:13
model static MoonshineModel undefined StreamTranscriber.model transcriber.ts:80

Methods

attachStream()

attachStream(stream): void

Defined in: streamTranscriber.ts:116

Attaches a MediaStream to this StreamTranscriber for transcription. A MediaStream must be attached before starting transcription.

Parameters

Parameter Type Description
stream MediaStream A MediaStream to transcribe

Returns

void

Inherited from

StreamTranscriber.attachStream


detachStream()

detachStream(): void

Defined in: streamTranscriber.ts:129

Detaches the MediaStream used for transcription.

Returns

void

Inherited from

StreamTranscriber.detachStream


getAudioBuffer()

getAudioBuffer(): AudioBuffer

Defined in: streamTranscriber.ts:143

Returns the most recent AudioBuffer that was input to the underlying model for text generation. This is useful in cases where we want to double-check the audio being input to the model while debugging.

Returns

AudioBuffer

An AudioBuffer

Inherited from

StreamTranscriber.getAudioBuffer


loadModel()

loadModel(): Promise<void>

Defined in: transcriber.ts:93

Returns

Promise<void>

Inherited from

StreamTranscriber.loadModel


start()

start(): Promise<void>

Defined in: mediaElementTranscriber.ts:27

Starts transcription.

if useVAD === true: generate an updated transcription at the end of every chunk of detected voice activity. else if useVAD === false: generate an updated transcription every Settings.FRAME_SIZE milliseconds.

Transcription will stop when stop is called, or when Settings.MAX_RECORD_MS is passed (whichever comes first).

Note that the StreamTranscriber must have a MediaStream attached via StreamTranscriber.attachStream before starting transcription.

Returns

Promise<void>

Overrides

StreamTranscriber.start


stop()

stop(): void

Defined in: streamTranscriber.ts:257

Stops transcription.

Returns

void

Inherited from

StreamTranscriber.stop