hama on-device NLP

Quickstart

Minimal examples for G2P, pronunciation correction, and phoneme ASR.

G2P

from hama import G2PModel

model = G2PModel()
result = model.predict(
  "Really? What's the orbital velocity of the moon?",
  preserve_literals="punct",
)
print(result.ipa)
print(result.display_ipa)

Pronunciation Correction

from hama import pronunciation_replace

text = "we met (jon smyth), yesterday"
terms = [{"text": "John Smythe"}]

result = pronunciation_replace(text, terms)
print(result["text"])

ASR

from hama import ASRModel

model = ASRModel()
result = model.transcribe_file("sample.wav")
print(result.phoneme_text)
print(result.word_phoneme_text)

For full signatures, options, and return shapes, see APIs.