npm.io
0.0.1 • Published 2 years ago

phonetisaurus

Licence
MIT
Version
0.0.1
Deps
0
Size
4.0 MB
Vulns
0
Weekly
0
Stars
5

Phonetisaurus.js

Grapheme to Phoneme on the Web powered by WebAssembly.

import phonetisaurus from 'phonetisaurus'

// download the remote model file
const res = await fetch("https://example.com/model.fst")
const buffer = await res.arrayBuffer();

// write to a virtual file system
phonetisaurus.FS.writeFile("/model.fst", buffer)

// create phonemizer instance
const phonemizer = new phonetisaurus.Phonemizer("/model.fst", "")
const result = phonemizer.phoneticize("hello", 10, 500, 10, false, false, 0.0)

// => [[ 'h', 'ɛɛ', 'l', 'oo' ]]

Reference