Update audio_processing/T2A.py
Browse files- audio_processing/T2A.py +7 -6
audio_processing/T2A.py
CHANGED
@@ -12,7 +12,8 @@ from streamlit_TTS import auto_play, text_to_audio
|
|
12 |
SAMPLING_RATE = 16000
|
13 |
|
14 |
class T2A:
|
15 |
-
def __init__(self, input_text: str):
|
|
|
16 |
self.output_model = pipe_tts(input_text)
|
17 |
|
18 |
def __get_duration(self, raw: bytes):
|
@@ -21,13 +22,13 @@ class T2A:
|
|
21 |
duration = librosa.get_duration(y=audio, sr=sample_rate)
|
22 |
return duration
|
23 |
|
24 |
-
def autoplay(self,
|
25 |
-
if text is not None:
|
26 |
-
if isinstance(text, str):
|
27 |
-
audio = text_to_audio(text, language=
|
28 |
auto_play(audio)
|
29 |
else:
|
30 |
-
text = f"Text you provide is {type(text)} accepted only string type"
|
31 |
audio = text_to_audio(text, language=language)
|
32 |
auto_play(audio)
|
33 |
else:
|
|
|
12 |
SAMPLING_RATE = 16000
|
13 |
|
14 |
class T2A:
|
15 |
+
def __init__(self, input_text: str = None):
|
16 |
+
self.text = input_text
|
17 |
self.output_model = pipe_tts(input_text)
|
18 |
|
19 |
def __get_duration(self, raw: bytes):
|
|
|
22 |
duration = librosa.get_duration(y=audio, sr=sample_rate)
|
23 |
return duration
|
24 |
|
25 |
+
def autoplay(self, lang: str = "en") -> None:
|
26 |
+
if self.text is not None:
|
27 |
+
if isinstance(self.text, str):
|
28 |
+
audio = text_to_audio(self.text, language=lang)
|
29 |
auto_play(audio)
|
30 |
else:
|
31 |
+
text = f"Text you provide is {type(self.text)} accepted only string type"
|
32 |
audio = text_to_audio(text, language=language)
|
33 |
auto_play(audio)
|
34 |
else:
|