Module for creating context-aware, rule-based G2P mappings that preserve indices
Grapheme-to-Phoneme transductions that preserve input and output indices!
This library is for handling arbitrary transductions between input and output segments while preserving indices.
:warning: :construction: This repo is currently under construction :construction: :warning:
It is certainly useable, but you should proceed with caution when integrating into other projects as it is currently pre-alpha and breaking changes should be expected.
Table of Contents
The initial version of this package was developed by Patrick Littell and was developed in order to allow for g2p from community orthographies to IPA and back again in ReadAlong-Studio. We decided to then pull out the g2p mechanism from Convertextract which allows transducer relations to be declared in CSV files, and turn it into its own library - here it is!
The best thing to do is install with pip
pip install g2p.
Otherwise, clone the repo and pip install it locally.
$ git clone https://github.com/roedoejet/g2p.git $ cd g2p $ pip install -e .
The easiest way to create a transducer is to use the
To use it, first import the function:
from g2p import make_g2p
Then, call it with an argument for
out_lang. Both must be strings equal to the name of a particular mapping.
>>> transducer = make_g2p('dan', 'eng-arpabet') >>> transducer('hej') 'HH EH Y'
There must be a valid path between the
out_lang in order for this to work. If you've edited a mapping or added a custom mapping, you must update g2p to include it:
If you edit or add new mappings to the
g2p.mappings.langs folder, you need to update
g2p. You do this by running
If you want to convert a string on the command line, you can use
g2p convert <input_text> <in_lang> <out_lang>
g2p convert hej dan eng-arpabet would produce
HH EH Y
If your language has a mapping to IPA and you want to generate a mapping between that and the English IPA mapping, you can use
g2p generate-mapping <in_lang> --ipa
g2p generate-mapping dan --ipa will produce a mapping from
eng-ipa. You must run
g2p update afterwards to update
g2p. The resulting mapping will be added to the folder in
You can also run the
g2p Studio which is a web interface for creating custom lookup tables to be used with g2p. To run the
g2p Studio either visit https://g2p-studio.herokuapp.com/ or run it locally using
Alternatively, you can run the app from the command line:
Feel free to dive in! Open an issue or submit PRs.
This repo follows the Contributor Covenant Code of Conduct.
This project exists thanks to all the people who contribute.
MIT © Patrick Littell, Aidan Pine
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size g2p-0.2.20191130-py3-none-any.whl (2.2 MB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size g2p-0.2.20191130.tar.gz (945.0 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for g2p-0.2.20191130-py3-none-any.whl