yta-audio-narration 0.0.5__py3-none-any.whl → 0.0.6__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,263 +1,6 @@
1
1
  """
2
- For anything else you need, check this:
3
- - https://www.tetyys.com/SAPI4/
4
-
5
- Each voice has an specific pitch and speed
6
- so please, pay attention to it. Here are
7
- some examples of this:
8
- 'Male Whisper' p: 113, s: 140
9
- 'Female Whisper' p: 169, s: 140
10
- 'Mary' p: 169, s: 140
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.
11
5
  """
12
- from yta_audio_narration_common.consts import DEFAULT_VOICE
13
- from yta_audio_narration_common.enums import NarrationLanguage, VoiceEmotion, VoiceSpeed, VoicePitch
14
- from yta_audio_narration_common.voice import NarrationVoice
15
- from yta_file.handler import FileHandler
16
- from yta_constants.enum import YTAEnum as Enum
17
- from yta_constants.file import FileType
18
- from yta_programming.output import Output
19
- from typing import Union
20
-
21
- import requests
22
-
23
-
24
- """
25
- The options below are specified even if we
26
- don't use them later when processing the
27
- voice narration. This is to keep the same
28
- structure for any voice narration and to
29
- simplify the way we offer the options in
30
- an API that is able to make requests.
31
- """
32
-
33
- # 1. The voices we accept, as Enums
34
- class TetyysVoiceName(Enum):
35
- """
36
- Available voices. The value is what is used
37
- for the audio creation.
38
- """
39
-
40
- DEFAULT = DEFAULT_VOICE
41
- SAM = 'Sam'
42
- MALE_WHISPER = 'Male Whisper'
43
- FEMALE_WHISPER = 'Female Whisper'
44
- MARY = 'Mary'
45
- MARY_IN_SPACE = 'Mary in Space'
46
- MIKE_IN_SPACE = 'Mike in Space'
47
- ROBOSOFT_ONE = 'RobosoftOne'
48
- # TODO: There are more voices
49
-
50
- # 2. The languages we accept
51
- LANGUAGE_OPTIONS = [
52
- NarrationLanguage.ENGLISH,
53
- NarrationLanguage.DEFAULT
54
- ]
55
-
56
- # 3. The emotions we accept
57
- EMOTION_OPTIONS = [
58
- VoiceEmotion.DEFAULT,
59
- VoiceEmotion.NORMAL,
60
- ]
61
-
62
- # 4. The speeds we accept
63
- SPEED_OPTIONS = [
64
- VoiceSpeed.DEFAULT,
65
- VoiceSpeed.NORMAL,
66
- ]
67
-
68
- # 5. The pitches we accept
69
- PITCH_OPTIONS = [
70
- VoicePitch.DEFAULT,
71
- VoicePitch.NORMAL,
72
- ]
73
-
74
-
75
- class TetyysNarrationVoice(NarrationVoice):
76
- """
77
- Voice instance to be used when narrating with
78
- Tiktok engine.
79
- """
80
-
81
- @property
82
- def processed_name(
83
- self
84
- ) -> str:
85
- """
86
- Get the usable name value from the one that has
87
- been set when instantiating the instance.
88
- """
89
- # TODO: Maybe this DEFAULT value has to exist
90
- # for each language so it chooses one voice name
91
- # for that language
92
- return (
93
- TetyysVoiceName.SAM.value
94
- if TetyysVoiceName.to_enum(self.name) == TetyysVoiceName.DEFAULT else
95
- TetyysVoiceName.to_enum(self.name).value
96
- )
97
-
98
- @property
99
- def processed_emotion(
100
- self
101
- ) -> str:
102
- """
103
- Get the usable emotion value from the one that
104
- has been set when instantiating the instance.
105
- """
106
- # This narration is not able to handle any
107
- # emotion (at least by now)
108
- return None
109
-
110
- @property
111
- def processed_speed(
112
- self
113
- ) -> int:
114
- """
115
- Get the usable speed value from the one that
116
- has been set when instantiating the instance.
117
- """
118
- # By now all the voices I'm using have the same
119
- # speed value so I'm just returning it
120
- return 140
121
-
122
- @property
123
- def processed_pitch(
124
- self
125
- ) -> int:
126
- """
127
- Get the usable pitch value from the one that
128
- has been set when instantiating the instance.
129
- """
130
- return {
131
- TetyysVoiceName.MALE_WHISPER: 113,
132
- TetyysVoiceName.FEMALE_WHISPER: 169,
133
- TetyysVoiceName.MARY: 169,
134
- TetyysVoiceName.MARY_IN_SPACE: 169,
135
- TetyysVoiceName.MIKE_IN_SPACE: 113,
136
- TetyysVoiceName.SAM: 100
137
- }[TetyysVoiceName.to_enum(self.processed_name)]
138
-
139
- @property
140
- def processed_language(
141
- self
142
- ) -> str:
143
- """
144
- Get the usable language value from the one that
145
- has been set when instantiating the instance.
146
- """
147
- # TODO: There is not language associated with this
148
- # narration voice engine
149
- return None
150
-
151
- def validate_and_process(
152
- self,
153
- name: str,
154
- emotion: VoiceEmotion,
155
- speed: VoiceSpeed,
156
- pitch: VoicePitch,
157
- language: NarrationLanguage
158
- ):
159
- TetyysVoiceName.to_enum(name)
160
- if VoiceEmotion.to_enum(emotion) not in EMOTION_OPTIONS:
161
- raise Exception(f'The provided {emotion} is not valid for this narration voice.')
162
- if VoiceSpeed.to_enum(speed) not in SPEED_OPTIONS:
163
- raise Exception(f'The provided {speed} is not valid for this narration voice.')
164
- if VoicePitch.to_enum(pitch) not in PITCH_OPTIONS:
165
- raise Exception(f'The provided {pitch} is not valid for this narration voice.')
166
- if NarrationLanguage.to_enum(language) not in LANGUAGE_OPTIONS:
167
- raise Exception(f'The provided {language} is not valid for this narration voice.')
168
-
169
- @staticmethod
170
- def default():
171
- return TetyysNarrationVoice(
172
- name = TetyysVoiceName.DEFAULT.value,
173
- emotion = VoiceEmotion.DEFAULT,
174
- speed = VoiceSpeed.DEFAULT,
175
- pitch = VoicePitch.DEFAULT,
176
- language = NarrationLanguage.DEFAULT
177
- )
178
-
179
-
180
- # The voices but for a specific language, to be able to
181
- # choose one when this is requested from the outside
182
- def get_narrator_names_by_language(
183
- language: NarrationLanguage
184
- ) -> list[str]:
185
- language = NarrationLanguage.to_enum(language)
186
- language = (
187
- NarrationLanguage.ENGLISH
188
- if language is NarrationLanguage.DEFAULT else
189
- language
190
- )
191
-
192
- return {
193
- NarrationLanguage.ENGLISH: [
194
- TetyysVoiceName.DEFAULT.value,
195
- TetyysVoiceName.SAM.value,
196
- TetyysVoiceName.MALE_WHISPER.value,
197
- TetyysVoiceName.FEMALE_WHISPER.value,
198
- TetyysVoiceName.MARY.value,
199
- TetyysVoiceName.MARY_IN_SPACE.value,
200
- TetyysVoiceName.MIKE_IN_SPACE.value,
201
- ]
202
- }[language]
203
-
204
- # All the remaining functionality we need to make it
205
- # work properly
206
- def narrate_tetyys(
207
- text: str,
208
- voice: TetyysNarrationVoice = TetyysNarrationVoice.default(),
209
- output_filename: Union[str, None] = None
210
- ) -> str:
211
- """
212
- This method creates an audio voice narration of the provided
213
- 'text' read with tthe tetyys system voice (Microsoft Speech
214
- API 4.0 from 1998) and stores it as 'output_filename'. It is
215
- only available for ENGLISH speaking.
216
-
217
- You can change some voice parameters in code to make it a
218
- different voice.
219
-
220
- This method is requesting an external (but apparently stable
221
- website).
222
-
223
- This method returns the filename that has been written.
224
- """
225
- headers = {
226
- 'accept': '*/*',
227
- 'accept-language': 'es-ES,es;q=0.9',
228
- 'priority': 'u=1, i',
229
- 'referer': 'https://www.tetyys.com/SAPI4/',
230
- 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
231
- 'sec-ch-ua-mobile': '?0',
232
- 'sec-ch-ua-platform': '"Windows"',
233
- 'sec-fetch-dest': 'empty',
234
- 'sec-fetch-mode': 'cors',
235
- 'sec-fetch-site': 'same-origin',
236
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
237
- }
238
-
239
- params = {
240
- 'text': text,
241
- # Inspect options 'value' from https://www.tetyys.com/SAPI4/ but
242
- # each voice has a pre-set 'pitch' and 'speed'
243
- 'voice': voice.processed_name,
244
- 'pitch': str(voice.processed_pitch),
245
- 'speed': str(voice.processed_speed)
246
- }
247
-
248
- """
249
- Some VOICE options:
250
- 'Male Whisper' 113, 140
251
- 'Female Whisper' 169, 140
252
- 'Mary' 169, 140
253
- 'Mary in Space'|'Mary in Hall'|'Mary in Stadium'|Mary (for Telephone) 169, 140
254
- 'Mike in Space'|... 113, 140
255
- 'RobosoftOne'|'RobosoftTwo'
256
- 'Sam' 100, 140
257
- """
258
-
259
- output_filename = Output.get_filename(output_filename, FileType.AUDIO)
260
-
261
- response = requests.get('https://www.tetyys.com/SAPI4/SAPI4', params = params, headers = headers)
262
-
263
- return FileHandler.write_binary(output_filename, response.content)
6
+ from yta_audio_narration_tetyys import TetyysVoiceName, LANGUAGE_OPTIONS, EMOTION_OPTIONS, SPEED_OPTIONS, PITCH_OPTIONS, TetyysNarrationVoice, get_narrator_names_by_language, narrate_tetyys
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: yta-audio-narration
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: Youtube Autonomous Audio Narration Module.
5
5
  Author: danialcala94
