File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1395,10 +1395,23 @@ async def text_to_speech(self, text):
13951395 Note:
13961396 The assistant should send the audio URL to the user so they can listen to it, it will embed the audio in the chat when the assistant sends the URL.
13971397 """
1398- return self .ApiClient .text_to_speech (
1399- text = text ,
1400- agent_name = self .agent_name ,
1398+ from Agent import Agent
1399+ import base64
1400+
1401+ agent = Agent (
1402+ agent_name = self .agent_name , ApiClient = self .ApiClient , user = self .user
14011403 )
1404+ AGIXT_URI = getenv ("AGIXT_URI" )
1405+ tts_response = await agent .text_to_speech (text = text )
1406+ if not str (tts_response ).startswith ("http" ):
1407+ file_type = "wav"
1408+ file_name = f"{ uuid .uuid4 ().hex } .{ file_type } "
1409+ audio_path = os .path .join (self .WORKING_DIRECTORY , file_name )
1410+ audio_data = base64 .b64decode (tts_response )
1411+ with open (audio_path , "wb" ) as f :
1412+ f .write (audio_data )
1413+ tts_response = f"{ AGIXT_URI } /outputs/{ self .agent_id } /{ self .conversation_id } /{ file_name } "
1414+ return tts_response
14021415
14031416 async def create_todo_item (
14041417 self ,
You can’t perform that action at this time.
0 commit comments