yta-audio-narration 0.0.3__py3-none-any.whl → 0.0.4__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.
@@ -1,209 +1,6 @@
1
- from yta_audio_narration_common.enums import NarrationLanguage, VoiceEmotion, VoiceSpeed, VoicePitch
2
- from yta_audio_narration_common.consts import DEFAULT_VOICE
3
- from yta_audio_narration_common.voice import NarrationVoice
4
- from yta_constants.enum import YTAEnum as Enum
5
- from yta_constants.file import FileType
6
- from yta_programming.output import Output
7
- from typing import Union
8
-
9
- import pyttsx3
10
-
11
-
12
1
  """
13
- The options below are specified even if we
14
- don't use them later when processing the
15
- voice narration. This is to keep the same
16
- structure for any voice narration and to
17
- simplify the way we offer the options in
18
- an API that is able to make requests.
2
+ TODO: Do we make this optional or not? If it
3
+ is optional we can allow installing the libs
4
+ only if using this one.
19
5
  """
20
-
21
- # 1. The voices we accept, as Enums
22
- class MicrosoftVoiceName(Enum):
23
- """
24
- Available voices. The value is what is used
25
- for the audio creation.
26
- """
27
-
28
- DEFAULT = DEFAULT_VOICE
29
- SPANISH_SPAIN = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_ES-ES_HELENA_11.0'
30
- SPANISH_MEXICO = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_ES-MX_SABINA_11.0'
31
- # TODO: There are more voices
32
-
33
- # 2. The languages we accept
34
- LANGUAGE_OPTIONS = [
35
- NarrationLanguage.DEFAULT,
36
- NarrationLanguage.SPANISH
37
- ]
38
-
39
- # 3. The emotions we accept
40
- EMOTION_OPTIONS = [
41
- VoiceEmotion.DEFAULT,
42
- VoiceEmotion.NORMAL,
43
- ]
44
-
45
- # 4. The speeds we accept
46
- SPEED_OPTIONS = [
47
- VoiceSpeed.DEFAULT,
48
- VoiceSpeed.NORMAL,
49
- VoiceSpeed.SLOW,
50
- VoiceSpeed.FAST
51
- ]
52
-
53
- # 5. The pitches we accept
54
- PITCH_OPTIONS = [
55
- VoicePitch.DEFAULT,
56
- VoicePitch.NORMAL,
57
- ]
58
-
59
-
60
- class MicrosoftNarrationVoice(NarrationVoice):
61
- """
62
- Voice instance to be used when narrating with
63
- Microsoft engine.
64
- """
65
-
66
- @property
67
- def processed_name(
68
- self
69
- ) -> str:
70
- """
71
- Get the usable name value from the one that has
72
- been set when instantiating the instance.
73
- """
74
- # TODO: Maybe this DEFAULT value has to exist
75
- # for each language so it chooses one voice name
76
- # for that language
77
- return (
78
- MicrosoftVoiceName.SPANISH_SPAIN.value
79
- if MicrosoftVoiceName.to_enum(self.name) == MicrosoftVoiceName.DEFAULT else
80
- MicrosoftVoiceName.to_enum(self.name).value
81
- )
82
-
83
- @property
84
- def processed_emotion(
85
- self
86
- ) -> str:
87
- """
88
- Get the usable emotion value from the one that
89
- has been set when instantiating the instance.
90
- """
91
- # This narration is not able to handle any
92
- # emotion (at least by now)
93
- return None
94
-
95
- @property
96
- def processed_speed(
97
- self
98
- ) -> int:
99
- """
100
- Get the usable speed value from the one that
101
- has been set when instantiating the instance.
102
- """
103
- # This value is actually the amount of words per
104
- # minute to be said during the speech
105
- speed = (
106
- VoiceSpeed.NORMAL
107
- if self.speed == VoiceSpeed.DEFAULT else
108
- self.speed
109
- )
110
-
111
- return {
112
- VoiceSpeed.SLOW: 160,
113
- VoiceSpeed.NORMAL: 200,
114
- VoiceSpeed.FAST: 240
115
- }[speed]
116
-
117
- @property
118
- def processed_pitch(
119
- self
120
- ) -> float:
121
- """
122
- Get the usable pitch value from the one that
123
- has been set when instantiating the instance.
124
- """
125
- # By now we are not handling the pitch with
126
- # this voice
127
- return None
128
-
129
- @property
130
- def processed_language(
131
- self
132
- ) -> str:
133
- """
134
- Get the usable language value from the one that
135
- has been set when instantiating the instance.
136
- """
137
- # By now we are not handling the language with
138
- # this voice
139
- return None
140
-
141
- def validate_and_process(
142
- self,
143
- name: str,
144
- emotion: VoiceEmotion,
145
- speed: VoiceSpeed,
146
- pitch: VoicePitch,
147
- language: NarrationLanguage
148
- ):
149
- MicrosoftVoiceName.to_enum(name)
150
- if VoiceEmotion.to_enum(emotion) not in EMOTION_OPTIONS:
151
- raise Exception(f'The provided {emotion} is not valid for this narration voice.')
152
- if VoiceSpeed.to_enum(speed) not in SPEED_OPTIONS:
153
- raise Exception(f'The provided {speed} is not valid for this narration voice.')
154
- if VoicePitch.to_enum(pitch) not in PITCH_OPTIONS:
155
- raise Exception(f'The provided {pitch} is not valid for this narration voice.')
156
- if NarrationLanguage.to_enum(language) not in LANGUAGE_OPTIONS:
157
- raise Exception(f'The provided {language} is not valid for this narration voice.')
158
-
159
- @staticmethod
160
- def default():
161
- return MicrosoftNarrationVoice(
162
- name = MicrosoftVoiceName.DEFAULT.value,
163
- emotion = VoiceEmotion.DEFAULT,
164
- speed = VoiceSpeed.DEFAULT,
165
- pitch = VoicePitch.DEFAULT,
166
- language = NarrationLanguage.DEFAULT
167
- )
168
-
169
- # The voices but for a specific language, to be able to
170
- # choose one when this is requested from the outside
171
- def get_narrator_names_by_language(
172
- language: NarrationLanguage
173
- ) -> list[str]:
174
- language = NarrationLanguage.to_enum(language)
175
- language = (
176
- NarrationLanguage.SPANISH
177
- if language is NarrationLanguage.DEFAULT else
178
- language
179
- )
180
-
181
- return {
182
- NarrationLanguage.SPANISH: [
183
- MicrosoftVoiceName.DEFAULT.value,
184
- MicrosoftVoiceName.SPANISH_SPAIN.value,
185
- MicrosoftVoiceName.SPANISH_MEXICO.value
186
- ]
187
- }[language]
188
-
189
- # All the remaining functionality we need to make it
190
- # work properly
191
- def narrate(
192
- text: str,
193
- voice: MicrosoftNarrationVoice = MicrosoftNarrationVoice.default(),
194
- output_filename: Union[str, None] = None
195
- ):
196
- """
197
- Creates an audio narration of the provided 'text'
198
- and stores it as 'output_filename'.
199
- """
200
- output_filename = Output.get_filename(output_filename, FileType.AUDIO)
201
-
202
- engine = pyttsx3.init()
203
- engine.setProperty('voice', voice.processed_name)
204
- # Default speed is 200 (wpm)
205
- engine.setProperty('rate', voice.processed_speed)
206
- engine.save_to_file(text, output_filename)
207
- engine.runAndWait()
208
-
209
- return output_filename
6
+ from yta_audio_narration_microsoft import MicrosoftNarrationLanguage, LANGUAGE_OPTIONS, EMOTION_OPTIONS, SPEED_OPTIONS, PITCH_OPTIONS, MicrosoftNarrationVoice, get_narrator_names_by_language, narrate
@@ -1,16 +1,16 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yta-audio-narration
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Youtube Autonomous Audio Narration Module.
5
5
  Author: danialcala94
