This commit is contained in:
Saifeddine ALOUI 2024-05-20 11:29:27 +02:00
parent 6f45b1ca82
commit b6530a6403
3 changed files with 23 additions and 23 deletions

View File

@ -71,6 +71,20 @@ class LollmsApplication(LoLLMsCom):
self.generate_msg_with_internet: Callable[[str, Dict], None] = None
self.handle_continue_generate_msg_from: Callable[[str, Dict], None] = None
# services
self.ollama = None
self.vllm = None
self.whisper = None
self.xtts = None
self.sd = None
self.comfyui = None
self.motion_ctrl = None
self.tti = None
self.tts = None
self.stt = None
self.rt_com = None
if not free_mode:
try:
@ -228,17 +242,7 @@ class LollmsApplication(LoLLMsCom):
return self.lollms_paths.personal_uploads_path
def start_servers(self):
self.ollama = None
self.vllm = None
self.whisper = None
self.xtts = None
self.sd = None
self.comfyui = None
self.motion_ctrl = None
self.tti = None
self.tts = None
self.stt = None

View File

@ -41,6 +41,11 @@ class LoLLMsCom:
def __init__(self, sio:socketio.AsyncServer=None, verbose:bool=False) -> None:
self.sio= sio
self.verbose = verbose
self.tti = None
self.tts = None
self.stt = None
self.rt_com = None
def InfoMessage(self, content, client_id=None, verbose:bool=None):

View File

@ -644,7 +644,6 @@ class Discussion:
self.discussion_rag_folder.mkdir(exist_ok=True)
self.discussion_view_images_folder.mkdir(exist_ok=True)
self.messages = self.get_messages()
self.whisper= None
if len(self.messages)>0:
self.current_message = self.messages[-1]
@ -731,22 +730,14 @@ class Discussion:
self.audio_files.append(path)
if process:
self.lollms.new_message(client.client_id if client is not None else 0, content = "", message_type = MSG_TYPE.MSG_TYPE_FULL)
if self.lollms.stt is None:
self.lollms.info("Please select an stt engine in the services settings first")
self.lollms.info(f"Transcribing ... ")
if self.whisper is None:
if not PackageManager.check_package_installed("whisper"):
PackageManager.install_package("openai-whisper")
try:
import conda.cli
conda.cli.main("install", "conda-forge::ffmpeg", "-y")
except:
ASCIIColors.bright_red("Couldn't install ffmpeg. whisper won't work. Please install it manually")
import whisper
self.whisper = whisper.load_model("base")
result = self.whisper.transcribe(str(path))
result = self.lollms.stt.transcribe(str(path))
transcription_fn = str(path)+".txt"
with open(transcription_fn, "w", encoding="utf-8") as f:
f.write(result["text"])
self.text_files.append(transcription_fn)
tasks_library.info(f"Transcription saved to {transcription_fn}")
elif path.suffix in [".png",".jpg",".jpeg",".gif",".bmp",".svg",".webp"]: