Creates a transcriber for transcribing an audio stream from a mic.
This basic example demonstrates the use of the transcriber with custom callbacks:
import MicrophoneTranscriber from "@moonshine-ai/moonshine-js";
var transcriber = new MicrophoneTranscriber(
"model/tiny"
{
onPermissionsRequested() {
console.log("Requesting permissions.")
},
onError(error) {
console.log(`Error: ${error}`)
},
onModelLoadStarted() {
console.log("onModelLoadStarted()");
},
onTranscribeStarted() {
console.log("onTranscribeStarted()");
},
onTranscribeStopped() {
console.log("onTranscribeStopped()");
},
onTranscriptionUpdated(text: string) {
console.log(
"onTranscriptionUpdated(" + text + ")"
);
},
onTranscriptionCommitted(text: string) {
console.log(
"onTranscriptionCommitted(" + text + ")"
);
},
},
false // use streaming mode
);
transcriber.start();
Attaches a MediaStream to this Transcriber for transcription. A MediaStream must be attached before starting transcription.
A MediaStream to transcribe
Detaches the MediaStream used for transcription. TODO
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.
An AudioBuffer
Preloads the models and initializes the buffer required for transcription.
Starts transcription. This will request permission to access the user's microphone, if it hasn't already been granted.
Transcription will stop when stop is called.
Stops transcription.
Accesses the user's microphone and transcribes their speech.