upgraded ui

This commit is contained in:
Saifeddine ALOUI 2024-02-03 19:04:43 +01:00
parent 3bc72bc33a
commit 75329b7b6e
9 changed files with 310 additions and 212 deletions

View File

@ -208,4 +208,25 @@ async def open_code_folder(request: Request):
except Exception as ex:
trace_exception(ex)
lollmsElfServer.error(ex)
return {"status":False,"error":str(ex)}
return {"status":False,"error":str(ex)}
@router.get("/start_recording")
def start_recording():
lollmsElfServer.info("Starting audio capture")
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(lollmsElfServer.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")
@router.get("/stop_recording")
def stop_recording():
lollmsElfServer.info("Stopping audio capture")
text = lollmsElfServer.audio_cap.stop_recording()
return text

@ -1 +1 @@
Subproject commit 9f196227fdf551ed6383fd980233dfbf4fc58ee8
Subproject commit a2a1252fdaf042ab5ae6a409f15e226ffdc0e3d9

File diff suppressed because one or more lines are too long

44
web/dist/assets/rec_off-fb27b641.svg vendored Normal file
View File

@ -0,0 +1,44 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="794.000000pt" height="596.000000pt" viewBox="0 0 794.000000 596.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,596.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M505 4469 c-43 -12 -102 -64 -128 -112 -21 -41 -22 -52 -25 -419 -3
-338 -1 -381 14 -413 33 -70 128 -88 186 -36 l33 29 3 361 3 360 354 3 c342 3
355 4 382 24 34 26 58 83 49 120 -4 15 -22 42 -41 61 l-33 33 -384 -1 c-210 0
-396 -5 -413 -10z"/>
<path d="M6606 4449 c-45 -39 -55 -84 -30 -136 35 -71 44 -73 431 -73 l342 0
3 -361 3 -361 33 -29 c58 -52 153 -34 186 36 15 32 17 75 14 413 -3 367 -4
378 -25 419 -27 50 -86 100 -133 113 -20 6 -198 10 -412 10 l-377 0 -35 -31z"/>
<path d="M1631 3719 c-278 -54 -497 -253 -582 -529 -31 -98 -34 -299 -6 -400
40 -149 130 -291 243 -384 132 -109 274 -164 444 -173 351 -18 654 194 760
532 34 107 39 276 11 385 -40 164 -133 312 -256 413 -77 64 -219 131 -317 151
-82 17 -225 19 -297 5z"/>
<path d="M5921 3719 c-270 -53 -462 -246 -525 -529 -50 -221 -16 -475 85 -647
19 -32 66 -89 104 -128 125 -126 285 -185 502 -185 314 0 543 154 618 413 26
90 29 88 -146 85 l-151 -3 -19 -49 c-21 -56 -77 -119 -129 -146 -84 -43 -229
-50 -330 -15 -104 36 -187 128 -231 255 -19 54 -23 87 -23 200 -1 147 9 198
55 290 75 151 237 228 417 200 120 -20 202 -83 242 -188 l18 -47 156 -3 c175
-3 164 -9 141 78 -56 211 -221 365 -442 414 -78 17 -266 20 -342 5z"/>
<path d="M2975 3698 c-3 -7 -4 -335 -3 -728 l3 -715 143 -3 142 -3 0 281 0
280 98 0 98 0 131 -277 130 -278 161 -3 c140 -2 162 0 162 13 0 8 -63 141
-140 295 -77 154 -140 283 -140 287 0 5 25 21 55 36 246 129 289 498 81 695
-67 63 -137 97 -241 117 -103 20 -673 22 -680 3z m650 -260 c67 -36 105 -102
105 -183 0 -94 -39 -161 -115 -196 -33 -16 -66 -19 -197 -19 l-158 0 0 211 0
211 168 -4 c130 -3 174 -7 197 -20z"/>
<path d="M4245 3698 c-3 -7 -4 -335 -3 -728 l3 -715 478 -3 477 -2 0 120 0
120 -335 0 -335 0 0 190 0 190 303 2 302 3 0 115 0 115 -302 3 -303 2 0 180 0
180 335 0 335 0 0 120 0 120 -475 0 c-371 0 -477 -3 -480 -12z"/>
<path d="M409 2485 c-15 -8 -34 -30 -43 -50 -15 -32 -17 -75 -14 -413 3 -367
4 -378 25 -419 27 -51 82 -96 132 -112 26 -7 162 -11 414 -11 l376 0 35 31
c45 39 55 84 30 136 -35 71 -44 73 -431 73 l-342 0 -3 361 -3 361 -33 29 c-37
33 -97 39 -143 14z"/>
<path d="M7388 2471 l-33 -29 -3 -361 -3 -361 -342 0 c-387 0 -396 -2 -431
-73 -25 -52 -15 -97 30 -136 l35 -31 376 0 c252 0 388 4 414 11 50 16 105 61
132 112 21 41 22 52 25 419 3 338 1 381 -14 413 -33 70 -128 88 -186 36z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

9
web/dist/assets/rec_on-78d31957.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 45 KiB

2
web/dist/index.html vendored
View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-3ef4a164.js"></script>
<script type="module" crossorigin src="/assets/index-14ba940c.js"></script>
<link rel="stylesheet" href="/assets/index-3f9023f9.css">
</head>
<body>

View File

@ -31,16 +31,13 @@ export default {
},
methods: {
startAudioStream() {
this.isAudioActive = true;
socket.emit('start_audio_stream');
socket.emit('start_audio_stream', ()=>{this.isAudioActive = true;});
nextTick(() => {
feather.replace()
})
},
stopAudioStream() {
this.isAudioActive = false;
this.imageDataUrl = null;
socket.emit('stop_audio_stream');
socket.emit('stop_audio_stream', ()=>{this.isAudioActive = false;this.imageDataUrl = null});
nextTick(() => {
feather.replace()
})

View File

@ -21,7 +21,7 @@
:class="{ 'text-green-500': isLesteningToVoice }"
class="w-6 hover:text-secondary duration-75 active:scale-90 cursor-pointer text-red-500"
>
<i data-feather="mic"></i>
<img :src="is_recording?rec_on:rec_off" height="25">
</button>
<button
title="speak"
@ -229,6 +229,9 @@ import html5_block from '@/assets/html5_block.png';
import LaTeX_block from '@/assets/LaTeX_block.png';
import bash_block from '@/assets/bash_block.png';
import rec_on from '@/assets/rec_on.svg';
import rec_off from '@/assets/rec_off.svg';
async function showInputPanel(name, default_value="", options=[]) {
return new Promise((resolve, reject) => {
@ -378,6 +381,8 @@ export default {
data() {
return {
is_recording:false,
cpp_block:cpp_block,
html5_block:html5_block,
LaTeX_block:LaTeX_block,
@ -386,6 +391,9 @@ export default {
python_block:python_block,
bash_block:bash_block,
rec_off:rec_off,
rec_on:rec_on,
isSynthesizingVoice:false,
audio_url:null,
mdRenderHeight:300,
@ -469,6 +477,8 @@ export default {
console.log("Generation canceled OK")
});
//console.log('chatbox mnt',this.$refs)
this.$nextTick(() => {
feather.replace();
@ -818,13 +828,30 @@ export default {
});
},
startRecording(){
axios.get('./start_audio_stream').then(response => {
if(!this.is_recording){
axios.get('/start_recording').then(response => {
this.is_recording = true;
console.log(response.data)
this.presets=response.data
this.selectedPreset = this.presets[0]
}).catch(ex=>{
this.$refs.toast.showToast(`Error: ${ex}`,4,false)
});
}
else{
axios.get('/stop_recording').then(response => {
this.is_recording = false;
console.log(response)
this.text += response.data
console.log(response.data)
this.presets=response.data
this.selectedPreset = this.presets[0]
}).catch(ex=>{
this.$refs.toast.showToast(`Error: ${ex}`,4,false)
});
}
},
startSpeechRecognition() {

@ -1 +1 @@
Subproject commit 4c60b1338b510363379341f1b039f630668c4b3d
Subproject commit 49d29334590f956eec08eee7730c3c18859f37f3