Skip to main content

Module for creating context-aware, rule-based G2P mappings that preserve indices

Project description

Gⁱ-2-Pⁱ

Coverage Status Documentation Status Build Status PyPI package license standard-readme compliant

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

Background

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!

Install

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 .

Usage

The easiest way to create a transducer is to use the g2p.make_g2p function.

To use it, first import the function:

from g2p import make_g2p

Then, call it with an argument for in_lang and 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 in_lang and 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: g2p update

CLI

update

If you edit or add new mappings to the g2p.mappings.langs folder, you need to update g2p. You do this by running g2p update

convert

If you want to convert a string on the command line, you can use g2p convert <input_text> <in_lang> <out_lang>

Ex. g2p convert hej dan eng-arpabet would produce HH EH Y

generate-mapping

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

Ex. g2p generate-mapping dan --ipa will produce a mapping from dan-ipa to eng-ipa. You must run g2p update afterwards to update g2p. The resulting mapping will be added to the folder in g2p.mappings.langs.generated

Studio

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 python run_studio.py.

Alternatively, you can run the app from the command line: g2p run.

Maintainers

@roedoejet.

Contributing

Feel free to dive in! Open an issue or submit PRs.

This repo follows the Contributor Covenant Code of Conduct.

Contributors

This project exists thanks to all the people who contribute.

@littell. @finguist. @joanise. @eddieantonio. @dhdaines.

License

MIT © Patrick Littell, Aidan Pine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

g2p-0.3.20200220.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

g2p-0.3.20200220-py3-none-any.whl (2.8 MB view details)

Uploaded Python 3

File details

Details for the file g2p-0.3.20200220.tar.gz.

File metadata

  • Download URL: g2p-0.3.20200220.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for g2p-0.3.20200220.tar.gz
Algorithm Hash digest
SHA256 f591a3352230a6948fa006b09be8d3fe2c6020c5dd51f521da466d23421662ae
MD5 5d6a23ce911dd711af0d5d77b9eafc0e
BLAKE2b-256 86f1a962f68e6c4c633cf5cb1625075ee9ab6387336933ab8a9a9b890a9584a2

See more details on using hashes here.

File details

Details for the file g2p-0.3.20200220-py3-none-any.whl.

File metadata

  • Download URL: g2p-0.3.20200220-py3-none-any.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4

File hashes

Hashes for g2p-0.3.20200220-py3-none-any.whl
Algorithm Hash digest
SHA256 5e437f49eda5394a85a1dfd7953c463b8d32aa3eb5a262bb576d385b61775740
MD5 a5507293f733268914cffcff0f704886
BLAKE2b-256 29f1dfa5751244dac1bda191260edd42738a6134d693fd8c72c901f00e23e8b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page