Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.24 KB

File metadata and controls

52 lines (36 loc) · 1.24 KB

IPA Engine

A lightweight package to convert text to IPA (International Phonetic Alphabet) symbols.

Command-line usage

Run a query without installing the package:

uvx ipa-engine "Ça va bien?" --lang fr_FR

Load more than one language dictionary by repeating --lang:

uvx ipa-engine "hello 世界" --lang en_US --lang zh_hans

Use --preserve-unknown (or -p) to keep characters that are not present in the selected dictionaries:

uvx ipa-engine "hello, Codex!" --lang en_US --preserve-unknown

Run uvx ipa-engine --help to see all options. The legacy ipa-translate command remains available when the package is installed.

Demo usage

import logging

from ipa_engine import IPAEngine

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# Create an instance of IPASession
# ipa_session = IPASession(languages=["zh_hans"])
logger.debug("Initializing IPA session...")
ipa_session = IPAEngine(languages=["fr_FR"])
logger.debug("IPA session initialized.")

# Translate a sentence
sentence = "Ça va bien?"
ipa_result = ipa_session.translate_ipa(sentence)
logger.debug(
    "IPA translation: %s",
    "".join(ipa_result))  # Output will be a list of IPA transcriptions