PyThaiTTS 0.4.2__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {pythaitts-0.4.2 → pythaitts-0.5.0}/PKG-INFO +10 -1
  2. {pythaitts-0.4.2 → pythaitts-0.5.0}/PyThaiTTS.egg-info/PKG-INFO +10 -1
  3. pythaitts-0.5.0/PyThaiTTS.egg-info/SOURCES.txt +37 -0
  4. {pythaitts-0.4.2 → pythaitts-0.5.0}/PyThaiTTS.egg-info/requires.txt +1 -0
  5. {pythaitts-0.4.2 → pythaitts-0.5.0}/README.md +8 -0
  6. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/__init__.py +19 -10
  7. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/__init__.py +35 -0
  8. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/_data.py +30 -0
  9. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/_th2ipa.py +1576 -0
  10. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/dict.txt +62112 -0
  11. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/PhSTrigram.sts +68702 -0
  12. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/sylform_var.pkl +0 -0
  13. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/sylrule.lts +273 -0
  14. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/sylseg.3g +0 -0
  15. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/thaisyl.dict +2127 -0
  16. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/fallback/thdict +0 -0
  17. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/data/ipa.json +62114 -0
  18. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/fallback.py +101 -0
  19. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/g2p.py +58 -0
  20. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/kokoro.py +88 -0
  21. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/normalizer.py +502 -0
  22. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/tokenizer.py +42 -0
  23. pythaitts-0.5.0/pythaitts/pretrained/fastthaig2p/tts.py +381 -0
  24. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/pretrained/khanomtan_tts.py +2 -0
  25. {pythaitts-0.4.2 → pythaitts-0.5.0}/setup.py +5 -1
  26. pythaitts-0.5.0/tests/test_fastthaig2p.py +186 -0
  27. pythaitts-0.4.2/PyThaiTTS.egg-info/SOURCES.txt +0 -19
  28. {pythaitts-0.4.2 → pythaitts-0.5.0}/LICENSE +0 -0
  29. {pythaitts-0.4.2 → pythaitts-0.5.0}/PyThaiTTS.egg-info/dependency_links.txt +0 -0
  30. {pythaitts-0.4.2 → pythaitts-0.5.0}/PyThaiTTS.egg-info/not-zip-safe +0 -0
  31. {pythaitts-0.4.2 → pythaitts-0.5.0}/PyThaiTTS.egg-info/top_level.txt +0 -0
  32. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/preprocess.py +0 -0
  33. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/pretrained/__init__.py +0 -0
  34. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/pretrained/lunarlist_model.py +0 -0
  35. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/pretrained/lunarlist_onnx.py +0 -0
  36. {pythaitts-0.4.2 → pythaitts-0.5.0}/pythaitts/pretrained/vachana_tts.py +0 -0
  37. {pythaitts-0.4.2 → pythaitts-0.5.0}/setup.cfg +0 -0
  38. {pythaitts-0.4.2 → pythaitts-0.5.0}/tests/__init__.py +0 -0
  39. {pythaitts-0.4.2 → pythaitts-0.5.0}/tests/test_preprocess.py +0 -0
  40. {pythaitts-0.4.2 → pythaitts-0.5.0}/tests/test_vachana.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyThaiTTS
3
- Version: 0.4.2
3
+ Version: 0.5.0
4
4
  Summary: Open Source Thai Text-to-speech library in Python
5
5
  Home-page: https://github.com/pythainlp/pythaitts
6
6
  Author: Wannaphong
@@ -26,6 +26,7 @@ Requires-Dist: numpy>=1.22
26
26
  Requires-Dist: onnxruntime
27
27
  Requires-Dist: vachanatts
28
28
  Requires-Dist: soundfile
29
+ Requires-Dist: pythainlp
29
30
  Dynamic: author
30
31
  Dynamic: author-email
31
32
  Dynamic: classifier
@@ -76,14 +77,22 @@ PyThaiTTS supports multiple TTS models. You can specify which model to use:
76
77
  from pythaitts import TTS
77
78
 
78
79
  # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
80
+ # Sample Rate is 22050 Hz
79
81
  tts = TTS(pretrained="vachana")
