Agent Zero AI framework
Microsoft Edge TTS - FREE with HF
evrardt78d1920c21d2
diff --git a/main.py b/main.pyindex 368a96fa1..3b7a32b72 100644--- a/main.py+++ b/main.py@@ -1,4 +1,4 @@-import threading, time, models, os+import threading, time, models, os, sys, argparse, asynciofrom ansio import application_keypad, mouse_input, raw_inputfrom ansio.input import InputEvent, get_input_eventfrom agent import Agent, AgentConfig@@ -6,11 +6,18 @@ from python.helpers.print_style import PrintStylefrom python.helpers.files import read_filefrom python.helpers import filesimport python.helpers.timed_input as timed_input-+from tts import TTSinput_lock = threading.Lock()os.chdir(files.get_abs_path("./work_dir")) #change CWD to work_dir+# args parser+parser = argparse.ArgumentParser()+parser.add_argument('-v', '--voice')+args = parser.parse_args()++# init tts (text to speech)+tts = TTS(args.voice)def initialize():@@ -108,8 +115,8 @@ def chat(agent:Agent):# print agent0 responsePrintStyle(font_color="white",background_color="#1D8348", bold=True, padding=True).print(f"{agent.agent_name}: reponse:")- PrintStyle(font_color="white").print(f"{assistant_response}")-+ PrintStyle(font_color="white").print(f"{assistant_response}")+ tts.speech(assistant_response)# User intervention during agent streamingdef intervention():diff --git a/requirements.txt b/requirements.txtindex a1f1a2f25..90e293e9b 100644--- a/requirements.txt+++ b/requirements.txt@@ -12,4 +12,6 @@ sentence-transformers==3.0.1docker==7.1.0paramiko==3.4.0duckduckgo_search==6.1.12-inputimeout==1.0.4\ No newline at end of file+inputimeout==1.0.4+gradio_client==1.2.0+pygame==2.6.0\ No newline at end of filediff --git a/tts.py b/tts.pynew file mode 100644index 000000000..86aeadf5b--- /dev/null+++ b/tts.py@@ -0,0 +1,30 @@+from gradio_client import Client+import os+import pygame.mixer++client = Client("innoai/Edge-TTS-Text-to-Speech")+pygame.mixer.init()+lang = "en-US-AndrewMultilingualNeural"++class TTS:+ def __init__(self, lang):+ if (lang.lower() == 'fr'):+ lang == "fr-FR-RemyMultilingualNeural"+ elif (lang.lower() == 'es'):+ lang == "es-ES-AlvaroNeural"+ elif (lang.lower() == 'de'):+ lang == "de-DE-FlorianMultilingualNeural"+ else:+ lang == "en-US-AndrewMultilingualNeural"++ def speech(self, text):+ speech = client.predict(+ text=text,+ voice=lang,+ rate=20,+ pitch=0,+ api_name="/predict"+ )+ pygame.mixer.music.load(speech[0]) # chargement de la musique+ pygame.mixer.music.play() # la musique est jouée+\ No newline at end of file