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.1.tar.gz (25.8 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.1-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygoruut-0.8.1.tar.gz
  • Upload date:
  • Size: 25.8 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.1.tar.gz
Algorithm Hash digest
SHA256 ba628d1da0fbf46df33635a8f8707e1dbd9c416e07d9db8030548d04b1b773f5
MD5 8b0f41675872014b374555935943bd09
BLAKE2b-256 3203645385f9df162bf54b04564dfaa9a4e7c87211ab2f2b742329c2e3b3e624

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygoruut-0.8.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b157cf5ca00d86590174dda6a76a597d876548d2b356535af9c4e8b75ca1defe
MD5 4da4c930c0482fbc136be1a43ba4cfdc
BLAKE2b-256 3a6bc7e0b372567f560378a3c8bea6a9d16e6c5a797adba8554d25c6a4a96eff

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