PyThaiTTS 0.2.1__tar.gz → 0.4.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 (27) hide show
  1. pythaitts-0.4.0/PKG-INFO +125 -0
  2. pythaitts-0.4.0/PyThaiTTS.egg-info/PKG-INFO +125 -0
  3. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/PyThaiTTS.egg-info/SOURCES.txt +7 -1
  4. pythaitts-0.4.0/PyThaiTTS.egg-info/requires.txt +4 -0
  5. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/PyThaiTTS.egg-info/top_level.txt +1 -0
  6. pythaitts-0.4.0/README.md +84 -0
  7. pythaitts-0.4.0/pythaitts/__init__.py +88 -0
  8. pythaitts-0.4.0/pythaitts/preprocess.py +254 -0
  9. pythaitts-0.4.0/pythaitts/pretrained/__init__.py +0 -0
  10. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/pythaitts/pretrained/lunarlist_model.py +4 -1
  11. pythaitts-0.4.0/pythaitts/pretrained/lunarlist_onnx.py +189 -0
  12. pythaitts-0.4.0/pythaitts/pretrained/vachana_tts.py +111 -0
  13. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/setup.py +1 -1
  14. pythaitts-0.4.0/tests/__init__.py +4 -0
  15. pythaitts-0.4.0/tests/test_preprocess.py +125 -0
  16. pythaitts-0.4.0/tests/test_vachana.py +113 -0
  17. PyThaiTTS-0.2.1/PKG-INFO +0 -46
  18. PyThaiTTS-0.2.1/PyThaiTTS.egg-info/PKG-INFO +0 -46
  19. PyThaiTTS-0.2.1/PyThaiTTS.egg-info/requires.txt +0 -4
  20. PyThaiTTS-0.2.1/README.md +0 -22
  21. PyThaiTTS-0.2.1/pythaitts/__init__.py +0 -64
  22. PyThaiTTS-0.2.1/pythaitts/pretrained/__init__.py +0 -8
  23. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/LICENSE +0 -0
  24. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/PyThaiTTS.egg-info/dependency_links.txt +0 -0
  25. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/PyThaiTTS.egg-info/not-zip-safe +0 -0
  26. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/pythaitts/pretrained/khanomtan_tts.py +0 -0
  27. {PyThaiTTS-0.2.1 → pythaitts-0.4.0}/setup.cfg +0 -0
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyThaiTTS
3
+ Version: 0.4.0
4
+ Summary: Open Source Thai Text-to-speech library in Python
5
+ Home-page: https://github.com/pythainlp/pythaitts
6
+ Author: Wannaphong
7
+ Author-email: wannaphong@yahoo.com
8
+ License: Apache Software License 2.0
9
+ Project-URL: Documentation, https://github.com/pythainlp/pythaitts
10
+ Project-URL: Source, https://github.com/pythainlp/pythaitts
11
+ Project-URL: Bug Reports, https://github.com/pythainlp/pythaitts/issues
12
+ Keywords: Thai,NLP,natural language processing,text analytics,text processing,localization,computational linguistics,text-to-speech
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Text Processing
19
+ Classifier: Topic :: Text Processing :: General
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Requires-Python: >=3.6
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: huggingface_hub
25
+ Requires-Dist: numpy>=1.22
26
+ Requires-Dist: onnxruntime
27
+ Requires-Dist: vachanatts
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license
36
+ Dynamic: license-file
37
+ Dynamic: project-url
38
+ Dynamic: requires-dist
39
+ Dynamic: requires-python
40
+ Dynamic: summary
41
+
42
+ # PyThaiTTS
43
+ Open Source Thai Text-to-speech library in Python
44
+
45
+ [Google Colab](https://colab.research.google.com/github/PyThaiNLP/PyThaiTTS/blob/dev/notebook/use_lunarlist_model.ipynb) | [Docs](https://pythainlp.github.io/PyThaiTTS/) | [Notebooks](https://github.com/PyThaiNLP/PyThaiTTS/tree/dev/notebook)
46
+ <a href="https://pepy.tech/project/pythaitts"><img alt="Download" src="https://pepy.tech/badge/pythaitts/month"/></a>
47
+
48
+ License: [Apache-2.0 License](https://github.com/PyThaiNLP/pythaitts/blob/main/LICENSE)
49
+
50
+ ## Install
51
+
52
+ Install by pip:
53
+
54
+ > pip install pythaitts
55
+
56
+ ## Usage
57
+
58
+ ### Basic Usage
59
+
60
+ ```python
61
+ from pythaitts import TTS
62
+
63
+ tts = TTS()
64
+ file = tts.tts("ภาษาไทย ง่าย มาก มาก", filename="cat.wav") # It will get wav file path.
65
+ wave = tts.tts("ภาษาไทย ง่าย มาก มาก",return_type="waveform") # It will get waveform.
66
+ ```
67
+
68
+ ### Using Different TTS Models
69
+
70
+ PyThaiTTS supports multiple TTS models. You can specify which model to use:
71
+
72
+ ```python
73
+ from pythaitts import TTS
74
+
75
+ # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
76
+ tts = TTS(pretrained="vachana")
77
+ file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
78
+
79
+ # Use Lunarlist ONNX (default)
80
+ tts = TTS(pretrained="lunarlist_onnx")
81
+ file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
82
+
83
+ # Use KhanomTan
84
+ tts = TTS(pretrained="khanomtan")
85
+ file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
86
+ ```
87
+
88
+ ### Text Preprocessing
89
+
90
+ PyThaiTTS includes automatic text preprocessing to improve TTS quality:
91
+ - **Number to Thai text conversion**: Converts digits (e.g., "123") to Thai text (e.g., "หนึ่งร้อยยี่สิบสาม")
92
+ - **Mai yamok (ๆ) expansion**: Expands the Thai repetition character (e.g., "ดีๆ" becomes "ดีดี")
93
+
94
+ Preprocessing is enabled by default:
95
+
96
+ ```python
97
+ from pythaitts import TTS
98
+
99
+ tts = TTS()
100
+ # Automatic preprocessing: "มี 5 คนๆ" becomes "มี ห้า คนคน"
101
+ file = tts.tts("มี 5 คนๆ", filename="output.wav")
102
+ ```
103
+
104
+ You can disable preprocessing if needed:
105
+
106
+ ```python
107
+ file = tts.tts("มี 5 คนๆ", preprocess=False, filename="output.wav")
108
+ ```
109
+
110
+ You can also use preprocessing functions directly:
111
+
112
+ ```python
113
+ from pythaitts import num_to_thai, expand_maiyamok, preprocess_text
114
+
115
+ # Convert numbers to Thai text
116
+ print(num_to_thai("123")) # Output: หนึ่งร้อยยี่สิบสาม
117
+
118
+ # Expand mai yamok
119
+ print(expand_maiyamok("ดีๆ")) # Output: ดีดี
120
+
121
+ # Full preprocessing
122
+ print(preprocess_text("มี 5 คนๆ")) # Output: มี ห้า คนคน
123
+ ```
124
+
125
+ You can see more at [https://pythainlp.github.io/PyThaiTTS/](https://pythainlp.github.io/PyThaiTTS/).
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyThaiTTS
3
+ Version: 0.4.0
4
+ Summary: Open Source Thai Text-to-speech library in Python
5
+ Home-page: https://github.com/pythainlp/pythaitts
6
+ Author: Wannaphong
7
+ Author-email: wannaphong@yahoo.com
8
+ License: Apache Software License 2.0
9
+ Project-URL: Documentation, https://github.com/pythainlp/pythaitts
10
+ Project-URL: Source, https://github.com/pythainlp/pythaitts
11
+ Project-URL: Bug Reports, https://github.com/pythainlp/pythaitts/issues
12
+ Keywords: Thai,NLP,natural language processing,text analytics,text processing,localization,computational linguistics,text-to-speech
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Text Processing
19
+ Classifier: Topic :: Text Processing :: General
20
+ Classifier: Topic :: Text Processing :: Linguistic
21
+ Requires-Python: >=3.6
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: huggingface_hub
25
+ Requires-Dist: numpy>=1.22
26
+ Requires-Dist: onnxruntime
27
+ Requires-Dist: vachanatts
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: keywords
35
+ Dynamic: license
36
+ Dynamic: license-file
37
+ Dynamic: project-url
38
+ Dynamic: requires-dist
39
+ Dynamic: requires-python
40
+ Dynamic: summary
41
+
42
+ # PyThaiTTS
43
+ Open Source Thai Text-to-speech library in Python
44
+
45
+ [Google Colab](https://colab.research.google.com/github/PyThaiNLP/PyThaiTTS/blob/dev/notebook/use_lunarlist_model.ipynb) | [Docs](https://pythainlp.github.io/PyThaiTTS/) | [Notebooks](https://github.com/PyThaiNLP/PyThaiTTS/tree/dev/notebook)
46
+ <a href="https://pepy.tech/project/pythaitts"><img alt="Download" src="https://pepy.tech/badge/pythaitts/month"/></a>
47
+
48
+ License: [Apache-2.0 License](https://github.com/PyThaiNLP/pythaitts/blob/main/LICENSE)
49
+
50
+ ## Install
51
+
52
+ Install by pip:
53
+
54
+ > pip install pythaitts
55
+
56
+ ## Usage
57
+
58
+ ### Basic Usage
59
+
60
+ ```python
61
+ from pythaitts import TTS
62
+
63
+ tts = TTS()
64
+ file = tts.tts("ภาษาไทย ง่าย มาก มาก", filename="cat.wav") # It will get wav file path.
65
+ wave = tts.tts("ภาษาไทย ง่าย มาก มาก",return_type="waveform") # It will get waveform.
66
+ ```
67
+
68
+ ### Using Different TTS Models
69
+
70
+ PyThaiTTS supports multiple TTS models. You can specify which model to use:
71
+
72
+ ```python
73
+ from pythaitts import TTS
74
+
75
+ # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
76
+ tts = TTS(pretrained="vachana")
77
+ file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
78
+
79
+ # Use Lunarlist ONNX (default)
80
+ tts = TTS(pretrained="lunarlist_onnx")
81
+ file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
82
+
83
+ # Use KhanomTan
84
+ tts = TTS(pretrained="khanomtan")
85
+ file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
86
+ ```
87
+
88
+ ### Text Preprocessing
89
+
90
+ PyThaiTTS includes automatic text preprocessing to improve TTS quality:
91
+ - **Number to Thai text conversion**: Converts digits (e.g., "123") to Thai text (e.g., "หนึ่งร้อยยี่สิบสาม")
92
+ - **Mai yamok (ๆ) expansion**: Expands the Thai repetition character (e.g., "ดีๆ" becomes "ดีดี")
93
+
94
+ Preprocessing is enabled by default:
95
+
96
+ ```python
97
+ from pythaitts import TTS
98
+
99
+ tts = TTS()
100
+ # Automatic preprocessing: "มี 5 คนๆ" becomes "มี ห้า คนคน"
101
+ file = tts.tts("มี 5 คนๆ", filename="output.wav")
102
+ ```
103
+
104
+ You can disable preprocessing if needed:
105
+
106
+ ```python
107
+ file = tts.tts("มี 5 คนๆ", preprocess=False, filename="output.wav")
108
+ ```
109
+
110
+ You can also use preprocessing functions directly:
111
+
112
+ ```python
113
+ from pythaitts import num_to_thai, expand_maiyamok, preprocess_text
114
+
115
+ # Convert numbers to Thai text
116
+ print(num_to_thai("123")) # Output: หนึ่งร้อยยี่สิบสาม
117
+
118
+ # Expand mai yamok
119
+ print(expand_maiyamok("ดีๆ")) # Output: ดีดี
120
+
121
+ # Full preprocessing
122
+ print(preprocess_text("มี 5 คนๆ")) # Output: มี ห้า คนคน
123
+ ```
124
+
125
+ You can see more at [https://pythainlp.github.io/PyThaiTTS/](https://pythainlp.github.io/PyThaiTTS/).
@@ -8,6 +8,12 @@ PyThaiTTS.egg-info/not-zip-safe
8
8
  PyThaiTTS.egg-info/requires.txt
9
9
  PyThaiTTS.egg-info/top_level.txt
10
10
  pythaitts/__init__.py
11
+ pythaitts/preprocess.py
11
12
  pythaitts/pretrained/__init__.py
12
13
  pythaitts/pretrained/khanomtan_tts.py
13
- pythaitts/pretrained/lunarlist_model.py
14
+ pythaitts/pretrained/lunarlist_model.py
15
+ pythaitts/pretrained/lunarlist_onnx.py
16
+ pythaitts/pretrained/vachana_tts.py
17
+ tests/__init__.py
18
+ tests/test_preprocess.py
19
+ tests/test_vachana.py
@@ -0,0 +1,4 @@
1
+ huggingface_hub
2
+ numpy>=1.22
3
+ onnxruntime
4
+ vachanatts
@@ -0,0 +1,84 @@
1
+ # PyThaiTTS
2
+ Open Source Thai Text-to-speech library in Python
3
+
4
+ [Google Colab](https://colab.research.google.com/github/PyThaiNLP/PyThaiTTS/blob/dev/notebook/use_lunarlist_model.ipynb) | [Docs](https://pythainlp.github.io/PyThaiTTS/) | [Notebooks](https://github.com/PyThaiNLP/PyThaiTTS/tree/dev/notebook)
5
+ <a href="https://pepy.tech/project/pythaitts"><img alt="Download" src="https://pepy.tech/badge/pythaitts/month"/></a>
6
+
7
+ License: [Apache-2.0 License](https://github.com/PyThaiNLP/pythaitts/blob/main/LICENSE)
8
+
9
+ ## Install
10
+
11
+ Install by pip:
12
+
13
+ > pip install pythaitts
14
+
15
+ ## Usage
16
+
17
+ ### Basic Usage
18
+
19
+ ```python
20
+ from pythaitts import TTS
21
+
22
+ tts = TTS()
23
+ file = tts.tts("ภาษาไทย ง่าย มาก มาก", filename="cat.wav") # It will get wav file path.
24
+ wave = tts.tts("ภาษาไทย ง่าย มาก มาก",return_type="waveform") # It will get waveform.
25
+ ```
26
+
27
+ ### Using Different TTS Models
28
+
29
+ PyThaiTTS supports multiple TTS models. You can specify which model to use:
30
+
31
+ ```python
32
+ from pythaitts import TTS
33
+
34
+ # Use VachanaTTS (default voices: th_f_1, th_m_1, th_f_2, th_m_2)
35
+ tts = TTS(pretrained="vachana")
36
+ file = tts.tts("สวัสดีครับ", speaker_idx="th_f_1", filename="output.wav")
37
+
38
+ # Use Lunarlist ONNX (default)
39
+ tts = TTS(pretrained="lunarlist_onnx")
40
+ file = tts.tts("ภาษาไทย ง่าย มาก", filename="output.wav")
41
+
42
+ # Use KhanomTan
43
+ tts = TTS(pretrained="khanomtan")
44
+ file = tts.tts("ภาษาไทย", speaker_idx="Linda", filename="output.wav")
45
+ ```
46
+
47
+ ### Text Preprocessing
48
+
49
+ PyThaiTTS includes automatic text preprocessing to improve TTS quality:
50
+ - **Number to Thai text conversion**: Converts digits (e.g., "123") to Thai text (e.g., "หนึ่งร้อยยี่สิบสาม")
51
+ - **Mai yamok (ๆ) expansion**: Expands the Thai repetition character (e.g., "ดีๆ" becomes "ดีดี")
52
+
53
+ Preprocessing is enabled by default:
54
+
55
+ ```python
56
+ from pythaitts import TTS
57
+
58
+ tts = TTS()
59
+ # Automatic preprocessing: "มี 5 คนๆ" becomes "มี ห้า คนคน"
60
+ file = tts.tts("มี 5 คนๆ", filename="output.wav")
61
+ ```
62
+
63
+ You can disable preprocessing if needed:
64
+
65
+ ```python
66
+ file = tts.tts("มี 5 คนๆ", preprocess=False, filename="output.wav")
67
+ ```
68
+
69
+ You can also use preprocessing functions directly:
70
+
71
+ ```python
72
+ from pythaitts import num_to_thai, expand_maiyamok, preprocess_text
73
+
74
+ # Convert numbers to Thai text
75
+ print(num_to_thai("123")) # Output: หนึ่งร้อยยี่สิบสาม
76
+
77
+ # Expand mai yamok
78
+ print(expand_maiyamok("ดีๆ")) # Output: ดีดี
79
+
80
+ # Full preprocessing
81
+ print(preprocess_text("มี 5 คนๆ")) # Output: มี ห้า คนคน
82
+ ```
83
+
84
+ You can see more at [https://pythainlp.github.io/PyThaiTTS/](https://pythainlp.github.io/PyThaiTTS/).
@@ -0,0 +1,88 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ PyThaiTTS
4
+ """
5
+ __version__ = "0.3.0"
6
+
7
+ from pythaitts.preprocess import preprocess_text, num_to_thai, expand_maiyamok
8
+
9
+
10
+ class TTS:
11
+ def __init__(self, pretrained="lunarlist_onnx", mode="last_checkpoint", version="1.0", device:str="cpu") -> None:
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)
15
+ :param str version: model version (default is 1.0 or 1.1)
16
+ :param str device: device for running model. (lunarlist_onnx and vachana support CPU only.)
17
+
18
+ **Options for mode**
19
+ * *last_checkpoint* (default) - last checkpoint of model
20
+ * *best_model* - Best model (best loss)
21
+
22
+ You can see more about khanomtan tts at `https://github.com/wannaphong/KhanomTan-TTS-v1.0 <https://github.com/wannaphong/KhanomTan-TTS-v1.0>`_
23
+ and `https://github.com/wannaphong/KhanomTan-TTS-v1.1 <https://github.com/wannaphong/KhanomTan-TTS-v1.1>`_
24
+
25
+ For lunarlist tts model, you must to install nemo before use the model by pip install nemo_toolkit['tts'].
26
+ You can see more about lunarlist tts at `https://link.medium.com/OpPjQis6wBb <https://link.medium.com/OpPjQis6wBb>`_
27
+
28
+ For lunarlist_onnx tts model, \
29
+ You can see more about lunarlist tts at `https://github.com/PyThaiNLP/thaitts-onnx <https://github.com/PyThaiNLP/thaitts-onnx>`_
30
+
31
+ For vachana tts model, \
32
+ You can see more about vachana tts at `https://github.com/VYNCX/VachanaTTS2 <https://github.com/VYNCX/VachanaTTS2>`_
33
+
34
+
35
+ """
36
+ self.pretrained = pretrained
37
+ self.mode = mode
38
+ self.device = device
39
+ self.load_pretrained(version=version)
40
+
41
+ def load_pretrained(self,version):
42
+ """
43
+ Load pretrained
44
+ """
45
+ if self.pretrained == "lunarlist_onnx":
46
+ from pythaitts.pretrained.lunarlist_onnx import LunarlistONNX
47
+ self.model = LunarlistONNX()
48
+ elif self.pretrained == "khanomtan":
49
+ from pythaitts.pretrained.khanomtan_tts import KhanomTan
50
+ self.model = KhanomTan(mode=self.mode, version=version)
51
+ elif self.pretrained == "lunarlist":
52
+ from pythaitts.pretrained.lunarlist_model import LunarlistModel
53
+ self.model = LunarlistModel(mode=self.mode, device=self.device)
54
+ elif self.pretrained == "vachana":
55
+ from pythaitts.pretrained.vachana_tts import VachanaTTS
56
+ self.model = VachanaTTS()
57
+ else:
58
+ raise NotImplementedError(
59
+ "PyThaiTTS doesn't support %s pretrained." % self.pretrained
60
+ )
61
+
62
+ def tts(self, text: str, speaker_idx: str = "Linda", language_idx: str = "th-th", return_type: str = "file", filename: str = None, preprocess: bool = True):
63
+ """
64
+ speech synthesis
65
+
66
+ :param str text: text
67
+ :param str speaker_idx: speaker (default is Linda for khanomtan, th_f_1 for vachana)
68
+ :param str language_idx: language (default is th-th)
69
+ :param str return_type: return type (default is file)
70
+ :param str filename: path filename for save wav file if return_type is file.
71
+ :param bool preprocess: whether to preprocess text (convert numbers to Thai text and expand ๆ). Default is True.
72
+ """
73
+ # Preprocess text if requested
74
+ if preprocess:
75
+ from pythaitts.preprocess import preprocess_text
76
+ text = preprocess_text(text)
77
+
78
+ if self.pretrained == "lunarlist" or self.pretrained == "lunarlist_onnx":
79
+ return self.model(text=text,return_type=return_type,filename=filename)
80
+ elif self.pretrained == "vachana":
81
+ return self.model(text=text,speaker_idx=speaker_idx,return_type=return_type,filename=filename)
82
+ return self.model(
83
+ text=text,
84
+ speaker_idx=speaker_idx,
85
+ language_idx=language_idx,
86
+ return_type=return_type,
87
+ filename=filename
88
+ )