6
6
  Author-email: danielalcalavalera@gmail.com
7
7
  Requires-Python: ==3.9
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.9
10
- Requires-Dist: pyttsx3 (>=2.90,<3.0)
11
10
  Requires-Dist: yta_audio_narration_common (>=0.0.1,<1.0.0)
12
11
  Requires-Dist: yta_audio_narration_coqui (>=0.0.1,<1.0.0)
13
12
  Requires-Dist: yta_audio_narration_google (>=0.0.1,<1.0.0)
13
+ Requires-Dist: yta_audio_narration_microsoft (>=0.0.1,<1.0.0)
14
14
  Requires-Dist: yta_constants (>=0.0.1,<1.0.0)
15
15
  Requires-Dist: yta_file (>=0.0.1,<1.0.0)
16
16
  Requires-Dist: yta_file_downloader (>=0.0.1,<1.0.0)
@@ -4,13 +4,13 @@ yta_audio_narration/narrator.py,sha256=w-ACkH71vGhgAJxD1H3ToPDa3HQZOs5W0f1okeqyz
4
4
  yta_audio_narration/voices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  yta_audio_narration/voices/coqui.py,sha256=e3-AOTW-IS9L9aYFrp-_sSE543vygKupW96xgYhL0cI,331
6
6
  yta_audio_narration/voices/google.py,sha256=I4L2qm-zIXJ7eE23iM88m8rdEtO9L820vbnRJbQHhsg,328
7
- yta_audio_narration/voices/microsoft.py,sha256=J5e4153secyta5tEWeNJTBYkkFhVYbM1zQ-e9y73Yr8,6375
7
+ yta_audio_narration/voices/microsoft.py,sha256=6N1b5y4ayCPg5WdxhHZAVKSPCH3kta_J6YhDc3nVoB8,326
8
8
  yta_audio_narration/voices/open_voice.py,sha256=KlqIcsJXY581dURIqaFdk8noHsllzxZbQCkSyBxQ7QM,12981
9
9
  yta_audio_narration/voices/tetyys.py,sha256=PZB8CSkdAyStWsWwMqRvm0dlEefZViO5fcwwzNZE9IM,8291
10
10
  yta_audio_narration/voices/tiktok.py,sha256=R1lWljr0on_wamKBOUo9mbHXkmKvPbGYk2Ebfm6ua50,7482
11
11
  yta_audio_narration/voices/tortoise.py,sha256=qtL7Hl2f2bSjw2G81Ui-lTV8DZIcrJrKClkY3ulkf3I,6576
12
12
  yta_audio_narration/voices/ttsmp3.py,sha256=Zl3w4uY9n93RlpQv8c_1w22KZlb5BzHQRAqsheu5Gbo,8799
13
- yta_audio_narration-0.0.3.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
14
- yta_audio_narration-0.0.3.dist-info/METADATA,sha256=Yc_dU9klDq7yGHbo8zgNYL5MXhrHZt9qTXIn4XT8gOA,970
15
- yta_audio_narration-0.0.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
16
- yta_audio_narration-0.0.3.dist-info/RECORD,,
13
+ yta_audio_narration-0.0.4.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
14
+ yta_audio_narration-0.0.4.dist-info/METADATA,sha256=D8D9saJl2JFiKQPQKB4qTKZh1dHSMkDYu-sWZN9pGB4,995
15
+ yta_audio_narration-0.0.4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
16
+ yta_audio_narration-0.0.4.dist-info/RECORD,,