voicesynth 0.1.5.post3__py3-none-any.whl

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.
voicesynth/__init__.py ADDED
@@ -0,0 +1,9 @@
1
+ from voicesynth.voicesynth import (
2
+ Synthesizer, Model, show_available_models, disable_logging
3
+ )
4
+
5
+
6
+ __all__ = ["Synthesizer", "Model", "show_available_models", "disable_logging"]
7
+
8
+
9
+
@@ -0,0 +1,79 @@
1
+ class VoiceSynthError(Exception):
2
+ """
3
+ Base class for Synthesizer exceptions.
4
+ """
5
+
6
+ pass
7
+
8
+
9
+ class IncorrectModel(VoiceSynthError):
10
+ """
11
+ Incorrect model parameters
12
+ """
13
+
14
+ pass
15
+
16
+
17
+ class IncorrectModelPath(IncorrectModel):
18
+ """
19
+ Incorrect model path
20
+ """
21
+
22
+ pass
23
+
24
+
25
+ class IncorrectSpeaker(IncorrectModel):
26
+ """
27
+ Incorrect speaker parameters
28
+ """
29
+
30
+ pass
31
+
32
+
33
+ class AudioError(VoiceSynthError):
34
+ """
35
+ Audio error
36
+ """
37
+ pass
38
+
39
+
40
+ class AudioPlayingError(AudioError):
41
+ """
42
+ Audio playing error
43
+ """
44
+ pass
45
+
46
+
47
+ class InvalidAudioFormat(AudioError):
48
+ """
49
+ Invalid audio formatting
50
+ """
51
+ pass
52
+
53
+
54
+ class InvalidAudioPath(AudioError):
55
+ """
56
+ Invalid path for audio playing
57
+ """
58
+ pass
59
+
60
+
61
+ class SynthesisError(AudioError):
62
+ """
63
+ Error synthesizing Audio
64
+ """
65
+ pass
66
+
67
+
68
+ class PackageError(VoiceSynthError):
69
+ """
70
+ Error in manual package installation
71
+ """
72
+ pass
73
+
74
+
75
+ class PackageInstallatioError(PackageError):
76
+ """
77
+ Class for package installation errors
78
+ """
79
+ pass
voicesynth/models.py ADDED
@@ -0,0 +1,65 @@
1
+ """
2
+ Model utilities for voicesynth
3
+ """
4
+
5
+ # all available models
6
+ models = {
7
+ "v4_ru": {"url": "https://models.silero.ai/models/tts/ru/v4_ru.pt",
8
+ "speakers": ['aidar', 'baya', 'kseniya', 'xenia', 'eugene'],
9
+ "language": "russian"},
10
+ "v4_ua": {"url": "https://models.silero.ai/models/tts/ua/v4_ua.pt",
11
+ "speakers": ["mykyta"],
12
+ "language": "ukranian"},
13
+ "v3_en": {"url": "https://models.silero.ai/models/tts/en/v3_en.pt",
14
+ "speakers": [f'en_{i}' for i in range(118)],
15
+ "language": "english"},
16
+ "v3_de": {"url": "https://models.silero.ai/models/tts/de/v3_de.pt",
17
+ "speakers": ["eva_k", "karlsson"],
18
+ "language": "german"},
19
+ "v3_es": {"url": "https://models.silero.ai/models/tts/es/v3_es.pt",
20
+ "speakers": ['es_0', 'es_1', 'es_2'],
21
+ "language": "spanish"},
22
+ "v3_fr": {"url": "https://models.silero.ai/models/tts/fr/v3_fr.pt",
23
+ "speakers": [f'fr_{i}' for i in range(6)],
24
+ "language": "french"}
25
+ }
26
+
27
+
28
+ def show_available_models() -> None:
29
+ # Define color codes
30
+ HEADER_COLOR = "\033[95m"
31
+ MODEL_COLOR = "\033[94m"
32
+ URL_COLOR = "\033[96m"
33
+ LANGUAGE_COLOR = "\033[93m" # Adding a new color for language
34
+ SPEAKERS_COLOR = "\033[92m"
35
+ END_COLOR = "\033[0m"
36
+
37
+ # Print colored header
38
+ print(f"{HEADER_COLOR} {'Model':<10}| {'Url':<50}| {'Language':<10}| {'Speakers'}{END_COLOR}")
39
+ print("-" * 160)
40
+
41
+ # Print each model's information
42
+ for model_name, model_info in models.items():
43
+ model_url = model_info["url"]
44
+ speakers = model_info["speakers"]
45
+ language = model_info["language"]
46
+
47
+ # Break speakers into rows with a maximum of 10 speakers per row
48
+ rows = [speakers[i:i + 10] for i in range(0, len(speakers), 10)]
49
+
50
+ # Print the first row with model, url, language, and speakers
51
+ print(
52
+ f"{MODEL_COLOR} {model_name:<10}{END_COLOR}| {URL_COLOR}{model_url:<50}{END_COLOR}| {LANGUAGE_COLOR}{language:<10}{END_COLOR}| {SPEAKERS_COLOR}{', '.join(rows[0])}{END_COLOR}")
53
+
54
+ # Print the remaining rows (if any) with model, url, language, and speakers blank
55
+ for row in rows[1:]:
56
+ # Apply color codes to the entire line
57
+ print(
58
+ f"{MODEL_COLOR} {'':<10}{END_COLOR}| {URL_COLOR}{'':<50}{END_COLOR}| {LANGUAGE_COLOR}{'':<10}{END_COLOR}| {SPEAKERS_COLOR}{', '.join(row)}{END_COLOR}")
59
+
60
+ # Print separation line between models
61
+ print("-" * 160)
62
+
63
+
64
+
65
+
@@ -0,0 +1,282 @@
1
+ """
2
+ Voice Synthesizing package
3
+ Author: ilyamiro
4
+
5
+ Available on pip:
6
+ pip install voicesynth
7
+
8
+ This package was created for realistic voice-synthesis
9
+
10
+ Copyright [2024] [Ilya Miro]
11
+
12
+ Licensed under the Apache License, Version 2.0 (the "License");
13
+ you may not use this file except in compliance with the License.
14
+ You may obtain a copy of the License at
15
+
16
+ http://www.apache.org/licenses/LICENSE-2.0
17
+
18
+ Unless required by applicable law or agreed to in writing, software
19
+ distributed under the License is distributed on an "AS IS" BASIS,
20
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ See the License for the specific language governing permissions and
22
+ limitations under the License.
23
+ """
24
+ import logging
25
+
26
+
27
+ def _disable_loggers():
28
+ """
29
+ Disables all logs produced by imported modules
30
+
31
+ DEPRECATED
32
+ """
33
+ loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]
34
+ for logg in loggers:
35
+ logg.setLevel(logging.ERROR)
36
+
37
+
38
+ import os
39
+ import subprocess
40
+ import sys
41
+
42
+ from importlib.util import find_spec
43
+
44
+ from typing import Literal, List, Union
45
+
46
+ import playsound
47
+ import torch
48
+
49
+ from voicesynth.exceptions import *
50
+
51
+ from voicesynth.models import (
52
+ models, show_available_models
53
+ )
54
+
55
+
56
+ class CustomLogger(logging.Logger):
57
+ def __init__(self):
58
+ super().__init__("Voicesynth", level=logging.NOTSET)
59
+ self._setup()
60
+
61
+ def _setup(self):
62
+ handler = logging.StreamHandler()
63
+ handler.setFormatter(logging.Formatter(fmt="Voicesynth - %(asctime)s - %(message)s", datefmt="%Y-%b-%d %H:%M:%S"))
64
+ self.addHandler(handler)
65
+
66
+
67
+ logger = CustomLogger()
68
+
69
+
70
+ def disable_logging():
71
+ """
72
+ Disables voicesynth logging
73
+ """
74
+ logger.disabled = True
75
+
76
+
77
+ def installed(name: str) -> bool:
78
+ """
79
+ A function for checking if the specified package is installed in venv
80
+ :param name: name of the package
81
+ :return: True if package is installed False otherwise
82
+ """
83
+ return False if not find_spec(name) else True
84
+
85
+
86
+ class Model:
87
+ """
88
+ TTS Model class for Synthesizer
89
+ """
90
+
91
+ def __init__(self, model: str, model_path: str, show_download: bool = True):
92
+ self.model = model # name of the model
93
+ self.model_path = model_path # path to the model for downloading
94
+ try:
95
+ self.url = models[model]["url"]
96
+ self.speakers = models[model]["speakers"]
97
+ self.set_speaker(self.speakers[0])
98
+ except KeyError:
99
+ error_msg = "Model invalid. Ensure it's one of "
100
+ for key in models.keys():
101
+ error_msg += f"{key}, "
102
+ raise IncorrectModel(error_msg)
103
+
104
+ logger.info("Model configured")
105
+
106
+ # Ensuring that model is a PyTorch one
107
+ if not self.model_path.endswith(".pt"):
108
+ raise IncorrectModelPath("Model file path should end with .pt!")
109
+
110
+ self.download_model(self.url, self.model_path, show_download)
111
+
112
+ def set_speaker(self, name):
113
+ if name in models[self.model]["speakers"]:
114
+ # noinspection PyAttributeOutsideInit
115
+ self.speaker = name
116
+ logger.info(f"Speaker {name} set")
117
+ else:
118
+ error_msg = "Speaker invalid! Ensure it's one of "
119
+ for speaker in models[self.model]["speakers"]:
120
+ error_msg += f"{speaker}, "
121
+ raise IncorrectSpeaker(error_msg)
122
+
123
+ def download_model(self, url: str, model_path: str, show_progress: bool = True) -> None:
124
+ """
125
+ Function for downloading voice model
126
+ :param url: url for model downloading
127
+ :param show_progress: if to show model's downloading process
128
+ :param model_path: path for model saving
129
+ """
130
+ self.model_path = model_path
131
+ # downloading model from source
132
+ if not os.path.exists(f"{self.model_path}"):
133
+ logger.info("Downloading synthesis model")
134
+ torch.hub.download_url_to_file(url, f"{self.model_path}",
135
+ progress=show_progress)
136
+ else:
137
+ logger.info("Setting up existing model")
138
+
139
+
140
+ class Synthesizer:
141
+ """
142
+ Class for synthesizing text
143
+ Based on silero-tts models from https://github.com/snakers4/silero-models
144
+ """
145
+
146
+ def __init__(self, model: Model) -> None:
147
+ """
148
+ Synthesizer initializing
149
+ """
150
+
151
+ # Parameters for synthesis
152
+ self.model = model
153
+ self.audio = AudioManager()
154
+
155
+ logger.info("Synthesizer configured")
156
+
157
+ # setting torch configuration
158
+ device = torch.device("cpu")
159
+ torch.set_num_threads(16)
160
+
161
+ logger.info("PyTorch device configured: Cpu, 16 threads")
162
+ # initialize sample rate
163
+ self.sample_rate = 48000
164
+
165
+ # creating model
166
+ self.model_download = torch.package.PackageImporter(
167
+ f"{self.model.model_path}").load_pickle("tts_models", "model")
168
+ self.model_download.to(device)
169
+
170
+ logger.info("Model imported to torch tts")
171
+
172
+ def say(self, text: str, path: str = "audio.wav", prosody_rate: int = 100,
173
+ module: Literal["playsound", "pygame", "pydub"] = "playsound") -> None:
174
+ """
175
+ Function for saying something
176
+ :param prosody_rate: relative speed for saying
177
+ :param path: path for audio to be saved in. Should be a .wav file
178
+ :param text: text for saying
179
+ :param module: module to use for audio playing
180
+ """
181
+ if not path.endswith(".wav"):
182
+ raise InvalidAudioFormat("Incorrect audio format! Ensure that path leads to a .wav file")
183
+
184
+ self.synthesize(text, path, prosody_rate)
185
+
186
+ getattr(self.audio, f"play_{module}")(path)
187
+
188
+ def synthesize(self, text: str, path: str = "audio.wav", prosody_rate: int = 100) -> None:
189
+ try:
190
+ self.model_download.save_wav(ssml_text=f"<speak><prosody rate='{prosody_rate}%'>{text}</prosody></speak>",
191
+ speaker=self.model.speaker,
192
+ sample_rate=self.sample_rate,
193
+ audio_path=path)
194
+
195
+ logger.info("Audio synthesized")
196
+ except Exception:
197
+ raise SynthesisError(
198
+ f"There was en error synthesizing this text: {text}. Ensure all parameters are inputted correctly")
199
+
200
+
201
+ def _player(path: str):
202
+ """
203
+ Player decorator for checking specified path before playing.
204
+ """
205
+ def decorator(func):
206
+ def wrapper():
207
+ # checking if the path exists
208
+ if os.path.exists(path):
209
+ func()
210
+ logger.info(f"File {path} played")
211
+ else:
212
+ raise InvalidAudioPath("Specified path for playing does not exist")
213
+ return wrapper
214
+ return decorator
215
+
216
+
217
+ class AudioManager:
218
+ @staticmethod
219
+ def play_playsound(path: str):
220
+ # checking if the platform is Linux-based
221
+ if sys.platform == "linux":
222
+ try:
223
+ # checking if the pygobject exists
224
+ from gi.repository import GObject
225
+ except ImportError:
226
+ logger.debug("Install pygobject for playsound using pip install pygobject. Playsound is relying on another subprocess")
227
+
228
+ @_player(path)
229
+ def play():
230
+ # playing sound using playsound library
231
+ playsound.playsound(path)
232
+
233
+ play()
234
+
235
+ @staticmethod
236
+ def play_pygame(path: str):
237
+
238
+ # disabling pygame support prompt
239
+ from os import environ
240
+ environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
241
+
242
+ if not installed("pygame"):
243
+ raise ModuleNotFoundError("Pygame is not installed. Install it using 'pip install pydub' and try again")
244
+ else:
245
+ import pygame
246
+
247
+ # initializing pygame if it was not yet.
248
+ if not pygame.get_init():
249
+ pygame.init()
250
+ pygame.mixer.init()
251
+
252
+ logger.info("Pygame initialized")
253
+
254
+ @_player(path)
255
+ def play():
256
+ pygame.mixer.music.load(path)
257
+ pygame.mixer.music.play()
258
+
259
+ while pygame.mixer.music.get_busy():
260
+ pygame.time.Clock().tick(10)
261
+
262
+ play()
263
+
264
+ @staticmethod
265
+ def play_pydub(path: str):
266
+ if not installed("pydub"):
267
+ raise ModuleNotFoundError("PyDub is not installed. Install it using 'pip install pydub' and try again")
268
+
269
+ from pydub.playback import play as replay
270
+
271
+ if sys.platform == "linux":
272
+ subprocess.run(
273
+ ["jack_control", "start"],
274
+ stdout=subprocess.DEVNULL, # DEVNULL surpasses console output
275
+ stderr=subprocess.STDOUT)
276
+ logger.info("jack_control service started")
277
+
278
+ @_player(path)
279
+ def play():
280
+ replay(pydub.AudioSegment.from_wav(path))
281
+
282
+ play()
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2024] [Ilya Miro]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.1
2
+ Name: voicesynth
3
+ Version: 0.1.5.post3
4
+ Summary: Package for realistic voice synthesis
5
+ Author: ilyamiro
6
+ Author-email: ilyamiro.workemail@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: torch
14
+ Requires-Dist: numpy
15
+ Requires-Dist: playsound
16
+
17
+ <h2>VoiceSynth</h2>
18
+ <strong>Voice Synthesizing Library</strong> <br>
19
+
20
+ <h3> How to use: </h3>
21
+ First, install the package
22
+
23
+ ```bash
24
+ pip install voicesynth
25
+ ```
26
+ Then import it into your code and go ahead and use it:
27
+ ```python
28
+ from voicesynth import Model, Synthesizer, show_available_models
29
+
30
+ show_available_models() # Showcase of all tts models available
31
+
32
+ # initializing the model
33
+ # setting show_download to False does not show model downloading progress
34
+ model = Model("v4_ru", model_path="model.pt", show_download=False)
35
+ model.set_speaker("eugene")
36
+
37
+ # creating a synthesizer instance
38
+ synthesizer = Synthesizer(model)
39
+ synthesizer.say("Я представить себе не могу, что это действительно случилось!")
40
+ ```
41
+ Instead of using .say() method, you can synthesize an audio and then play it whenever you want
42
+
43
+ ```python
44
+ import time
45
+
46
+ synthesizer.synthesize("Всем привет!", path="audio.wav")
47
+ time.sleep(3)
48
+ synthesizer.play_playsound("audio.wav")
49
+ ```
50
+ There are multiple ways to play a synthesized audio:
51
+ ```python
52
+ synthesizer.say("Как дела?", module="pygame") # Using pygame.mixer to play the audio
53
+ synthesizer.say("Хорошо, а твои как?", module="pydub") # Using pydub to play the audio
54
+ ```
55
+ There are three ways to play the audio:
56
+ ```python
57
+ synthesizer.audio.play_playsound("audio.wav")
58
+ synthesizer.audio.play_pygame("audio.wav")
59
+ synthesizer.audio.play_pydub("audio.wav")
60
+ ```
61
+ All models support simple ssml tags:
62
+ ```python
63
+ synthesizer.say("В н+едрах т+ундры в+ыдры п+ели п+есни", prosody_rate=90)
64
+ # I added prosody as a parameter, so that people who are not familiar with ssml tags
65
+ # could change speaking speed without knowing how to manually do it
66
+ ```
67
+
68
+ By default, logging is enabled. If it bothers you, you can disable it
69
+ ```python
70
+ from voicesynth import disable_logging
71
+
72
+ disable_logging()
73
+ ```
@@ -0,0 +1,9 @@
1
+ voicesynth/__init__.py,sha256=kC-V8-OSwIegwqLxnn5NKIDeQ_3MoooTNQqNzy-T1BI,185
2
+ voicesynth/exceptions.py,sha256=zdTbu5S5m_wYvd1yBPPtptKZT8p4DFmEioowJSvHgMc,1064
3
+ voicesynth/models.py,sha256=cnhdoWV06UdbOy8XdEM23EE2-Z49c-nYg_xrOfmkgEE,2572
4
+ voicesynth/voicesynth.py,sha256=JlUSIPcFVoU9LvqioakYG3LEFxHbNx8OCUSZbIyUaeM,8801
5
+ voicesynth-0.1.5.post3.dist-info/LICENSE,sha256=wsCXqd_fEgkgNWu190Pwf22B3UK5xmlKgNoZjyoL9cc,11343
6
+ voicesynth-0.1.5.post3.dist-info/METADATA,sha256=ltVV0Z6-jUZAcVBUb2kCDnQ1VwBaPj5Sw2YBeeu3FCM,2389
7
+ voicesynth-0.1.5.post3.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
8
+ voicesynth-0.1.5.post3.dist-info/top_level.txt,sha256=1aQc3BjFZJonCeKGmZtmdKBiYHd1LG9W2FDloC9c70c,11
9
+ voicesynth-0.1.5.post3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (74.1.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ voicesynth