Skip to main content

Text-to-IPA converter and phonetic translator for Python, powered by the Goruut phonemization engine

Project description

pygoruut

Getting started

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut()

print(str(pygoruut.phonemize(language="EnglishAmerican", sentence="fast racing car")))

# Prints: fˈæst ɹˈeɪsɪŋ kˈɑɹ

# Now, convert it back

print(str(pygoruut.phonemize(language="EnglishAmerican", sentence="fˈæst ɹˈeɪsɪŋ kˈɑɹ", is_reverse=True)))

# Prints: fast racing car

ℹ️ For English, we recommend using EnglishBritish or EnglishAmerican instead of English. These dialect-specific models use high-quality Kokoro Misaki dictionaries and produce better results, especially for reversing IPA back to text.


Uyghur language, our highest quality language

print(str(pygoruut.phonemize(language="Uyghur", sentence="قىزىل گۈل ئاتا")))

# Prints: qizil gyl ʔɑtɑ

# Now, convert it back

print(str(pygoruut.phonemize(language="Uyghur", sentence="qizil gyl ʔɑtɑ", is_reverse=True)))

# Prints: قىزىل گۈل ئاتا

The quality of translation varies across the 136 supported languages.


Advanced Use

Multi-lingual sentence handling

Use comma (,) separated languages in language. The first language is the preferred language:

print(pygoruut.phonemize(language="EnglishBritish,Slovak", sentence="hello world ahojte notindictionary!!!!"))

# Prints: həlˈoʊ wˈɜɹld aɦɔjcɛ ŋətandəktɪnˈɑːɪ!!!!

Numerics handling (English, Arabic)

print(str(pygoruut.phonemize(language="EnglishBritish", sentence="100 bottles")))

# Prints: wˈʌn hˈʌndɹəd bˈɒtəlz

Homograph handling (Hebrew3)

print(str(pygoruut.phonemize(language="Hebrew3", sentence="השרים ביקשו מהשרים לפתוח את הדלתות של בית השרים.")))

# Prints: hasaʁˈim bikʃˈu mehasaʁˈim liftˈoaχ ʔˈat hadlatˈot ʃˈel bˈet hasaʁˈim.

No punctuation

print(str(pygoruut.phonemize(language="EnglishBritish", sentence="hello world!!!!", is_punct=False)))

# Prints: həlˈəʊ wˈɜːld

Force a specific version

You can pin a specific version. It will translate all words in the same way forever:

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut(version='v0.6.2')

Use an online inference api

You can use an inference api. The model will not be downloaded:

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut(api='https://hashtron.cloud')

Use an extra model

Extra model can be loaded from a ZIP file manually. It extends a specific language.

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut(models={"Hebrew3": "/home/john/Downloads/hebrew3.zip"})

Configure a model download directory for faster startup

To cache models in a user-specified directory:

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut(writeable_bin_dir='/home/john/')

To cache in the user's home subdirectory .goruut:

from pygoruut.pygoruut import Pygoruut

pygoruut = Pygoruut(writeable_bin_dir='')

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

pygoruut-0.6.5.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygoruut-0.6.5-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file pygoruut-0.6.5.tar.gz.

File metadata

  • Download URL: pygoruut-0.6.5.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pygoruut-0.6.5.tar.gz
Algorithm Hash digest
SHA256 de1835a402c91c2d603a44e6dca8663242c1caa0538289ed20c0dfdad19856b9
MD5 fb82d5035f8a04115f9271b2f38ba4b9
BLAKE2b-256 4536fa2c1113850c98f15a666f4a54b60b65ffb211726e4644e1971f3a190df2

See more details on using hashes here.

File details

Details for the file pygoruut-0.6.5-py3-none-any.whl.

File metadata

  • Download URL: pygoruut-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pygoruut-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1bfde53cf3143354cf3c08bfade809f2cd4bf5649e14fefd689de8426ff4cfda
MD5 8a4dd9a7db5d79ff01cdc7b069172fbe
BLAKE2b-256 b8e896cfa03907725369d025feb6aa1be5f4cf264c0efaf87f9c82fbe3e2766e

See more details on using hashes here.

Supported by

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