CineAI commited on
Commit
5c1488a
·
verified ·
1 Parent(s): 9c715e2

Update audio_processing/T2A.py

Browse files
Files changed (1) hide show
  1. audio_processing/T2A.py +12 -2
audio_processing/T2A.py CHANGED
@@ -3,12 +3,22 @@ from streamlit_TTS import auto_play, text_to_audio
3
 
4
 
5
  class T2A:
6
- def autoplay(self, input_text: Optional[str] = None, lang: str = "en") -> None:
 
 
 
 
 
 
 
 
7
 
8
  if input_text is not None:
9
  if isinstance(input_text, str):
10
  audio = text_to_audio(input_text, language=lang)
11
- auto_play(audio)
 
 
12
  else:
13
  text = f"The text you provided is of data type {type(input_text)}, only string type is accepted"
14
  audio = text_to_audio(text, language=lang)
 
3
 
4
 
5
  class T2A:
6
+ def autoplay(self, input_text: Optional[str] = None, lang: str = "en", just_once: bool = False) -> None:
7
+ """
8
+ Plays audio once based on the provided input text.
9
+
10
+ Args:
11
+ input_text (Optional[str], optional): Text to convert to audio. Defaults to None.
12
+ lang (str, optional): Language for text-to-speech conversion. Defaults to "en".
13
+ just_once (bool, optional): Flag to control whether audio plays only once. Defaults to False.
14
+ """
15
 
16
  if input_text is not None:
17
  if isinstance(input_text, str):
18
  audio = text_to_audio(input_text, language=lang)
19
+ if not just_once:
20
+ auto_play(audio)
21
+ just_once = True
22
  else:
23
  text = f"The text you provided is of data type {type(input_text)}, only string type is accepted"
24
  audio = text_to_audio(text, language=lang)