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

node-openjtalk

v1.1.1

Published

Japanese text-to-speech engine binding for NodeJS

Downloads

4

Readme

node-openjtalk

OpenJTalk, Japanese text-to-speech engine binding for NodeJS.

Requirements

MacOSX users do not need to install libiconv because OSX already includes it.

Installation

$ npm install node-openjtalk

Usage

var fs = require('fs');
var Speaker = require('speaker');
var OpenJTalk = require('node-openjtalk').OpenJTalk;

// pre-included HTS voice file
var fn_voice = OpenJTalk.voices.mei_normal;
// instantiate OpenJTalk with an HTS voice
var open_jtalk = new OpenJTalk({voice: fn_voice});

// synthesize a voice buffer from a text
open_jtalk.synthesize("すもももももももものうち", function(error, buffer) {
  if (!error) {
    // save as audio file
    var fd = fs.openSync(__dirname + '/test.wav', 'w');
    fs.write(fd, buffer, 0, buffer.length, null, function(err, written, buffer) {
      fs.closeSync(fd);
    });
  }
});

// synthesize a voice synchronously
var buffer = open_jtalk.synthesizeSync("すもももももももものうち");

// flush to node-speaker
var speaker = new Speaker({
  channels: 1,
  bitDepth: 16,
  sampleRate: 48000
});
speaker.end(buffer);

API

new OpenJTalk(option)

Instantiates OpenJTalk object.

You must specify HTS voice file path with an option argument.

var OpenJTalk = require('node-openjtalk').OpenJTalk;
var open_jtalk = new OpenJTalk({voice: "/path/to/HTS voice file"});

You can use pre-included voice files.

var OpenJTalk = require('node-openjtalk').OpenJTalk;
var open_jtalk = new OpenJTalk({voice: OpenJTalk.voices.m001});

The pre-included voice files are:

  • m001
  • mei_angry
  • mei_bashful
  • mei_happy
  • mei_normal
  • mei_sad

OpenJTalk#synthesize(text, [optionHook], callback)

Synthesizes voice audio asynchronously from a text. The callback takes two arguments, error and buffer object.

open_jtalk.synthesize("音声合成するテキスト", function(error, buffer) {
  if (!error) {
    // do something with buffer
  }
});

The "optionHook" function lets you modify synthesis parameters. For example, following code makes speech speed double.

open_jtalk.synthesize(text, function(option) {
  return {
    speed: option.speed * 2
  };
}, function(error, buffer) {

});

The available parameters are:

  • samplingFrequency
  • fPeriod
  • alpha
  • beta
  • speed
  • addHalfTone
  • msdThreshold
  • gvWeightForSpectrum
  • gvWeightForLogF0
  • volume
  • audioBuffSize

OpenJTalk#synthesizeSync(text, [optionHook])

Synthesizes voice audio synchronously from a text. This function returns buffer object.

Supported platforms

node-openjtalk currently supports following platforms.

  • MacOSX/x64
  • linux/ia32
  • linux/x64

License

node-openjtalk is licensed under the MIT license. See LICENSE for more details.

node-openjtalk builds on OpenJTalk and hts_engine API, and is shiped with HTS Voice "NIT ATR503 M001" and "Mei". Thanks for their works.

Both OpenJTalk and hts_engine API are issued under the Modified BSD license.

HTS Voice "NIT ATR503 M001" and "Mei" are both issued under the Creative Commons Attribution 3.0 license.