Modules & Commands¶
hfst¶
Morphological analysis with finite state transducers.
tokenize
Tokenize text using PMHFST model.
Input: String | Output: String (CG3 format)
cg3¶
Constraint Grammar disambiguation and processing.
vislcg3
Apply CG3 rules from compiled grammar.
Input: String (CG3) | Output: String (CG3)
Tip
Enable tracing: -c 'vislcg3={"config":{"trace":true}}'
mwesplit
Split multi-word expressions.
Input: String (CG3) | Output: String (CG3)
streamcmd
Insert CG3 stream commands (SETVAR, REMVAR).
Input: String (CG3) | Output: String (CG3)
Tip
Configure: -c 'cmd-id="variable=value"'
sentences
Extract sentences from CG3 stream.
Input: String (CG3) | Output: ArrayString
to_json
Convert CG3 output to JSON.
Input: String (CG3) | Output: Json
divvun¶
Spell/grammar checking and suggestions.
blanktag
Analyze whitespace using HFST.
Input: String (CG3) | Output: String (CG3)
cgspell
Spell check with error models.
let x = divvun.cgspell(input, {
err_model_path: "errmodel.hfst",
acc_model_path: "acceptor.hfst",
config: {
n_best: 10,
max_weight: 5000.0,
beam: 15.0,
recase: true
}
});
Input: String (CG3) | Output: String (CG3 with suggestions)
suggest
Generate error report with suggestions.
Input: String (CG3 with error tags) | Output: Json (error array)
Tip
Configure locales and filters: -c 'suggest={"locales":["fo","en"],"ignore":["typo"]}'
speech¶
Text-to-speech synthesis.
Note
Speech features must be enabled during build.
normalize
Normalize text for TTS.
let x = speech.normalize(input, {
normalizers: { "Sem/Plc": "place-norm.hfst" },
generator: "generator.hfst",
analyzer: "analyzer.hfst"
});
Input: String (CG3) | Output: String (CG3 with phonological forms)
phon
Add phonological forms.
Input: String (CG3) | Output: String (CG3 with phon tags)
tts
Synthesize speech.
let audio = speech.tts(sentences, {
voice_model: "voice.onnx",
univnet_model: "vocoder.onnx",
speaker: 0,
language: 0,
alphabet: "sme" // "sme", "smj", "sma", "smi"
});
Input: String or ArrayString | Output: Bytes (WAV audio)
Tip
Override speaker: -c 'tts-cmd={"speaker":1}'
example¶
Learning and demo functions.