1.5.0 • Published 10 months ago

@cariva/asr-sdk v1.5.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
10 months ago

Cariva ASR SDK for JavaScript

npm version

Effortlessly integrate Cariva’s Automatic Speech Recognition (ASR) API into your JavaScript applications to transcribe audio with minimal setup.


📋 Table of Contents


✨ Features

  • Minimal Setup: Get up and running in minutes.
  • Flexible Environments: Supports Node.js (v18+) and modern browsers.
  • Promise‑based API: Intuitive task creation and processing.
  • Cancellation Support: Abort long‑running tasks.
  • Customizable: Override language and medical specialty for model tuning.

🎬 Demo

Try a live integration guide and playground demo here.


⚙️ Requirements

  • Node.js v18 or higher (for npm install)
  • Modern browsers (for CDN usage)

🚀 Installation

npm

npm install @cariva/asr-sdk
# or
yarn add @cariva/asr-sdk

CDN

Include via <script> tag:

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

💡 Quick Start

import { ASR, ASRConfigs, cancelASRTask } from '@cariva/asr-sdk';

(async () => {
  const config = new ASRConfigs({
    key: 'YOUR_API_KEY',           // required
    secret: 'YOUR_API_SECRET',     // required
    mode: 'doc-ipd-soap',          // required
    lang: 'en',                    // optional, default: 'en'
    specialty: 'other',            // optional, default: 'other'
    newLineString: '\n',          // optional
  });

  const asr = new ASR(config);

  try {
    const task = await asr.create();

    // Cancel if it takes longer than 5 minutes
    const timeoutId = setTimeout(async () => {
      console.warn('Cancelling ASR task due to timeout');
      await cancelASRTask(task.id);
    }, 300000);

    const audioBlob = /* your File or Blob */;
    const result = await task.process(audioBlob);
    clearTimeout(timeoutId);

    console.log('Transcription:', result);
  } catch (error) {
    console.error('ASR error:', error);
  }
})();

🔧 Configuration

ASRConfigs

OptionTypeRequiredDefaultDescription
keyStringYesYour Cariva ASR API public key
secretStringYesYour Cariva ASR API secret key
modeStringYesRecognition mode: doc-ipd-soap | doc-opd-clinicalrecord | nur-opd-nursenote-start | nur-opd-nursenote-end
langStringNoenTranscription language: en | th (only for SOAP/clinicalrecord modes)
specialtyStringNootherMedical specialty for improved accuracy (SOAP/clinicalrecord modes)
newLineStringStringNo\nReplacement string for newline characters

Process Options

When calling task.process(), you can override configuration per request:

OptionTypeRequiredDefaultDescription
fileFile | BlobYesAudio file or blob to transcribe
langStringNoenOverride transcription language
specialtyStringNootherOverride medical specialty

⚠️ Error Handling

All failures are thrown as JavaScript Error. Wrap your calls in try/catch:

try {
  // ASR logic...
} catch (err) {
  console.error("ASR processing failed:", err);
}

🗂️ Specialty Key Mapping

#LabelKey
1General Practitioner (GP)gen-practitioner
2General Medicinegen-med
3Cardiologymed-cardio
4Pulmonologymed-pulmonary
5Gastroenterology (GI)med-gastro
6Neurologymed-neuro
7Nephrologymed-nephro
8Oncologymed-onco
9Endocrinologymed-endo
10Dermatology (Skin)med-skin
11Allergy and Immunologymed-allergy
12General Surgerysurgery
13Orthopedicorthopedic
14General Pediatricsgen-ped
15Ophthalmology (Eye)ophthalmology
16Otolaryngology (ENT)otolaryngology
17Obstetrics & Gynecology (OB-GYN)ob-gyn
18Emergency (ER)emergency
19Other specialistsother

📜 License

This project is licensed under the Apache License 2.0.

1.5.0

10 months ago

1.4.0

12 months ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.14

1 year ago

1.0.31

1 year ago