80
82
  file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
81
83
 
82
84
  # Use Lunarlist ONNX (default)
85
+ # Sample Rate is 22050 Hz
83
86
  tts = TTS(pretrained="lunarlist_onnx")
84
87
  file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
85
88
 
89
+ # Use FastThaiG2P (default voice: thai_som)
90
+ # FastThaiG2P Sample Rate is 24000 Hz
91
+ tts = TTS(pretrained="fastthaig2p")
92
+ file = tts.tts("สวัสดีครับ", speaker_idx="thai_som", filename="output.wav")
93
+
86
94
  # Use KhanomTan
95
+ # Sample Rate is 16000 Hz
87
96
  tts = TTS(pretrained="khanomtan")
88
97
  file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
89
98
  ```
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyThaiTTS
3
- Version: 0.4.2
3
+ Version: 0.5.0
4
4
  Summary: Open Source Thai Text-to-speech library in Python
5
5
  Home-page: https://github.com/pythainlp/pythaitts
6
6
  Author: Wannaphong
@@ -26,6 +26,7 @@ Requires-Dist: numpy>=1.22
26
26
  Requires-Dist: onnxruntime
27
27
  Requires-Dist: vachanatts
28
28
  Requires-Dist: soundfile
29
+ Requires-Dist: pythainlp
29
30
  Dynamic: author
30
31
  Dynamic: author-email
31
32
  Dynamic: classifier
@@ -76,14 +77,22 @@ PyThaiTTS supports multiple TTS models. You can specify which model to use:
76
77
  from pythaitts import TTS
77
78
 
78
79
  # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
80
+ # Sample Rate is 22050 Hz
79
81
  tts = TTS(pretrained="vachana")
80
82
  file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
81
83
 
82
84
  # Use Lunarlist ONNX (default)
85
+ # Sample Rate is 22050 Hz
83
86
  tts = TTS(pretrained="lunarlist_onnx")
84
87
  file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
85
88
 
89
+ # Use FastThaiG2P (default voice: thai_som)
90
+ # FastThaiG2P Sample Rate is 24000 Hz
91
+ tts = TTS(pretrained="fastthaig2p")
92
+ file = tts.tts("สวัสดีครับ", speaker_idx="thai_som", filename="output.wav")
93
+
86
94
  # Use KhanomTan
95
+ # Sample Rate is 16000 Hz
87
96
  tts = TTS(pretrained="khanomtan")
88
97
  file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
89
98
  ```
@@ -0,0 +1,37 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ PyThaiTTS.egg-info/PKG-INFO
5
+ PyThaiTTS.egg-info/SOURCES.txt
6
+ PyThaiTTS.egg-info/dependency_links.txt
7
+ PyThaiTTS.egg-info/not-zip-safe
8
+ PyThaiTTS.egg-info/requires.txt
9
+ PyThaiTTS.egg-info/top_level.txt
10
+ pythaitts/__init__.py
11
+ pythaitts/preprocess.py
12
+ pythaitts/pretrained/__init__.py
13
+ pythaitts/pretrained/khanomtan_tts.py
14
+ pythaitts/pretrained/lunarlist_model.py
15
+ pythaitts/pretrained/lunarlist_onnx.py
16
+ pythaitts/pretrained/vachana_tts.py
17
+ pythaitts/pretrained/fastthaig2p/__init__.py
18
+ pythaitts/pretrained/fastthaig2p/_data.py
19
+ pythaitts/pretrained/fastthaig2p/_th2ipa.py
20
+ pythaitts/pretrained/fastthaig2p/fallback.py
21
+ pythaitts/pretrained/fastthaig2p/g2p.py
22
+ pythaitts/pretrained/fastthaig2p/kokoro.py
23
+ pythaitts/pretrained/fastthaig2p/normalizer.py
24
+ pythaitts/pretrained/fastthaig2p/tokenizer.py
25
+ pythaitts/pretrained/fastthaig2p/tts.py
26
+ pythaitts/pretrained/fastthaig2p/data/dict.txt
27
+ pythaitts/pretrained/fastthaig2p/data/ipa.json
28
+ pythaitts/pretrained/fastthaig2p/data/fallback/PhSTrigram.sts
29
+ pythaitts/pretrained/fastthaig2p/data/fallback/sylform_var.pkl
30
+ pythaitts/pretrained/fastthaig2p/data/fallback/sylrule.lts
31
+ pythaitts/pretrained/fastthaig2p/data/fallback/sylseg.3g
32
+ pythaitts/pretrained/fastthaig2p/data/fallback/thaisyl.dict
33
+ pythaitts/pretrained/fastthaig2p/data/fallback/thdict
34
+ tests/__init__.py
35
+ tests/test_fastthaig2p.py
36
+ tests/test_preprocess.py
37
+ tests/test_vachana.py
@@ -3,3 +3,4 @@ numpy>=1.22
3
3
  onnxruntime
