Package: pronunciation-dictionary-utils
pronunciation-dictionary-utilsLibrary and CLI to modify pronunciation dictionaries (any language).Featuresexport-vocabulary: export vocabulary from dictionariesexport-phonemes: export phoneme set from dictionariesmerge: merge dictionaries togetherextract: extract subset of dictionary vocabularymap-symbols-in-pronunciations: map phonemes/symbols in pronunciations to another phoneme/symbol, e.g., mapping ARPAbet to IPAmap-symbols-in-pronunciations-json: map phonemes/symbols in pronunciations to phoneme/symbol specified in fileremove-symbols-from-vocabulary: remove phonemes/symbols from vocabularyremove-symbols-from-pronunciations: remove phonemes/symbols from pronunciationsremove-symbols-from-words: remove characters/symbols from wordschange-formatting: change formatting of dictionariesselect-single-pronunciation: select single pronunciationchange-word-casing: transform all words to upper- or lower-casesort-words: sort dictionary after wordssort-pronunciations: sort dictionary pronunciationsnormalize-weights: normalize pronunciation weights for each wordRoadmapAdding testsImplementation of printing of statisticsAdd change of pronunciation for a word via CLIInstallationpipinstallpronunciation-dictionary-utils--userUsageusage: dict-cli [-h] [-v]
                {export-vocabulary,export-phonemes,merge,extract,map-symbols-in-pronunciations,map-symbols-in-pronunciations-json,remove-symbols-from-vocabulary,remove-symbols-from-pronunciations,remove-symbols-from-words,change-formatting,select-single-pronunciation,change-word-casing,sort-words,sort-pronunciations,normalize-weights}
                ...

This program provides methods to modify pronunciation dictionaries.

positional arguments:
  {export-vocabulary,export-phonemes,merge,extract,map-symbols-in-pronunciations,map-symbols-in-pronunciations-json,remove-symbols-from-vocabulary,remove-symbols-from-pronunciations,remove-symbols-from-words,change-formatting,select-single-pronunciation,change-word-casing,sort-words,sort-pronunciations,normalize-weights}
                                        description
    export-vocabulary                   export vocabulary from dictionaries
    export-phonemes                     export phoneme set from dictionaries
    merge                               merge dictionaries together
    extract                             extract subset of dictionary vocabulary
    map-symbols-in-pronunciations       map phonemes/symbols in pronunciations to another phoneme/symbol, e.g., mapping ARPAbet to IPA
    map-symbols-in-pronunciations-json  map phonemes/symbols in pronunciations to phoneme/symbol specified in file
    remove-symbols-from-vocabulary      remove phonemes/symbols from vocabulary
    remove-symbols-from-pronunciations  remove phonemes/symbols from pronunciations
    remove-symbols-from-words           remove characters/symbols from words
    change-formatting                   change formatting of dictionaries
    select-single-pronunciation         select single pronunciation
    change-word-casing                  transform all words to upper- or lower-case
    sort-words                          sort dictionary after words
    sort-pronunciations                 sort dictionary pronunciations
    normalize-weights                   normalize pronunciation weights for each word

optional arguments:
  -h, --help                            show this help message and exit
  -v, --version                         show program's version number and exitExample# Download CMU dictionarywgethttps://raw.githubusercontent.com/cmusphinx/cmudict/master/cmudict.dict\-O"/tmp/example.dict"# Change formatting to remove numbers from words, comments and save as UTF-8dict-clichange-formatting\"/tmp/example.dict"\--deserialization-encoding"ISO-8859-1"\--consider-numbers\--consider-pronunciation-comments\--serialization-encoding"UTF-8"# Export phoneme setdict-cliexport-phonemes\"/tmp/example.dict"\"/tmp/example-phoneme-set.txt"# Export vocabularydict-cliexport-vocabulary\"/tmp/example.dict"\"/tmp/example-vocabulary.txt"# Keep first pronunciation for each word and discard the restdict-cliselect-single-pronunciation\"/tmp/example.dict"\--mode"first"# Replace all "ER0" phonemes with "ER"dict-climap-symbols-in-pronunciations\"/tmp/example.dict"\"ER0""ER"ContributingDevelopment setup# updatesudoaptupdate# install Python 3.8-3.12 for ensuring that tests can be runsudoaptinstallpython3-pip\python3.8python3.8-devpython3.8-distutilspython3.8-venv\python3.9python3.9-devpython3.9-distutilspython3.9-venv\python3.10python3.10-devpython3.10-distutilspython3.10-venv\python3.11python3.11-devpython3.11-distutilspython3.11-venv\python3.12python3.12-devpython3.12-distutilspython3.12-venv# install pipenv for creation of virtual environmentspython3.8-mpipinstallpipenv--user# check out repogitclonehttps://github.com/stefantaubert/pronunciation-dictionary-utils.gitcdpronunciation-dictionary-utils# create virtual environmentpython3.8-mpipenvinstall--devRunning the tests# first install the tool like in "Development setup"# then, navigate into the directory of the repo (if not already done)cdpronunciation-dictionary-utils# activate environmentpython3.8-mpipenvshell# run teststoxFinal lines of test result output:py38: commands succeeded
py39: commands succeeded
py310: commands succeeded
py311: commands succeeded
py312: commands succeeded
congratulations :)AcknowledgmentsFunded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – Project-ID 416228727 – CRC 1410CitationIf you want to cite this repo, you can use this BibTeX-entry generated by GitHub (seeAbout => Cite this repository).Taubert, S., and Przybysz, N. (2024). pronunciation-dictionary-utils (Version 0.0.5) [Computer software]. https://doi.org/10.5281/zenodo.10560153