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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@piper-plus/g2p

v0.2.0

Published

Multilingual G2P (Grapheme-to-Phoneme) for TTS — eSpeak-ng free, MIT licensed

Readme

@piper-plus/g2p

Multilingual G2P (Grapheme-to-Phoneme) for TTS. Converts text to IPA phoneme sequences without eSpeak-ng. Runs in the browser via WebAssembly.

Install

npm install @piper-plus/g2p

Quick Start

import { G2P } from '@piper-plus/g2p';

// Initialize with desired languages
const g2p = await G2P.create({ languages: ['ja', 'en'] });

// Convert text to IPA tokens
const tokens = g2p.phonemize('Hello, world!');
// => ["h", "ʌ", "l", "oʊ", ",", " ", "w", "ɜː", "l", "d", "!"]

const jaTokens = g2p.phonemize('こんにちは');
// => ["k", "o", "N_n", "n", "i", "ch", "i", "h", "a"]

// Encode for Piper TTS inference
import { Encoder } from '@piper-plus/g2p/encode';
const encoder = new Encoder(config);
const ids = encoder.encode(tokens);

Per-Language Imports

Each language can be imported independently to minimize bundle size:

import { JapaneseG2P } from '@piper-plus/g2p/ja';
import { EnglishG2P } from '@piper-plus/g2p/en';
import { KoreanG2P } from '@piper-plus/g2p/ko';
import { SwedishG2P } from '@piper-plus/g2p/sv';

Supported Languages

| Language | Code | Method | External Dependencies | |------------|------|---------------------|-----------------------| | Japanese | ja | OpenJTalk WASM | NAIST-jdic (auto-download) | | English | en | Rule-based | None | | Chinese | zh | Pinyin-based | None | | Spanish | es | Rule-based | None | | French | fr | Rule-based | None | | Portuguese | pt | Rule-based | None | | Korean | ko | Hangul decomposition | None | | Swedish | sv | Rule-based | None |

Features

  • IPA-first -- phonemize() returns IPA token arrays; no PUA encoding by default
  • Prosody info -- Japanese G2P provides A1/A2/A3 accent features via phonemizeWithProsody()
  • Language detection -- UnicodeLanguageDetector auto-detects language from text
  • Custom dictionaries -- Override pronunciations with JSON v1.0/v2.0 or TSV format
  • Tree-shakeable -- Per-language subpath exports for minimal bundle size
  • No eSpeak-ng -- Zero GPL dependencies; fully MIT licensed

Comparison

| Feature | @piper-plus/g2p | phonemizer | gruut | Misaki | |---------------------|:--------------:|:----------:|:------:|:-------:| | License | MIT | GPL-3.0 | MIT | Apache-2.0 | | Languages | 8 | 100+ | ~20 | 2 | | Japanese | Yes | No | No | Yes | | Browser/WASM | Yes | No | No | No | | eSpeak-ng free | Yes | No | Yes | Yes | | Maintained (2026) | Yes | Yes | No | Yes |

API

G2P.create(options)

Creates and initializes a G2P instance.

  • options.languages -- Array of language codes to load (default: all)
  • Returns: Promise<G2P>

g2p.phonemize(text, lang?)

Converts text to IPA token array. Language is auto-detected if omitted.

g2p.phonemizeWithProsody(text, lang?)

Returns { tokens, prosody } with per-token prosody features (Japanese only).

Encoder.encode(tokens)

Encodes IPA tokens to Piper-compatible phoneme IDs with BOS/EOS/padding.

Cross-Platform Consistency

Also available as:

  • Python: piper-plus-g2p on PyPI
  • Rust crate: piper-plus-g2p on crates.io
  • Go: go get github.com/ayutaz/piper-plus/src/go/phonemize

All implementations share the same PUA mapping (pua_compat_version: 1) and are validated against a common test fixture.

Zero Dependencies

@piper-plus/g2p has zero npm runtime dependencies for rule-based languages (EN, ZH, KO, ES, FR, PT, SV). Only Japanese requires the bundled OpenJTalk WASM binary. This eliminates the most common vector for supply chain attacks in the JavaScript ecosystem.

License

MIT