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="Slovak,EnglishBritish", sentence="hello world ahojte notindictionary!!!!"))

# Prints: həlˈoʊ wˈɜɹld aɦɔjtɛ nɔtinditstiɔnari!!!!

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 bʲikɪ̞ʃu mehasaʁˈim liftˈoaχ ʔˈet hadlatˈot ʃˈel bˈajit hasaʁˈim.

No punctuation

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

# Prints: həlˈoʊ 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.8.0.tar.gz (26.1 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.8.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygoruut-0.8.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pygoruut-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3ef8a52ed1c3f343c2653df3de7cfe5b4d348e8299756c702cec5bb12353d521
MD5 2e938c0ace86deb2e0a6d8fc63600d98
BLAKE2b-256 a4ee48df702f8d5706844258f953d14d03e4e2bed54878fa1b331d01304ca7c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygoruut-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pygoruut-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaab12cba15c073db8a2819141165c303e814dfa4c1901860099b6effa3e0547
MD5 2c2919d0bc02422b39535c1c319d5296
BLAKE2b-256 9b9b3f2c332f98658c061652ecdf22769951bb31a61e5413d6378735b82003e3

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