Documentation
¶
Overview ¶
Package prg2p implements a grapheme-to-phoneme rule-based converter.
Usage
package main
import (
"fmt"
"github.com/mdm-code/prg2p"
)
func main() {
r := prg2p.Rules()
g2p, err := prg2p.Load(r)
if err != nil {
fmt.Println(err)
return
}
// Iterate over words to get their phonemic transcripts
var trans []string
for _, w := range []string{"ala", "ma", "kota"} {
t, err := g2p.Transcribe(w, false)
if err != nil {
fmt.Println(err)
continue
}
trans = append(trans, t...)
}
for _, t := range trans {
fmt.Println(t)
}
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type G2P ¶
type G2P struct {
// contains filtered or unexported fields
}
G2P transcriber class that takes a populated double trie tree with parsed grapheme-to-phoneme rules. It exposes transcription interface that takes individual words and outputs their most likely transcripts.
func Load ¶
Load returns a fully initialized G2P object with rules read from r.
Example ¶
package main
import (
"fmt"
"github.com/mdm-code/prg2p"
)
func main() {
r := prg2p.Rules()
g2p, err := prg2p.Load(r)
if err != nil {
fmt.Println(err)
return
}
var trans []string
for _, w := range []string{"ala", "ma", "kta"} {
t, err := g2p.Transcribe(w, false)
if err != nil {
fmt.Println(err)
continue
}
trans = append(trans, t...)
}
for _, t := range trans {
fmt.Println(t)
}
}
Click to show internal directories.
Click to hide internal directories.