0.1.11 • Published 6 months ago

@corti/dictation-web v0.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Corti Dictation SDK

Overview

The Corti Dictation SDK is a web component that enables real-time speech-to-text dictation using Corti's Dictation API. It provides a simple interface for capturing audio, streaming it to the API, and handling transcripts.

Note: OAuth 2.0 authentication is not handled by this SDK. The client must provide an API key or authorization token before using the component.

Installation

Include the SDK in your project by importing the JavaScript module:

npm i @corti/dictation-web

Then import the module like so:

// Import the Corti Dictation SDK
import '@corti/dictation-web';

Alternatively, use a CDN to start quickly (not recommended).

<script
  src="https://cdn.jsdelivr.net/npm/@corti/dictation-web/dist/bundle.min.js"
  preload
  type="module"
></script>

Usage

Demo

šŸš€ Hosted Demo

Basic Example

<!DOCTYPE html>
<html lang="en">
  <body>
    <corti-dictation></corti-dictation>
    <textarea
      id="transcript"
      placeholder="Transcript will appear here..."
    ></textarea>

    <script>
      import '@corti/dictation-web';
      const dictation = document.getElementById('transcript');
      dictation.setAccessToken('YOUR_AUTH_TOKEN'); // Note: Never hardcode tokens
      // Listen for events
      dictationEl.addEventListener('transcript', e => {
        document.getElementById('transcript').value += e.detail.data.text + ' ';
      });
    </script>
  </body>
</html>

API Reference

Properties

PropertyTypeDescription
devicesArrayList of available recording devices.
selectedDeviceObjectThe selected device used for recording (MediaDeviceInfo).
recordingStateStringCurrent state of recording (stopped, recording, initializing and stopping, ).
dictationConfigObjectConfiguration settings for dictation.
debug_displayAudioBooleanOverrides any device selection and instead uses getDisplayMedia to stream system audio. Should only be used for debugging

Methods

MethodDescription
toggleRecording()Starts or stops recording.
setAccessToken(access_token: string)Set the latest access token. This will return the server config.

Events

EventDescription
readyFired once the component is ready.
recording-state-changedFired when the recording state changes. detail.state contains the new state.
recording-devices-changedFired when the user switches recording devices or the list of recording devices changes. detail.devices contains the full devices list. detail.selectedDevice contains the current selected device.
transcriptFired when a new transcript is received. detail.data.text contains the transcribed text.
commandFired whenever a new command is detected.
audio-level-changedFired when the input audio level changes. detail.audioLevel contains the new level.
errorFired on error. detail contains the full error.

Authentication

This SDK does not handle OAuth 2.0 authentication. The client must provide an API key or access token as a string using setAccessToken.

Usage Examples

Explore practical implementations and usage examples in the Demo Folder. These demos can also be run locally.

Styling

UI Overview

The default UI is designed to be slotted into existing applications seamlessly, however, it also supports custom styling as well as theming. The UI can be fully customized using CSS properties. Refer to our Styling Guide for detailed instructions.

License

This SDK is licensed under MIT.

Support

For issues or questions, contact Corti Support at support@corti.ai.

0.1.11

6 months ago

0.1.10

7 months ago

0.1.9

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago