Gⁱ-2-Pⁱ
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.
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
In order to initialize a Transducer, you must first create a Mapping object.
Mapping
You can create mappings either by initializing them directly with a list:
from g2p.mappings import Mapping
mappings = Mapping([{"in": 'a', "out": 'b'}])
Alternatively, you can add a CSV file to g2p/mappings/langs/<YourLang>/<YourLookupTable>
from g2p.mappings import Mapping
mappings = Mapping(language={"lang": "<YourLang>", "table": "<YourLookupTable>"})
Transducer
Initialize a Transducer with a Mapping object. Calling the Transducer then produces the output. In order to preserve the indices, pass index=True when calling the Transducer.
from g2p.mappings import Mapping
from g2p.transducer import Transducer
mappings = Mapping([{"in": 'a', "out": 'b'}])
transducer = Transducer(mappings)
transducer('a')
# 'b'
transducer('a', index=True)
# ('b', <g2p.transducer.indices.Indices object>)
To make sense of the Indices object that is produced, you can either call it, and produce a list of each character. Doing that for the above produces [((0, 'a'), (0, 'b'))] - a list of relation tuples where each relation tuple is comprised of an input and output. Each input tuple and output tuple is in turn comprised of an index and a corresponding character. You can also call output() and input() to see the plain text output and input respectively.
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 ***** or run it locally using python run_studio.py.
You can also import the app directly from the package:
from g2p import app
app.run(host='0.0.0.0', port=5000, debug=True)
Maintainers
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. @eddieantonio. @dhdaines.
License
MIT © Patrick Littell, Aidan Pine
Metadata
Release files for g2p 0.2.20190919
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| g2p-0.2.20190919.tar.gz | 1.5 MB | Without provenance | Details for g2p-0.2.20190919.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| g2p-0.2.20190919-py3-none-any.whl | Python 3 | none | any | Details for g2p-0.2.20190919-py3-none-any.whl |
Total release size: 3.8 MB
Release files / g2p-0.2.20190919.tar.gz
| Download URL | g2p-0.2.20190919.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
184a28b8e068228cc74fd829098b57dd7b40934f0ea9dfbd8ff30db62cbe35a3
|
|
BLAKE2b-256 checksum How to use checksums |
1aa1d6bc95623b0fe596719fd3d822a131966d059e510b796b6089ae9be9a0d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / g2p-0.2.20190919-py3-none-any.whl
| Download URL | g2p-0.2.20190919-py3-none-any.whl |
|---|---|
| Size | 2.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fd574e842a715359dc8dd21201561890bba342a931934b7d3981c56d5c94758
|
|
BLAKE2b-256 checksum How to use checksums |
b4dd041de95371a0b181ce20013d8af31974bc33c2fa2be7daf1333d2f9dc906
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for g2p 0.2.20190919
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.