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

talkify-tts-api

v1.1.0

Published

Library to generate TTS directly from Talkify.net APIs

Downloads

12

Readme

Talkify TTS API

npm Types jsDocs.io License

Library to generate text-to-speech audio through Talkify.net APIs.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

npm i talkify-tts-api --save

Features

  • Low-effort text-to-speech generation using Talkify service
  • Synthetized response as a readable stream for data manipulation or saving into a file
  • Support for Speech Synthesis Markup Language (SSML) by default
  • Fetch current available voices list from Talkify and their enabled features

API

This module exports a contructor function which takes an options object.

Talkify(options)

Creates a new Talkify instance

Arguments

  • options (Required) - A plain JavaScript object that contains the configuration options.

Options

  • key (Required): A string that contains the API Key from Talkify, which can be created at https://manage.talkify.net.
  • format: This will determine the output format generated by the Talkify service. Acceptable values: mp3 and wav. Default: mp3.
  • fallbackLanguage: The default language to fallback to Talkify when the service is unable to detect the language automatically. It accepts a string with the language name or a Language object. Default: undefined.
  • voice: The default voice to be used when synthetizing text. It accepts a string with the voice name, or a Voice object. Omit for automatic language detection. Default: undefined.
  • rate: The rate of speech as an signed integer. Accepted range: -5 to 5. Default: 0.
  • ssml: Defines if the text should be parsed as SSML (true) or plain text (false). Default: true.
  • whisper: Use the whispering effect. Only applicable to selected voices. Default: false.
  • soft: Use the softer speech effect. Only applicable to selected voices. Default: false.
  • volume: Adjusts the base volume. Only applicable to selected voices. Accepted range: -10 to 10. Default: 0.
  • wordBreak: Adds a break in milliseconds between words. Only applicable to selected voices. Accepted range: 0 to 1000. Default: 0.
  • pitch: Controls the pitch of the spoken text. Accepted range: -10 to 10. Default: 0.

Return value

A Talkify instance.

Exceptions

Throws a TalkifyError exception if the required options are missing or if any of the other options has any invalid value or range.

Example

In TypeScript:

import Talkify from 'talkify-tts-api'

const talkify = new Talkify({
  key: 'YOUR_TALKIFY_API_KEY'
})

Or in CommonJS:

const { Talkify } = require('talkify-tts-api')

const talkify = new Talkify({
  key: 'YOUR_TALKIFY_API_KEY'
})

Available methods

talkify.speech(text[, options])

This method will synthetize a text-to-speech audio with the given text string or SSML XML content.

Important: When using SSML, the text input must be correct. All XML characters that are not part of the SSML syntax must be escaped or a Bad Request will be thrown.

Parameters

  • text (Required): The text to be used for generating the TTS audio.
  • options: An optional SpeechOptions object that will override the default options from the Talkify instance.

Return Value

A SpeechStream object will be returned, which is a Readable stream that can be used for piping into processing or writing into a file.

Exceptions

Throws a TalkifyError exception if any of the other options has any invalid value or range, or if the API request failed.

The SpeechOptions Object

  • format: This will determine the output format generated by the Talkify service. Acceptable values: mp3 and wav.
  • fallbackLanguage: The default language to fallback to Talkify when the service is unable to detect the language automatically. It accepts a string with the language name or a Language object.
  • voice: The default voice to be used when synthetizing text. Omit for automatic language detection.
  • rate: The rate of speech as an signed integer. Accepted range: -5 to 5.
  • ssml: Defines if the text should be parsed as SSML (true) or plain text (false).
  • whisper: Use the whispering effect. Only applicable to selected voices.
  • soft: Use the softer speech effect. Only applicable to selected voices.
  • volume: Adjusts the base volume. Only applicable to selected voices. Accepted range: -10 to 10.
  • wordBreak: Adds a break in milliseconds between words. Only applicable to selected voices. Accepted range: 0 to 1000.
  • pitch: Controls the pitch of the spoken text. Accepted range: -10 to 10.

talkify.availableVoices([language])

This method will fetch a list of the voices available at Talkify, with their own features. Optionally, it can filter voices by language.

Parameters

  • language: The language to filter the voices from the list. It accepts a string with the language name or a Language object. Omit for showing all voices for all languages. Example: english. Default: null.

Return Value

An array of Voice objects will be returned.

Exceptions

Throws a TalkifyError exception if the API request failed.

The Voice Object

  • culture: The culture. Example: en-US.
  • name: Name of the voice, this is used for the voice parameter when calling the talkify.speech() method. Example: Zira.
  • gender: The gender of the voice. Example: Female.
  • language: The language of this voice. Example: English
  • supportedFormats: A list of the supported formats that this voice can generate audio. Example: ['mp3', 'wav'].
  • description: The voice description. Example: Zira (English - en-US).
  • isStandard: If this voice belongs to the standard tier. Example: true.
  • isPremium: If this voice belongs to the premium tier. Example: true.
  • isExclusive: If this voice belongs to the exclusive tier. Example: true.
  • isNeural: If this voice belongs to the neural voices tier. Example: true.
  • canUseSpeechMarks: If this voice can use the speech marks feature. Example: true.
  • canWhisper: If this voice can use the speech marks feature. Example: true.
  • canUseWordBreak: If this voice can use the word break pause feature. Example: true.
  • canSpeakSoftly: If this voice can use the softer speech feature. Example: true.
  • canUseVolume: If this voice can use the volume setting. Example: true.
  • canUsePitch: If this voice can use the pitch setting. Example: true.

talkify.detectLanguage(text)

This method will use the Talkify API to detect the language for the given text string.

Parameters

  • text (Required): The string that will be used to detect the language. Example: May the Force be with you.

Return Value

A Language object will be returned. If a language can't be detected, undefined will be returned instead.

Exceptions

Throws a TalkifyError exception if the API request failed.

The Language Object

  • name: Name of the language, this is used for the language parameter when calling the class methods. Example: English.
  • cultures: An array with the cultures. Example: ['en-US', 'en-GB'].

Usage Examples

Examples can be found at the examples folder of this repository, it contains both TypeScript and CommonJS files for feature demonstration.

The API key can be placed inside a .env file, so it can be used within the examples. (Please refer to the examples/.env.example file)