mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
Fix some error
FIX: llm_provider.py 102: _model -> model MOD: utility.py 25: add windows termial color print text_to_speech.py 29: add windows version ADD: add termcolor in requirements.txt
This commit is contained in:
parent
298c26a63f
commit
42d2655881
@ -9,3 +9,5 @@ ollama==0.4.7
|
||||
scipy==1.15.1
|
||||
kokoro==0.7.12
|
||||
flask==3.1.0
|
||||
soundfile==0.13.1
|
||||
termcolor
|
@ -99,7 +99,7 @@ class Provider:
|
||||
thought += chunk['message']['content']
|
||||
except ollama.ResponseError as e:
|
||||
if e.status_code == 404:
|
||||
ollama.pull(self._model)
|
||||
ollama.pull(self.model)
|
||||
if "refused" in str(e):
|
||||
raise Exception("Ollama connection failed. is the server running ?")
|
||||
raise e
|
||||
|
@ -3,6 +3,8 @@ from IPython.display import display, Audio
|
||||
import soundfile as sf
|
||||
import subprocess
|
||||
import re
|
||||
import platform
|
||||
|
||||
|
||||
class Speech():
|
||||
def __init__(self, language = "english") -> None:
|
||||
@ -20,10 +22,15 @@ class Speech():
|
||||
speed=1, split_pattern=r'\n+'
|
||||
)
|
||||
for i, (gs, ps, audio) in enumerate(generator):
|
||||
audio_file = f'sample.wav'
|
||||
audio_file = 'sample.wav'
|
||||
print(audio_file)
|
||||
display(Audio(data=audio, rate=24000, autoplay=i==0))
|
||||
sf.write(audio_file, audio, 24000) # save each audio file
|
||||
if platform.system().lower() != "windows":
|
||||
subprocess.call(["afplay", audio_file])
|
||||
else:
|
||||
import winsound
|
||||
winsound.PlaySound(audio_file, winsound.SND_FILENAME)
|
||||
|
||||
def clean_sentence(self, sentence):
|
||||
sentence = re.sub(r'`.*?`', '', sentence)
|
||||
|
@ -1,10 +1,14 @@
|
||||
|
||||
from colorama import Fore
|
||||
from termcolor import colored
|
||||
import platform
|
||||
|
||||
|
||||
def pretty_print(text, color = "info"):
|
||||
"""
|
||||
print text with color
|
||||
"""
|
||||
if platform.system().lower() != "windows":
|
||||
color_map = {
|
||||
"success": Fore.GREEN,
|
||||
"failure": Fore.RED,
|
||||
@ -18,3 +22,16 @@ def pretty_print(text, color = "info"):
|
||||
pretty_print("Invalid color in pretty_print", "warning")
|
||||
return
|
||||
print(color_map[color], text, Fore.RESET)
|
||||
else:
|
||||
color_map = {
|
||||
"success": "green",
|
||||
"failure": "red",
|
||||
"status": "light_green",
|
||||
"code": "light_blue",
|
||||
"warning": "yello",
|
||||
"output": "cyan",
|
||||
"default": "black"
|
||||
}
|
||||
if color not in color_map:
|
||||
color = "default"
|
||||
print(colored(text, color_map[color]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user