0.1.0 • Published 2 years ago

compromise-speech v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Syllables

Tokenize a word approximately by it's pronounced syllables. We use a custom rule-based alortithm for this.

import plg from 'compromise-speech'
nlp.extend(plg)

let doc = nlp('seventh millenium. white collar')
doc.syllables()
[ [ 'se', 'venth', 'mil', 'le', 'nium' ], [ 'white', 'col', 'lar' ] ]

Alternatively, if you'd like to combine syllable information with other properties, you can use .compute('syllables')

let doc = nlp('edmonton oilers')
doc.compute('syllables')
doc.json()
/*[{
  "terms": [
    {
      "normal": "edmonton",
      "syllables": ["ed", "mon", "ton"]
    },
    {
      "normal": "oilers",
      "syllables": ["oi", "lers"]
    }
  ]
}]
*/

SoundsLike

Generate an expected pronounciation for the word, as a normalized string. We use the metaphone implementation, which is a simple rule-based pronounciation system.

import plg from 'compromise-speech'
nlp.extend(plg)

let doc = nlp('seventh millenium. white collar')
doc.soundsLike()
// [ [ 'sefenth', 'milenium' ], [ 'wite', 'kolar' ] ]

Alternatively, if you'd like to combine syllable information with other properties, you can use .compute('syllables')

let doc = nlp('edmonton oilers')
doc.compute('soundsLike')
doc.json()
/*[{
  "terms": [
    {
      "normal": "edmonton",
      "soundsLike": "etmonton"
    },
    {
      "normal": "oilers",
      "soundsLike": "oilers"
    }
  ]
}]
*/

MIT