Skip to main content

No project description provided

Project description

Gⁱ-2-Pⁱ

Coverage 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.

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//

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.IOStates object>)

To make sense of the IOStates 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

@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.

License

MIT © 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.1.20190816.tar.gz (636.6 kB view details)

Uploaded Source

Built Distribution

g2p-0.1.20190816-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: g2p-0.1.20190816.tar.gz
  • Upload date:
  • Size: 636.6 kB
  • 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.3

File hashes

Hashes for g2p-0.1.20190816.tar.gz
Algorithm Hash digest
SHA256 df499c666a49c954819ec4bcd1630156bb97dff93df656af67950a5ebab86706
MD5 43025dd7aaec08d963b30cec30ee12a0
BLAKE2b-256 c1dae98b4bc48df0e6a10d94a1767bd07388aafe4ea1777ce3afa93463423362

See more details on using hashes here.

File details

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

File metadata

  • Download URL: g2p-0.1.20190816-py3-none-any.whl
  • Upload date:
  • Size: 1.3 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.3

File hashes

Hashes for g2p-0.1.20190816-py3-none-any.whl
Algorithm Hash digest
SHA256 1a7c675ecdd7f9cf3746ebb7fac96cc3e14068da20ad12485775ac07278cf914
MD5 08497a671698ca0120017d1556722319
BLAKE2b-256 ba7dce41f7f2285a10f6926ec2a1673a7686677db105a20db0ca4daa4b8ea11b

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