0.4.0 • Published 7 months ago

@reverieit/reverie-client v0.4.0

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

Reverie Client

Reverie Client is an SDK for interacting with Reverie Language Technologies' APIs for speech-to-text, text translation, language identification, and more.

Check out the sample integrations in Github Repo. Go to github.com/reverieinc/javascript-sdk

Installation

Install the package via npm:

npm i @reverieit/reverie-client

Getting Started

Step 1: Obtain API Key

Go to revup.reverieinc.com and create your first API key.

Step 2: Initialize Reverie Client

Import and initialize ReverieClient with your API key and app ID:

const ReverieClient = require("reverie-client");

const reverieClient = new ReverieClient({
  apiKey: "YOUR-API-KEY",
  appId: "YOUR-APP-ID",
});

Step 3: Include STT SDK (If Using Speech-to-Text Streaming)

If you are using STT stream, add the following script to the head section of your index.html:

<script src="https://cdn.jsdelivr.net/npm/reverie-stt-sdk/dist/bundle.js"></script>

Features

1. Transliterate Text

const result = await reverieClient.transliterate({
  text: "Namaste",
  src_lang: "en",
  tgt_lang: "ta",
});

Parameters:

  • text (string, required): The text to be transliterated.
  • src_lang (string, required): The source language code (e.g., "hi").
  • tgt_lang (string, required): The target language code (e.g., "ta").

2. Analyze Text

const analysis = await reverieClient.analyze_text({
  text: "Aap kaise hain?",
  src_lang: "hi",
});

Parameters:

  • text (string, required): The text to analyze.
  • src_lang (string, required): The source language code.
  • tgt_lang (string, optional): The target language code for translation.
  • translation_domain (string, optional): The domain of translation (e.g., "generic").
  • moderation_types (array, optional): Types of content moderation to apply (e.g., ["hate_speech", "profanity"]).

3. Language Identification (Text)

const language = await reverieClient.identify_language_by_text({
  text: "Vanakkam",
});

Parameters:

  • text (string, required): The text whose language needs to be identified.

4. Translate Text

const translation = await reverieClient.translate({
  text: "Namaste",
  src_lang: "hi",
  tgt_lang: "ta",
});

Parameters:

  • text (string, required): The text to translate.
  • src_lang (string, required): The source language code.
  • tgt_lang (string, required): The target language code.
  • domain (string, optional): The translation domain (default is "generic").

5. Speech-to-Text (Batch Processing)

const sttResult = await reverieClient.transcribeAudio({
  audioFile: myAudioFile,
  language: "hi",
  subtitles: "true",
});

Parameters:

  • audioFile (File, required): The audio file to be transcribed.
  • src_lang (string, required): The language code of the speech.
  • domain (string, optional): The domain of speech recognition (default is "generic").

6. Text-to-Speech

const audioBlob = await reverieClient.text_to_speech({
  text: "Namaste Duniya!",
  speaker: "default",
  speed: 1.0,
  pitch: 1.0,
});

Parameters:

  • text (string, required): The text to convert into speech.
  • speaker (string, required): The speaker voice to use.
  • speed (number, optional): The speech speed (default is 1.0).
  • pitch (number, optional): The pitch of the speech (default is 1.0).
  • format (string, optional): The output format (default is "WAV").

7. Initialize Speech-to-Text Streaming

await reverieClient.init_stt({
  src_lang: "hi",
  callback: (event) => {
    // Handle STT event
  },
});

Parameters:

  • src_lang (string, required): The language code for speech recognition.
  • callback (function, required): The function to handle STT events.
  • element (DOM element, optional): The element to insert transcribed text.
  • domain (string, optional): The domain of speech recognition.
  • silence (number, optional): The silence detection threshold.
  • continuous (boolean, optional): Whether the STT should continue after detecting silence.
  • logging (boolean, optional): Whether to enable logging.
  • timeout (number, optional): Timeout duration in seconds.

8. Start/Stop STT Streaming

await reverieClient.start_stt();
await reverieClient.stop_stt();

No parameters required.

9. Document Translation

const translationResult = await reverieClient.translateDocument({
  sourceLanguage: "english",
  targetLanguage: "hindi",
  uploadedFile: myDocumentFile,
});

Parameters:

  • sourceLanguage (string, required): The language code of the source document.
  • targetLanguage (string, required): The language code for the translated document.
  • uploadedFile (File, required): The document file to be translated.

10. Optical Character Recognition

const ocrResult = await reverieClient.uploadDocument({
  file: myDocumentFile,
  file_type: "img",
  selectedLanguages: "en",
  ocrType: "only_ocr",
});

Parameters:

  • file (File, required): The PDF or image file to process
  • file_type (string, required): Type of file ( pdf or img )
  • targetLanguage (string, required): The language code of the document.
  • ocrType (File, required): Type of OCR processing (layout_ocr or only_ocr )

10. Language Identification (Voice)

const language = await reverieClient.uploadAudio({
  file: myAudioFile,
});

Parameters:

  • file (File, required): Local audio file’s path to obtain the transcript.

    Note - file length should be equal to or less than 120 seconds (2 minutes).

License

MIT License

Copyright (c) 2025 Reverie Language Technologies

0.4.0

7 months ago

0.3.1-rc.1

7 months ago

0.3.1-rc.0

7 months ago

0.3.0

7 months ago

0.2.1-rc.1

7 months ago

0.2.1-rc.0

8 months ago

0.2.0

8 months ago

0.1.6-rc.4

8 months ago

0.1.6-rc.3

8 months ago

0.1.6-rc.2

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago