JSPM

abenasdk

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q27293F
  • License PROPRIETARY

Enterprise Node.js SDK for Abena AI Services - ASR, TTS, Translation

Package Exports

  • abenasdk
  • abenasdk/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (abenasdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Abena AI Node.js SDK

NPM version License: Proprietary

The official enterprise-grade Node.js SDK for integrating Abena AI's powerful services into your applications. Access high-quality Text-to-Speech (TTS), accurate Automatic Speech Recognition (ASR), and Neural Machine Translation with a simple and intuitive async/await API.

Features

  • High-Quality TTS: Synthesize natural-sounding speech using intuitive voice names.
  • Accurate ASR: Transcribe audio from files, Buffers, or Streams.
  • Neural Translation: Translate text between hundreds of user-friendly language codes.
  • Robust & Secure: Built with production-grade validation and security.
  • Detailed Error Handling: Clear, specific exceptions for easy debugging in your application.
  • TypeScript Support: Fully typed for a modern development experience.

Installation

The package requires Node.js v14 or higher.

npm install @abena-ai-team/abenasdk

Quick Start

const { AbenasClient, FileError } = require('@abena-ai-team/abenasdk');
const fs = require('fs');

// Best practice: store your API key in an environment variable
// export ABENA_API_KEY="sk_your_api_key_here"
const client = new AbenasClient({
    apiKey: process.env.ABENA_API_KEY
});

async function main() {
    try {
        // Text-to-Speech (TTS)
        const audioBuffer = await client.tts.synthesize(
            'Hello from the Abena AI software development kit.',
            'akua'
        );
        fs.writeFileSync('speech_output.wav', audioBuffer);
        console.log("Audio saved to speech_output.wav");

        // Automatic Speech Recognition (ASR)
        const transcription = await client.asr.transcribe('speech_output.wav', 'en');
        console.log(`Transcription: ${transcription.text}`);

        // Translation
        const translation = await client.translator.translate({
            text: 'Hello from Abena AI!',
            source_language: 'en',
            target_language: 'fr'
        });
        console.log(`Translation: ${translation.translation}`);

    } catch (error) {
        console.error(`An error occurred: [${error.name}] ${error.message}`);
        if (error instanceof FileError) {
            console.error("Please ensure the input file exists.");
        }
    }
}

main();

API Reference

Client Initialization

The client can be configured for production or local development environments.

const { AbenasClient } = require('@abena-ai-team/abenasdk');

// For Production (default)
const client = new AbenasClient({ apiKey: 'YOUR_PROD_KEY' });

Text-to-Speech (client.tts)

synthesize(text, voice, outputFile)

Converts text to speech.

  • text (string): The text to synthesize. Max 500 characters.
  • voice (string): The voice name to use (e.g., 'akua', 'abena').
  • outputFile (string, optional): Path to save the .wav file. If omitted, a Buffer is returned.
// Get audio data as a Buffer
const audioBuffer = await client.tts.synthesize('Hello world', 'akua');

// Or save directly to a file
await client.tts.synthesize('Hello world', 'abena', 'output.wav');

Speech Recognition (client.asr)

transcribe(audioSource, language)

Transcribes an audio file to text.

  • audioSource (string | Buffer | Stream): The audio to transcribe. Can be a file path, a Buffer, or a Readable stream.
  • language (string): The language of the audio (e.g., 'en').
// From a file path
const result = await client.asr.transcribe('./audio.wav', 'en');
console.log(result.text);

// From a Buffer
const audioBuffer = fs.readFileSync('./audio.wav');
const resultFromBuffer = await client.asr.transcribe(audioBuffer, 'en');

Translation (client.translator)

translate({ text, source_language, target_language })

Translates text between languages.

  • text (string): The text to translate. Max 1000 characters.
  • source_language (string): The source language code (e.g., 'en').
  • target_language (string): The target language code (e.g., 'fr').
const result = await client.translator.translate({
    text: 'Welcome to the future of AI.',
    source_language: 'en',
    target_language: 'twi'
});
console.log(result.translation);

Error Handling

The SDK throws specific, custom errors to allow for robust error handling.

const { AbenasClient, APIError, ValidationError, FileError } = require('@abena-ai-team/abenasdk');
const client = new AbenasClient({ apiKey: '...' });

try {
    await client.asr.transcribe('non_existent_file.wav');
} catch (error) {
    if (error instanceof FileError) {
        console.error(`File Error: ${error.message}`);
    } else if (error instanceof ValidationError) {
        console.error(`Validation Error: ${error.message}`);
    } else if (error instanceof APIError) {
        console.error(`API Error: [Status ${error.status}] ${error.message}`);
        // The raw server response data is available if needed
        console.error('Server Response:', error.data);
    } else {
        console.error(`An unexpected error occurred: ${error.message}`);
    }
}

Documentation & Support


© 2025 Mobobi LLC. All rights reserved.