File size: 1,003 Bytes
d5436e0 9b0d264 4bb9300 e294914 5c1488a e294914 5c1488a 5d817ad e294914 558fcff e294914 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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:
"""
Plays audio based on the provided input text.
Args:
input_text (Optional[str], optional): Text to convert to audio. Defaults to None.
lang (str, optional): Language for text-to-speech conversion. Defaults to "en".
"""
if input_text is None:
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)
if not isinstance(input_text, str):
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)
audio = text_to_audio(input_text, language=lang)
auto_play(audio)
|