Update audio_processing/T2A.py
Browse files- audio_processing/T2A.py +14 -0
audio_processing/T2A.py
CHANGED
@@ -7,6 +7,8 @@ import soundfile as sf
|
|
7 |
from io import BytesIO
|
8 |
from .config import pipe_tts
|
9 |
|
|
|
|
|
10 |
SAMPLING_RATE = 16000
|
11 |
|
12 |
class T2A:
|
@@ -19,6 +21,18 @@ class T2A:
|
|
19 |
duration = librosa.get_duration(y=audio, sr=sample_rate)
|
20 |
return duration
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def get_audio(self):
|
23 |
try:
|
24 |
synth = self.output_model["audio"][0]
|
|
|
7 |
from io import BytesIO
|
8 |
from .config import pipe_tts
|
9 |
|
10 |
+
from streamlit_TTS import auto_play, text_to_audio
|
11 |
+
|
12 |
SAMPLING_RATE = 16000
|
13 |
|
14 |
class T2A:
|
|
|
21 |
duration = librosa.get_duration(y=audio, sr=sample_rate)
|
22 |
return duration
|
23 |
|
24 |
+
def autoplay(self, text: str, language: str = "en") -> None:
|
25 |
+
if text is not None:
|
26 |
+
if isinstance(text, str):
|
27 |
+
audio = text_to_audio(text, language=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:
|
34 |
+
raise Exception("Text is None")
|
35 |
+
|
36 |
def get_audio(self):
|
37 |
try:
|
38 |
synth = self.output_model["audio"][0]
|