Skip to main content

API

The Sofya Transcription SDK provides a comprehensive API for real-time audio transcription. This section provides an overview of the API components. For detailed information, please refer to the following sections:

Main Components

Quick Reference

Basic Usage

import { SofyaTranscriber } from 'sofya.transcription'

// Create transcriber
const transcriber = new SofyaTranscriber({
apiKey: 'YOUR_API_KEY',
config: {
language: 'en-US'
}
})

// Start transcription
transcriber.on('ready', () => {
navigator.mediaDevices.getUserMedia({ audio: true })
.then(mediaStream => {
transcriber.startTranscription(mediaStream)
})
})

For more detailed information and examples, please refer to the specific sections linked above.

TranscriptionService

Constructor

Creates a new instance of the transcription service with a given API KEY and an config object.

let config = {language: 'en-US'}
constructor('YOUR_API_KEY', config)

.startTranscription(mediaStream)

Starts the transcription process with a given MediaStream.

startTranscription(mediaStream): void

.stopTranscription()

Stops the transcription process.

stopTranscription(): void

.on()

Registers an event handler for transcription events.

 on(event: string, callback: Function): void

Possible events include:

  • recognizing: Fired when transcription is in progress.
  • recognized: Fired when transcription is complete.
  • nomatch: Fired when no speech is recognized.

MediaElementAudioCapture

Constructor

Creates a new instance of the media element audio capture.

constructor()

.captureAudio()

Captures the audio stream from a given media element and returns a MediaStream.

captureAudio(mediaElement: HTMLMediaElement): MediaStream