This commit is contained in:
Saifeddine ALOUI 2024-01-29 22:21:45 +01:00
parent faba2b4eb8
commit 8966acc147
3 changed files with 18 additions and 27 deletions

View File

@ -40,7 +40,12 @@ def add_events(sio:socketio):
@sio.on('start_webcam_video_stream')
def start_webcam_video_stream(sid):
lollmsElfServer.info("Starting video capture")
lollmsElfServer.webcam.start_capture()
try:
from lollms.media import WebcamImageSender
lollmsElfServer.webcam = WebcamImageSender(sio,lollmsCom=lollmsElfServer)
lollmsElfServer.webcam.start_capture()
except:
lollmsElfServer.InfoMessage("Couldn't load media library.\nYou will not be able to perform any of the media linked operations. please verify the logs and install any required installations")
@sio.on('stop_webcam_video_stream')
def stop_webcam_video_stream(sid):
@ -50,7 +55,16 @@ def add_events(sio:socketio):
@sio.on('start_audio_stream')
def start_audio_stream(sid):
lollmsElfServer.info("Starting audio capture")
lollmsElfServer.audio_cap.start_recording()
try:
from lollms.media import AudioRecorder
lollmsElfServer.rec_output_folder = lollmsElfServer.lollms_paths.personal_outputs_path/"audio_rec"
lollmsElfServer.rec_output_folder.mkdir(exist_ok=True, parents=True)
lollmsElfServer.summoned = False
lollmsElfServer.audio_cap = AudioRecorder(sio,lollmsElfServer.rec_output_folder/"rt.wav", callback=lollmsElfServer.audio_callback,lollmsCom=lollmsElfServer)
lollmsElfServer.audio_cap.start_recording()
except:
lollmsElfServer.InfoMessage("Couldn't load media library.\nYou will not be able to perform any of the media linked operations. please verify the logs and install any required installations")
@sio.on('stop_audio_stream')
def stop_audio_stream(sid):

@ -1 +1 @@
Subproject commit 395b6243ba2bc6aa962c9eb9ceb7385921d9bb83
Subproject commit 3ecb4cfcf0d22eacef551d741ded6b7efcb57ff8

View File

@ -26,12 +26,7 @@ from lollms.generation import RECPTION_MANAGER, ROLE_CHANGE_DECISION, ROLE_CHANG
import git
import asyncio
import os
try:
from lollms.media import WebcamImageSender, AudioRecorder
Media_on=True
except:
ASCIIColors.warning("Couldn't load media library.\nYou will not be able to perform any of the media linked operations. please verify the logs and install any required installations")
Media_on=False
from safe_store import TextVectorizer, VectorizationMethod, VisualizationMethod
import threading
@ -205,24 +200,6 @@ class LOLLMSWebUI(LOLLMSElfServer):
"reception_manager": RECPTION_MANAGER()
}
}
if Media_on:
try:
self.webcam = WebcamImageSender(sio,lollmsCom=self)
except:
self.webcam = None
try:
self.rec_output_folder = lollms_paths.personal_outputs_path/"audio_rec"
self.rec_output_folder.mkdir(exist_ok=True, parents=True)
self.summoned = False
self.audio_cap = AudioRecorder(sio,self.rec_output_folder/"rt.wav", callback=self.audio_callback,lollmsCom=self)
except:
self.audio_cap = None
self.rec_output_folder = None
else:
self.webcam = None
self.rec_output_folder = None
# Define a WebSocket event handler
@sio.event