6
6
  Author-email: danielalcalavalera@gmail.com
@@ -12,6 +12,7 @@ Requires-Dist: yta_audio_narration_coqui (>=0.0.1,<1.0.0)
12
12
  Requires-Dist: yta_audio_narration_google (>=0.0.1,<1.0.0)
13
13
  Requires-Dist: yta_audio_narration_microsoft (>=0.0.1,<1.0.0)
14
14
  Requires-Dist: yta_audio_narration_open_voice (>=0.0.1,<1.0.0)
15
+ Requires-Dist: yta_audio_narration_tetyys (>=0.0.1,<1.0.0)
15
16
  Requires-Dist: yta_constants (>=0.0.1,<1.0.0)
16
17
  Requires-Dist: yta_file (>=0.0.1,<1.0.0)
17
18
  Requires-Dist: yta_file_downloader (>=0.0.1,<1.0.0)
@@ -6,11 +6,11 @@ yta_audio_narration/voices/coqui.py,sha256=e3-AOTW-IS9L9aYFrp-_sSE543vygKupW96xg
6
6
  yta_audio_narration/voices/google.py,sha256=I4L2qm-zIXJ7eE23iM88m8rdEtO9L820vbnRJbQHhsg,328
7
7
  yta_audio_narration/voices/microsoft.py,sha256=DnMyc2C5Zy2VEpYK2Xljsrhx8QibUPlIrXAKTUD6uTI,318
8
8
  yta_audio_narration/voices/open_voice.py,sha256=zU4LmXVAHgF3YCMrM--55RM1UGQX7kn9Y2137wCNu1Y,347
9
- yta_audio_narration/voices/tetyys.py,sha256=PZB8CSkdAyStWsWwMqRvm0dlEefZViO5fcwwzNZE9IM,8291
9
+ yta_audio_narration/voices/tetyys.py,sha256=CFVpUJLA_SK7_wMBnhl4mlPNgI-VKvxXy0aX7MvxoxE,316
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.5.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
14
- yta_audio_narration-0.0.5.dist-info/METADATA,sha256=2i9MUas04hn530bIrE5nNdClef3FmjRBM1VA9WEZyYk,1058
15
- yta_audio_narration-0.0.5.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
16
- yta_audio_narration-0.0.5.dist-info/RECORD,,
13
+ yta_audio_narration-0.0.6.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
14
+ yta_audio_narration-0.0.6.dist-info/METADATA,sha256=qoS0V-dvMbNcL-99m8F_3-Ies7o7o3s7usksAPT5Gmg,1117
15
+ yta_audio_narration-0.0.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
16
+ yta_audio_narration-0.0.6.dist-info/RECORD,,