JSPM

  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q72279F
  • License Apache-2.0

JavaScript SDK for Cariva ASR

Package Exports

  • asr-sdk-dev

Readme

Cariva ASR SDK for JavaScript

npmjs

Introduction

The Cariva ASR SDK for JavaScript enables fast and easy integration with Cariva's Automatic Speech Recognition (ASR) system. With minimal setup, you can begin using Cariva's ASR AI capabilities to transcribe audio within minutes.

Demo

For a live demonstration and integration guide, visit our playground demo.

Requirements

  • Node.js 18 or higher

Installation

You can install the @cariva/asr-sdk SDK either via npm or directly in the browser using a CDN.

Install via npm

To add the SDK to your project using npm, run:

npm install @cariva/asr-sdk --save

Install via CDN

To include the SDK directly in your HTML file via CDN

<script src="https://cdn.jsdelivr.net/npm/@cariva/asr-sdk/dist/global/0.0.16/index.min.js"></script>

Example Usage

Here's a sample implementation using the Cariva ASR SDK:

const { ASR } = require('@cariva/asr-sdk');

const config = {
  key: 'YOUR_API_KEY',          // Replace with your Cariva API key
  secret: 'YOUR_API_SECRET',     // Replace with your Cariva API secret
  version: 'v1.0',               // Specify the ASR SDK version
  mode: 'order',                 // Set recognition mode: 'order', 'soap', or 'medclerk'
};

const processAudio = async (audio) => {
  const asr = new ASR(config);  // Initialize ASR with provided configuration
  
  try {
    const task = await asr.create();              // Create a new ASR task
    const result = await task.process(audio);     // Process the audio asynchronously
    console.log('ASR Result:', result);           // Log the ASR result
    return result;                               // Return the result for further processing
  } catch (error) {
    console.error("Error processing audio:", error);  // Handle errors gracefully
    return null;  // Return null to indicate failure in processing
  }
};

Sample audio file or Blob data for processing

// Sample audio file or Blob data for processing
const audioFile = new Blob([...]); // Replace with actual audio data

// Call the function to process the audio
const result = await processAudio(audioFile)
console.log('Processing successful:', result);

Function to cancel an ongoing ASR task if needed

const { cancelASRTask } = require('@cariva/asr-sdk');

// Function to cancel an ongoing ASR task if needed
cancelASRTask();  // Cancel the ASR task (if applicable)

Configuration Options

  • key (string): Your Cariva ASR API key.
  • version (string): SDK version, specifying the model version (default: v1.0).
  • mode (string): Recognition mode, can be set to order, soap, or medclerk.

Error Handling

If an error occurs during processing, it will be logged to the console, and the ASR task will be canceled to free up resources.

License

  • This SDK is available under the terms of the LICENSE.