### Install on Linux Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Install the package on Linux using sudo make install. ```bash $ sudo make install ``` -------------------------------- ### Install OpenFst 1.7.2 for Phonetisaurus Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Download, configure, build, and install OpenFst 1.7.2. The configure flags are minimal and compatible with Kaldi defaults. Extends LD_LIBRARY_PATH in .bashrc assuming default install location. ```bash $ wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.7.2.tar.gz $ tar -xvzf openfst-1.7.2.tar.gz $ cd openfst-1.7.2 # Minimal configure, compatible with current defaults for Kaldi $ ./configure --enable-static --enable-shared --enable-far --enable-ngram-fsts $ make -j # Now wait a while... $ sudo make install # Extend your LD_LIBRARY_PATH .bashrc (assumes OpenFst installed to default location): $ echo 'export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/local/lib/fst' \ >> ~/.bashrc $ source ~/.bashrc $ cd .. ``` -------------------------------- ### Run G2P servlet and query with curl Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Start the G2P servlet in the background with nohup and send a word list via curl to the /phoneticize/list endpoint. Requires compilation of bindings and module install. Output shows pronunciations for each word. ```bash $ nohup script/g2pserver.py -m ~/train/model.fst -l ~/cmudict.formatted.dict & $ curl -s -F "wordlist=@words.list" http://localhost:8080/phoneticize/list test T EH1 S T right R AY1 T junkify JH AH1 NG K AH0 F AY2 junkify JH AH1 NG K IH0 F AY2 ``` -------------------------------- ### Compile Phonetisaurus with Python 3 bindings Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Clone and compile Phonetisaurus with Python 3 bindings. Requires pybindgen and uses PYTHON=python3 with --enable-python. Copies the built .so into the python directory and installs the setup.py package. ```bash $ git clone https://github.com/AdolfVonKleist/Phonetisaurus.git $ cd Phonetisaurus $ sudo pip3 install pybindgen # if OpenFst is installed in the default location: $ PYTHON=python3 ./configure --enable-python # if OpenFst is installed in a special location: $ PYTHON=python3 ./configure \ --with-openfst-includes=${OFST_PATH}/openfst-1.7.2/include \ --with-openfst-libs=${OFST_PATH}/openfst-1.7.2/lib \ --enable-python $ make $ sudo make install $ cd python $ cp ../.libs/Phonetisaurus.so . $ sudo python3 setup.py install $ cd ../.. ``` -------------------------------- ### Install mitlm for Phonetisaurus test model Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Clone, build, and install mitlm, which is used to build a quick test model with the CMUdict. ```bash $ git clone https://github.com/mitlm/mitlm.git $ cd mitlm/ $ ./autogen.sh $ make $ sudo make install $ cd .. ``` -------------------------------- ### Install Ubuntu dependencies for Phonetisaurus build Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Install system dependencies for building Phonetisaurus on Ubuntu 20.04. Includes basics for compilation, Python bindings, and gfortran for mitlm. ```bash $ sudo apt-get update # Basics $ sudo apt-get install git g++ autoconf-archive make libtool # Python bindings $ sudo apt-get install python-setuptools python-dev # mitlm (to build a quick play model) $ sudo apt-get install gfortran ``` -------------------------------- ### Configure with custom OpenFst and parallel build Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Configure and build with a custom OpenFst location and parallel make using 2 cores. ```bash $ ./configure --with-openfst-libs=/home/ubuntu/openfst-1.6.2/lib \ --with-openfst-includes=/home/ubuntu/openfst-1.6.2/include $ make -j 2 all ``` -------------------------------- ### Rebuild configure with autoreconf Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Rebuild the configure script using autoreconf. ```bash $ autoreconf -i ``` -------------------------------- ### Create work directory for Phonetisaurus build Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Create and enter a work directory for the build process. ```bash $ mkdir g2p $ cd g2p/ ``` -------------------------------- ### Show phonetisaurus-align help Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Displays the help information for the phonetisaurus-align command. ```bash $ bin/phonetisaurus-align --help ``` -------------------------------- ### Generate pronunciations with phonetisaurus-apply Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Generate pronunciations for a word list using the wrapper script. The output shows the word and its phoneme sequence for each input word. ```bash $ phonetisaurus-apply --model train/model.fst --word_list test.wlist test T EH1 S T jumbotron JH AH1 M B OW0 T R AA0 N excellent EH1 K S AH0 L AH0 N T eggselent EH1 G S L AH0 N T ``` -------------------------------- ### Run cpplint with custom filters Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Runs cpplint on src/include/util.h with specific filters to suppress certain style warnings. ```bash $ ./cpplint.py --filter=-whitespace/parens,-whitespace/braces,\ -legal/copyright,-build/namespaces,-runtime/references\ src/include/util.h ``` -------------------------------- ### Show phonetisaurus-arpa2wfst help Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Displays the help information for the phonetisaurus-arpa2wfst command. ```bash $ bin/phonetisaurus-arpa2wfst --help ``` -------------------------------- ### Show phonetisaurus-g2prnn help Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Displays the help information for the phonetisaurus-g2prnn command. ```bash $ bin/phonetisaurus-g2prnn --help ``` -------------------------------- ### Configure with custom g++ under OSX Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Configure and build using a custom g++ (g++-4.9) under OSX. Note: OpenFst must also be compiled with this custom g++ alternative; untested with v1.6.2. ```bash $ ./configure --with-openfst-libs=/home/osx/openfst-1.6.2gcc/lib \ --with-openfst-includes=/home/osx/openfst-1.6.2gcc/include \ CXX=g++-4.9 $ make -j 2 all ``` -------------------------------- ### Run phonetisaurus-apply via Docker Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Runs the phonetisaurus-apply program inside a Docker container, mounting the current directory to /work and passing the command as an argument. ```bash docker run --rm -it -v $PWD:/work phonetisaurus/phonetisaurus "phonetisaurus-apply -m model.fst -wl test.wlist" ``` -------------------------------- ### Show phonetisaurus-g2pfst help Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Displays the help information for the phonetisaurus-g2pfst command. ```bash $ bin/phonetisaurus-g2pfst --help ``` -------------------------------- ### Test manual model with phoneticize.py Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Test a manually built model with the wrapper script phoneticize.py, passing the OpenFst model and a word. Output shows the pronunciation score and per-phone alignment details. ```bash $ cd Phonetisaurus/script $ ./phoneticize.py -m ~/example/cmudict.o8.fst -w testing 11.24 T EH1 S T IH0 NG ------- t:T:3.31 e:EH1:2.26 s:S:2.61 t:T:0.21 i:IH0:2.66 n|g:NG:0.16 ::0.01 ``` -------------------------------- ### Uninstall on Linux Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Uninstall the package on Linux using sudo make uninstall. ```bash $ sudo make uninstall ``` -------------------------------- ### Build joint n-gram model: align, estimate-ngram, arpa2wfst Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Step-by-step pipeline to build a joint n-gram G2P model: align the dictionary with phonetisaurus-align, train an 8-gram model with estimate-ngram, and convert the ARPA model to OpenFst format with phonetisaurus-arpa2wfst. Approximate runtimes are noted in comments. ```bash # Align the dictionary (5m-10m) $ phonetisaurus-align --input=cmudict.formatted.dict \ --ofile=cmudict.formatted.corpus --seq1_del=false # Train an n-gram model (5s-10s): $ estimate-ngram -o 8 -t cmudict.formatted.corpus \ -wl cmudict.o8.arpa # Convert to OpenFst format (10s-20s): $ phonetisaurus-arpa2wfst --lm=cmudict.o8.arpa --ofile=cmudict.o8.fst $ cd ``` -------------------------------- ### Train G2P model with phonetisaurus-train Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Train a complete G2P model with default parameters using the wrapper script. Requires the tool to be compiled with Python 3 bindings. Output shows the training steps and final model path train/model.fst. ```bash $ phonetisaurus-train --lexicon cmudict.formatted.dict --seq2_del INFO:phonetisaurus-train:2017-07-09 16:35:31: Checking command configuration... INFO:phonetisaurus-train:2017-07-09 16:35:31: Checking lexicon for reserved characters: '}', '|', '_'... INFO:phonetisaurus-train:2017-07-09 16:35:31: Aligning lexicon... INFO:phonetisaurus-train:2017-07-09 16:37:44: Training joint ngram model... INFO:phonetisaurus-train:2017-07-09 16:37:46: Converting ARPA format joint n-gram model to WFST format... INFO:phonetisaurus-train:2017-07-09 16:37:59: G2P training succeeded: train/model.fst ``` -------------------------------- ### Compile Phonetisaurus without Python bindings Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Clone and compile Phonetisaurus without Python bindings. Use the default configure if OpenFst is in the default location, or specify include and lib paths otherwise. ```bash $ git clone https://github.com/AdolfVonKleist/Phonetisaurus.git $ cd Phonetisaurus # if OpenFst is installed in the default location: $ ./configure # if OpenFst is installed in a special location: $ ./configure \ --with-openfst-includes=${OFST_PATH}/openfst-1.7.2/include \ --with-openfst-libs=${OFST_PATH}/openfst-1.7.2/lib $ make $ sudo make install $ cd .. ``` -------------------------------- ### phonetisaurus-apply with probability mass and normalized scores Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Run phonetisaurus-apply with the -a (accumulate) and -p 0.85 (probability mass) options, printing normalized probabilities instead of negative log scores. Output shows the underlying phonetisaurus-g2pfst command and per-word probabilities. ```bash phonetisaurus-apply --model train/model.fst --word_list Phonetisaurus/script/words.list -v -a -p 0.85 -pr DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: Checking command configuration... DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: accumulate: True DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: beam: 10000 DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: greedy: False DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: lexicon_file: None DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: logger: DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: model: train/model.fst DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: nbest: 100 DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: pmass: 0.85 DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: probs: True DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: thresh: 99.0 DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: verbose: True DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: phonetisaurus-g2pfst --model=train/model.fst --nbest=100 --beam=10000 --thresh=99.0 --accumulate=true --pmass=0.85 --nlog_probs=false --wordlist=Phonetisaurus/script/words.list DEBUG:phonetisaurus-apply:2017-07-30 11:55:58: Applying G2P model... GitRevision: kaldi-2-g6e7c04-dirty test 0.68 T EH1 S T test 0.21 T EH2 S T right 0.81 R AY1 T right 0.13 R AY0 T junkify 0.64 JH AH1 NG K AH0 F AY2 junkify 0.23 JH AH1 NG K IH0 F AY2 ``` -------------------------------- ### phonetisaurus-apply with n-best and lexicon filter Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Run phonetisaurus-apply with n-best=2, greedy mode, verbose logging, and a reference lexicon filter. Output shows raw negative log scores for each candidate pronunciation. ```bash $ phonetisaurus-apply --model train/model.fst --word_list test.wlist -n 2 -g -v -l cmudict.formatted.dict DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: Checking command configuration... DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: beam: 10000 DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: greedy: True DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: lexicon_file: cmudict.formatted.dict DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: model: train/model.fst DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: nbest: 2 DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: thresh: 99.0 DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: verbose: True DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: Loading lexicon from file... DEBUG:phonetisaurus-apply:2017-07-09 16:48:22: Applying G2P model... GitRevision: kaldi-1-g5028ba-dirty eggselent 26.85 EH1 G S L AH0 N T eggselent 28.12 EH1 G Z L AH0 N T excellent 0.00 EH1 K S AH0 L AH0 N T excellent 19.28 EH1 K S L EH1 N T jumbotron 0.00 JH AH1 M B OW0 T R AA0 N jumbotron 17.30 JH AH1 M B OW0 T R AA2 N test 0.00 T EH1 S T test 11.56 T EH2 S T ``` -------------------------------- ### Download and format CMUdict for Phonetisaurus Source: https://github.com/adolfvonkleist/phonetisaurus/blob/master/README.md Download the latest CMUdict and reformat it into a tab-separated lexicon file. The Perl one-liner removes stress markers, normalizes whitespace, and outputs word and phonemes separated by a tab. ```bash $ mkdir example $ cd example $ wget https://raw.githubusercontent.com/cmusphinx/cmudict/master/cmudict.dict # Clean it up a bit and reformat: $ cat cmudict.dict \ | perl -pe 's/\([0-9]+\)//; s/\s+/ /g; s/^\s+//; s/\s+$//; @_ = split (/\s+/); $w = shift (@_); $_ = $w."\t".join (" ", @_)."\n";' \ > cmudict.formatted.dict ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.