feat : cleaner import arrangement

This commit is contained in:
martin legrand
2025-04-01 13:10:06 +02:00
parent b3efd09fb3
commit 1b5a55ccf2
8 changed files with 30 additions and 19 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
You are a planner agent. You are a project manager.
Your goal is to divide and conquer the task using the following agents: Your goal is to divide and conquer the task using the following agents:
- Coder: An expert coder agent. - Coder: An expert coder agent.
- File: An expert agent for finding files. - File: An expert agent for finding files.
+3 -1
View File
@@ -1,3 +1,4 @@
from typing import List, Tuple, Type, Dict, Tuple
from sources.text_to_speech import Speech from sources.text_to_speech import Speech
from sources.utility import pretty_print, animate_thinking from sources.utility import pretty_print, animate_thinking
@@ -11,7 +12,8 @@ class Interaction:
def __init__(self, agents, def __init__(self, agents,
tts_enabled: bool = True, tts_enabled: bool = True,
stt_enabled: bool = True, stt_enabled: bool = True,
recover_last_session: bool = False): recover_last_session: bool = False,
):
self.is_active = True self.is_active = True
self.current_agent = None self.current_agent = None
self.last_query = None self.last_query = None
+1
View File
@@ -1,3 +1,4 @@
from typing import List, Tuple, Type, Dict, Tuple
import langid import langid
import re import re
import nltk import nltk
+3 -2
View File
@@ -1,16 +1,17 @@
import os
import time import time
import ollama import ollama
from ollama import chat from ollama import chat
import requests import requests
import subprocess import subprocess
import ipaddress import ipaddress
import httpx
import platform import platform
from dotenv import load_dotenv, set_key from dotenv import load_dotenv, set_key
from openai import OpenAI from openai import OpenAI
from huggingface_hub import InferenceClient from huggingface_hub import InferenceClient
import os from typing import List, Tuple, Type, Dict, Tuple
import httpx
from sources.utility import pretty_print, animate_thinking from sources.utility import pretty_print, animate_thinking
+3 -2
View File
@@ -1,11 +1,12 @@
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import time import time
import datetime import datetime
import uuid import uuid
import os import os
import sys import sys
import json import json
from typing import List, Tuple, Type, Dict, Tuple
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+2
View File
@@ -1,6 +1,8 @@
import os import os
import sys import sys
import torch import torch
from typing import List, Tuple, Type, Dict, Tuple
from transformers import pipeline from transformers import pipeline
from adaptive_classifier import AdaptiveClassifier from adaptive_classifier import AdaptiveClassifier
+1
View File
@@ -1,4 +1,5 @@
from colorama import Fore from colorama import Fore
from typing import List, Tuple, Type, Dict, Tuple
import queue import queue
import threading import threading
import numpy as np import numpy as np
+16 -13
View File
@@ -1,30 +1,33 @@
import re
import platform
import subprocess
from sys import modules
from typing import List, Tuple, Type, Dict, Tuple
from kokoro import KPipeline from kokoro import KPipeline
from IPython.display import display, Audio from IPython.display import display, Audio
import soundfile as sf import soundfile as sf
import subprocess
import re
import platform
from sys import modules
class Speech(): class Speech():
""" """
Speech is a class for generating speech from text. Speech is a class for generating speech from text.
""" """
def __init__(self, enable: bool = True, language: str = "english") -> None: def __init__(self, enable: bool = True, language: str = "en", voice_idx: int = 0) -> None:
self.lang_map = { self.lang_map = {
"english": 'a', "en": 'a',
"chinese": 'z', "zh": 'z',
"french": 'f' "fr": 'f'
} }
self.voice_map = { self.voice_map = {
"english": ['af_alloy', 'af_bella', 'af_kore', 'af_nicole', 'af_nova', 'af_sky', 'am_echo', 'am_michael', 'am_puck'], "en": ['af_kore', 'af_bella', 'af_alloy', 'af_nicole', 'af_nova', 'af_sky', 'am_echo', 'am_michael', 'am_puck'],
"chinese": ['zf_xiaobei', 'zf_xiaoni', 'zf_xiaoxiao', 'zf_xiaoyi', 'zm_yunjian', 'zm_yunxi', 'zm_yunxia', 'zm_yunyang'], "zh": ['zf_xiaobei', 'zf_xiaoni', 'zf_xiaoxiao', 'zf_xiaoyi', 'zm_yunjian', 'zm_yunxi', 'zm_yunxia', 'zm_yunyang'],
"french": ['ff_siwis'] "fr": ['ff_siwis']
} }
self.pipeline = None self.pipeline = None
self.language = language
if enable: if enable:
self.pipeline = KPipeline(lang_code=self.lang_map[language]) self.pipeline = KPipeline(lang_code=self.lang_map[language])
self.voice = self.voice_map[language][2] self.voice = self.voice_map[language][voice_idx]
self.speed = 1.2 self.speed = 1.2
def speak(self, sentence: str, voice_number: int = 1 , audio_file: str = 'sample.wav'): def speak(self, sentence: str, voice_number: int = 1 , audio_file: str = 'sample.wav'):
@@ -38,7 +41,7 @@ class Speech():
if not self.pipeline: if not self.pipeline:
return return
sentence = self.clean_sentence(sentence) sentence = self.clean_sentence(sentence)
self.voice = self.voice_map["english"][voice_number] self.voice = self.voice_map[self.language][voice_number]
generator = self.pipeline( generator = self.pipeline(
sentence, voice=self.voice, sentence, voice=self.voice,
speed=self.speed, split_pattern=r'\n+' speed=self.speed, split_pattern=r'\n+'