CineAI's picture
Update audio_processing/T2A.py
558fcff verified
raw
history blame
775 Bytes
from typing import Optional
from streamlit_TTS import auto_play, text_to_audio
class T2A:
def autoplay(self, input_text: Optional[str] = None, lang: str = "en") -> None:
if input_text is not None:
if isinstance(input_text, str):
audio = text_to_audio(input_text, language=lang)
auto_play(audio)
else:
text = f"The text you provided is of data type {type(input_text)}, only string type is accepted"
audio = text_to_audio(text, language=lang)
auto_play(audio)
else:
text = "Please check the input text you have provided, it has a value of None"
audio = text_to_audio(text, language=lang)
auto_play(audio)