npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

partai-tts

v1.0.8

Published

PartAI Text-to-Speech (TTS) Node.js & TypeScript Package

Downloads

413

Readme

PartAI Text-to-Speech (TTS) Node.js & TypeScript API

This package provides a simple interface for interacting with the PartAI Text-to-Speech API. It allows you to convert short and long text to speech using various settings and provides functions to track and retrieve the audio files generated from the API.

Installation

npm install partai-tts

Prerequisites

To use this package, you'll need an API key. You can obtain it from the PartAI publisher dashboard.

Documentation

For detailed documentation on the API, please refer to the official service documentation.

Note: This package is not officially maintained by PartAI.

Usage

Here’s how to use the partai-tts package in your code:

Import and Initialize the Client

import PartaiTTS from 'partai-tts';

const gatewayToken = 'YOUR_API_KEY';
const ttsClient = new PartaiTTS(gatewayToken);

Convert Short Text to Speech

async function shortTextExample() {
    try {
        const response = await ttsClient.shortTextToSpeech("Hello, world!", 1, 1, true, false, true);
        console.log("Short Text Response:", response);
    } catch (error) {
        console.error("Error converting short text to speech:", error);
    }
}

shortTextExample();

Convert Long Text to Speech

async function longTextExample() {
    try {
        const response = await ttsClient.longTextToSpeech("This is a longer text to convert.", 1, 1);
        console.log("Long Text Response:", response);

        // Track the status of the conversion process
        const status = await ttsClient.checkLongTextStatus(response.token);
        console.log("File Status:", status);

        // Once complete, retrieve the file link
        if (status.status === 'complete') {
            const fileLink = await ttsClient.getProcessedLongTextFile(status.endpoint);
            console.log("File Link:", fileLink);
        }
    } catch (error) {
        console.error("Error converting long text to speech:", error);
    }
}

longTextExample();

API Reference

constructor(gatewayToken: string, baseUrl: string)

  • gatewayToken: Your API gateway token.
  • baseUrl: The base URL for the API. Defaults to https://partai.gw.isahab.ir/TextToSpeech/v1.

shortTextToSpeech(data: string, speaker?: number, speed?: number, filePath?: boolean, base64?: boolean, checksum?: boolean): Promise<SpeechResponse>

Converts short text to speech.

  • data: The text to convert to speech.
  • speaker: Speaker ID (default is 1).
  • speed: Speech speed (default is 1).
  • filePath: Whether to return the file path (default is true).
  • base64: Whether to return audio as base64 (default is false).
  • checksum: Whether to include a checksum (default is true).

longTextToSpeech(data: string, speaker?: number, speed?: number): Promise<LongTextToSpeechResponse>

Converts long text to speech. Requires tracking status for completion.

checkLongTextStatus(token: string): Promise<FileStatusResponse>

Checks the status of a long text-to-speech conversion.

  • token: Token for the conversion job.

getProcessedLongTextFile(endpoint: string): Promise<FileLinkResponse>

Retrieves the download link for a completed long text-to-speech file.

  • endpoint: The endpoint or token for the processed file.

License

MIT License