Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -58,27 +58,20 @@ def lookup_definition(query: str) -> AgentText:
|
|
58 |
|
59 |
AUDIO_OUTPUT_PATH = "/tmp/response.mp3"
|
60 |
|
|
|
61 |
@tool
|
62 |
def text_to_speech(text: str) -> AgentAudio:
|
63 |
"""
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
"""
|
66 |
tts = gTTS(text=text, lang='en')
|
67 |
tts.save(AUDIO_OUTPUT_PATH)
|
68 |
return AgentAudio(AUDIO_OUTPUT_PATH)
|
69 |
|
70 |
-
# Immediately after its definition, update the __doc__ attribute:
|
71 |
-
text_to_speech.__doc__ = (
|
72 |
-
"Convert text to speech and return the generated audio.\n\n"
|
73 |
-
"Parameters\n"
|
74 |
-
"----------\n"
|
75 |
-
"text : str\n"
|
76 |
-
" The text to be converted into speech.\n\n"
|
77 |
-
"Returns\n"
|
78 |
-
"-------\n"
|
79 |
-
"AgentAudio\n"
|
80 |
-
" An instance containing the path to the generated audio file."
|
81 |
-
)
|
82 |
|
83 |
|
84 |
# # Define the audio output path
|
|
|
58 |
|
59 |
AUDIO_OUTPUT_PATH = "/tmp/response.mp3"
|
60 |
|
61 |
+
|
62 |
@tool
|
63 |
def text_to_speech(text: str) -> AgentAudio:
|
64 |
"""
|
65 |
+
Converts input text to speech and returns an AgentAudio instance with the audio file path.
|
66 |
+
Args:
|
67 |
+
text: The text sring with word definition that will be converted into speech.
|
68 |
+
Returns:
|
69 |
+
AgentAudio: An AgentAudio instance containing the file path to the generated audio.
|
70 |
"""
|
71 |
tts = gTTS(text=text, lang='en')
|
72 |
tts.save(AUDIO_OUTPUT_PATH)
|
73 |
return AgentAudio(AUDIO_OUTPUT_PATH)
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
|
77 |
# # Define the audio output path
|