4
4
  vachanatts
5
5
  soundfile
6
+ pythainlp
@@ -34,14 +34,22 @@ PyThaiTTS supports multiple TTS models. You can specify which model to use:
34
34
  from pythaitts import TTS
35
35
 
36
36
  # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
37
+ # Sample Rate is 22050 Hz
37
38
  tts = TTS(pretrained="vachana")
38
39
  file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
39
40
 
40
41
  # Use Lunarlist ONNX (default)
42
+ # Sample Rate is 22050 Hz
41
43
  tts = TTS(pretrained="lunarlist_onnx")
42
44
  file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
43
45
 
46
+ # Use FastThaiG2P (default voice: thai_som)
47
+ # FastThaiG2P Sample Rate is 24000 Hz
48
+ tts = TTS(pretrained="fastthaig2p")
49
+ file = tts.tts("สวัสดีครับ", speaker_idx="thai_som", filename="output.wav")
50
+
44
51
  # Use KhanomTan
52
+ # Sample Rate is 16000 Hz
45
53
  tts = TTS(pretrained="khanomtan")
46
54
  file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
47
55
  ```
@@ -2,16 +2,16 @@
2
2
  """
3
3
  PyThaiTTS
4
4
  """
5
- __version__ = "0.4.2"
5
+ __version__ = "0.5.0"
6
6
 
7
7
  from pythaitts.preprocess import preprocess_text, num_to_thai, expand_maiyamok
8
8
 
9
9
 
10
10
  class TTS:
11
- def __init__(self, pretrained="lunarlist_onnx", mode="last_checkpoint", version="1.0", device:str="cpu") -> None:
11
+ def __init__(self, pretrained="lunarlist_onnx", mode="last_checkpoint", version="1.0", device:str="cpu", **kwargs) -> None:
12
12
  """
13
- :param str pretrained: TTS pretrained (lunarlist_onnx, khanomtan, lunarlist, vachana)
14
- :param str mode: pretrained mode (lunarlist_onnx and vachana don't support)
13
+ :param str pretrained: TTS pretrained (lunarlist_onnx, khanomtan, lunarlist, vachana, fastthaig2p)
14
+ :param str mode: pretrained mode (lunarlist_onnx, vachana, and fastthaig2p don't support)
15
15
  :param str version: model version (default is 1.0 or 1.1)
16
16
  :param str device: device for running model. (lunarlist_onnx and vachana support CPU only.)
17
17
 
@@ -32,14 +32,15 @@ class TTS:
32
32
  For vachana tts model, \
33
33
  You can see more about vachana tts at `https://github.com/VYNCX/VachanaTTS2 <https://github.com/VYNCX/VachanaTTS2>`_
34
34
 
35
-
35
+ For fastthaig2p tts model, \
36
+ You can see more about fastthaig2p at `https://github.com/awslabs/FastThaiG2P <https://github.com/awslabs/FastThaiG2P>`_
36
37
  """
37
38
  self.pretrained = pretrained
38
39
  self.mode = mode
39
40
  self.device = device
40
- self.load_pretrained(version=version)
41
+ self.load_pretrained(version=version, **kwargs)
41
42
 
42
- def load_pretrained(self,version):
43
+ def load_pretrained(self, version="1.0", **kwargs):
43
44
  """
44
45
  Load pretrained
