Skip to main content

Open Source Thai Text-to-speech library in Python

Project description

PyThaiTTS

Open Source Thai Text-to-speech library in Python

Google Colab | Docs | Notebooks Download

License: Apache-2.0 License

Install

Install by pip:

pip install pythaitts

Usage

Basic Usage

from pythaitts import TTS

tts = TTS()
file = tts.tts("ภาษาไทย ง่าย มาก มาก", filename="cat.wav") # It will get wav file path.
wave = tts.tts("ภาษาไทย ง่าย มาก มาก",return_type="waveform") # It will get waveform.

Using Different TTS Models

PyThaiTTS supports multiple TTS models. You can specify which model to use:

from pythaitts import TTS

# Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
tts = TTS(pretrained="vachana")
file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")

# Use Lunarlist ONNX (default)
tts = TTS(pretrained="lunarlist_onnx")
file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")

# Use KhanomTan
tts = TTS(pretrained="khanomtan")
file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")

Text Preprocessing

PyThaiTTS includes automatic text preprocessing to improve TTS quality:

  • Number to Thai text conversion: Converts digits (e.g., "123") to Thai text (e.g., "หนึ่งร้อยยี่สิบสาม")
  • Mai yamok (ๆ) expansion: Expands the Thai repetition character (e.g., "ดีๆ" becomes "ดีดี")

Preprocessing is enabled by default:

from pythaitts import TTS

tts = TTS()
# Automatic preprocessing: "มี 5 คนๆ" becomes "มี ห้า คนคน"
file = tts.tts("มี 5 คนๆ", filename="output.wav")

You can disable preprocessing if needed:

file = tts.tts("มี 5 คนๆ", preprocess=False, filename="output.wav")

You can also use preprocessing functions directly:

from pythaitts import num_to_thai, expand_maiyamok, preprocess_text

# Convert numbers to Thai text
print(num_to_thai("123"))  # Output: หนึ่งร้อยยี่สิบสาม

# Expand mai yamok
print(expand_maiyamok("ดีๆ"))  # Output: ดีดี

# Full preprocessing
print(preprocess_text("มี 5 คนๆ"))  # Output: มี ห้า คนคน

You can see more at https://pythainlp.github.io/PyThaiTTS/.

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

pythaitts-0.4.2.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

pythaitts-0.4.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file pythaitts-0.4.2.tar.gz.

File metadata

  • Download URL: pythaitts-0.4.2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pythaitts-0.4.2.tar.gz
Algorithm Hash digest
SHA256 aa1feed3e1636c8af2f550ee8cef48d4f9118dfab733ce714e9ed06dfc1d63ae
MD5 46ac8c91e2bb41f5af4661c3d83f826b
BLAKE2b-256 14a22f8868879219f13daa1f2670e04b7383a5a67b03f8c37855d6070e68ffc3

See more details on using hashes here.

File details

Details for the file pythaitts-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: pythaitts-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pythaitts-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd821c074a529ea9a9ab475471219e8136f42d8e37ab8b0df22d76c19061e7d0
MD5 b6ab7db845642ddf4e12065475c782b4
BLAKE2b-256 0bb0f6d216661e1e4ba530722f0afb0ffc300e139e3641079ef5fc3b4f219d50

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