45
46
  """
@@ -55,21 +56,25 @@ class TTS:
55
56
  elif self.pretrained == "vachana":
56
57
  from pythaitts.pretrained.vachana_tts import VachanaTTS
57
58
  self.model = VachanaTTS()
59
+ elif self.pretrained in ("fastthaig2p", "FastThaiG2P"):
60
+ from pythaitts.pretrained.fastthaig2p import FastThaiG2P
61
+ self.model = FastThaiG2P(device=self.device, **kwargs)
58
62
  else:
59
63
  raise NotImplementedError(
60
64
  "PyThaiTTS doesn't support %s pretrained." % self.pretrained
61
65
  )
62
66
 
63
- def tts(self, text: str, speaker_idx: str = "Linda", language_idx: str = "th-th", return_type: str = "file", filename: str = None, preprocess: bool = True):
67
+ def tts(self, text: str, speaker_idx: str = "Linda", language_idx: str = "th-th", return_type: str = "file", filename: str = None, preprocess: bool = True, **kwargs):
64
68
  """
65
69
  speech synthesis
66
70
 
67
71
  :param str text: text
68
- :param str speaker_idx: speaker (default is Linda for khanomtan, th_f_1 for vachana)
72
+ :param str speaker_idx: speaker (default is Linda for khanomtan, th_f_1 for vachana, thai_som for fastthaig2p)
69
73
  :param str language_idx: language (default is th-th)
70
74
  :param str return_type: return type (default is file)
71
75
  :param str filename: path filename for save wav file if return_type is file.
72
76
  :param bool preprocess: whether to preprocess text (convert numbers to Thai text and expand ๆ). Default is True.
77
+ :param kwargs: Additional parameters passed to the underlying model.
73
78
  """
74
79
  # Preprocess text if requested
75
80
  if preprocess:
@@ -79,7 +84,11 @@ class TTS:
79
84
  if self.pretrained == "lunarlist" or self.pretrained == "lunarlist_onnx":
80
85
  return self.model(text=text,return_type=return_type,filename=filename)
81
86
  elif self.pretrained == "vachana":
82
- return self.model(text=text,speaker_idx=speaker_idx,return_type=return_type,filename=filename)
87
+ return self.model(text=text,speaker_idx=speaker_idx,return_type=return_type,filename=filename, **kwargs)
88
+ elif self.pretrained in ("fastthaig2p", "FastThaiG2P"):
89
+ if speaker_idx in ("Linda", None):
90
+ speaker_idx = "thai_som"
91
+ return self.model(text=text,speaker_idx=speaker_idx,return_type=return_type,filename=filename, **kwargs)
83
92
  return self.model(
84
93
  text=text,
85
94
  speaker_idx=speaker_idx,
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ ## License
4
+
5
+ Copyright 2026 Charin Polpanumas and Amazon Web Services
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ from .g2p import G2P
22
+ from .kokoro import ipa_to_kokoro
23
+ from .normalizer import normalize
24
+ from .tokenizer import Tokenizer
25
+
26
+ __all__ = ["G2P", "Tokenizer", "normalize", "ipa_to_kokoro", "TTS", "FastThaiG2P"]
27
+
28
+
29
+ def __getattr__(name):
30
+ if name in ("TTS", "FastThaiG2P"):
31
+ from .tts import TTS, FastThaiG2P
32
+
33
+ return FastThaiG2P if name == "FastThaiG2P" else TTS
34
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
35
+
@@ -0,0 +1,30 @@
1
+ """Locate runtime data in both layouts: installed wheel (fastthaig2p/data,
2
+ via the force-include in pyproject.toml) and repo checkout (../data).
3
+
4
+ ## License
5
+
6
+ Copyright 2026 Charin Polpanumas and Amazon Web Services
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+ """
20
+
21
+ from pathlib import Path
22
+
23
+ _PKG = Path(__file__).parent
24
+
25
+
26
+ def data_path(*parts: str) -> Path:
27
+ installed = _PKG / "data" / Path(*parts)
28
+ if installed.exists():
29
+ return installed
30
+ return _PKG.parent / "data" / Path(*parts)