mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
Upgraded
This commit is contained in:
parent
c8162fc448
commit
1108db7281
@ -37,7 +37,7 @@ import requests
|
||||
from datetime import datetime
|
||||
from typing import List, Tuple
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from lollms.utilities import find_first_available_file_index
|
||||
|
||||
if not PackageManager.check_package_installed("requests"):
|
||||
@ -623,6 +623,7 @@ class LoLLMsAPI(LollmsApplication):
|
||||
|
||||
@socketio.on('new_discussion')
|
||||
def new_discussion(data):
|
||||
ASCIIColors.yellow("New descussion requested")
|
||||
client_id = request.sid
|
||||
title = data["title"]
|
||||
if self.connections[client_id]["current_discussion"] is not None:
|
||||
@ -1186,6 +1187,13 @@ class LoLLMsAPI(LollmsApplication):
|
||||
selected_language=personality.split(":")[1] if ":" in personality else None,
|
||||
run_scripts=True)
|
||||
mounted_personalities.append(personality)
|
||||
if self.config.auto_read and len(self.personality.audio_samples)>0:
|
||||
try:
|
||||
from lollms.audio_gen_modules.lollms_xtts import LollmsXTTS
|
||||
if self.tts is None:
|
||||
self.tts = LollmsXTTS(self, voice_samples_path=Path(self.personality.audio_samples[0]).parent)
|
||||
except:
|
||||
self.warning(f"Personality {personality.name} request using custom voice but couldn't load XTTS")
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(f"Personality file not found or is corrupted ({personality_path}).\nReturned the following exception:{ex}\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.")
|
||||
ASCIIColors.info("Trying to force reinstall")
|
||||
@ -2049,6 +2057,55 @@ class LoLLMsAPI(LollmsApplication):
|
||||
client_id=client_id,
|
||||
callback=partial(self.process_chunk,client_id = client_id)
|
||||
)
|
||||
if self.config.auto_read and len(self.personality.audio_samples)>0:
|
||||
try:
|
||||
from lollms.audio_gen_modules.lollms_xtts import LollmsXTTS
|
||||
if self.tts is None:
|
||||
self.tts = LollmsXTTS(self, voice_samples_path=Path(self.personality.audio_samples[0]).parent)
|
||||
self.tts.set_speaker_folder(Path(self.personality.audio_samples[0]).parent)
|
||||
fn = self.personality.name.lower().replace(' ',"_").replace('.','')
|
||||
fn = f"{fn}_{message_id}.wav"
|
||||
url = f"audio/{fn}"
|
||||
self.tts.tts_to_file(self.connections[client_id]["generated_text"], Path(self.personality.audio_samples[0]).name, f"{fn}", language="en")
|
||||
fl = f"""
|
||||
<audio controls autoplay>
|
||||
<source src="{url}" type="audio/wav">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
"""
|
||||
self.process_chunk(fl,MSG_TYPE.MSG_TYPE_CHUNK,client_id=client_id)
|
||||
|
||||
"""
|
||||
self.info("Creating audio output",10)
|
||||
self.personality.step_start("Creating audio output")
|
||||
if not PackageManager.check_package_installed("tortoise"):
|
||||
PackageManager.install_package("tortoise-tts")
|
||||
from tortoise import utils, api
|
||||
import sounddevice as sd
|
||||
if self.tts is None:
|
||||
self.tts = api.TextToSpeech( kv_cache=True, half=True)
|
||||
reference_clips = [utils.audio.load_audio(str(p), 22050) for p in self.personality.audio_samples]
|
||||
tk = self.model.tokenize(self.connections[client_id]["generated_text"])
|
||||
if len(tk)>100:
|
||||
chunk_size = 100
|
||||
|
||||
for i in range(0, len(tk), chunk_size):
|
||||
chunk = self.model.detokenize(tk[i:i+chunk_size])
|
||||
if i==0:
|
||||
pcm_audio = self.tts.tts_with_preset(chunk, voice_samples=reference_clips, preset='fast').numpy().flatten()
|
||||
else:
|
||||
pcm_audio = np.concatenate([pcm_audio, self.tts.tts_with_preset(chunk, voice_samples=reference_clips, preset='ultra_fast').numpy().flatten()])
|
||||
else:
|
||||
pcm_audio = self.tts.tts_with_preset(self.connections[client_id]["generated_text"], voice_samples=reference_clips, preset='fast').numpy().flatten()
|
||||
sd.play(pcm_audio, 22050)
|
||||
self.personality.step_end("Creating audio output")
|
||||
"""
|
||||
|
||||
|
||||
|
||||
except Exception as ex:
|
||||
ASCIIColors.error("Couldn't read")
|
||||
trace_exception(ex)
|
||||
print()
|
||||
ASCIIColors.success("## Done Generation ##")
|
||||
print()
|
||||
|
14
app.py
14
app.py
@ -361,6 +361,7 @@ try:
|
||||
self.add_endpoint("/<path:filename>", "serve_static", self.serve_static, methods=["GET"])
|
||||
self.add_endpoint("/user_infos/<path:filename>", "serve_user_infos", self.serve_user_infos, methods=["GET"])
|
||||
|
||||
self.add_endpoint("/audio/<path:filename>", "serve_audio", self.serve_audio, methods=["GET"])
|
||||
self.add_endpoint("/images/<path:filename>", "serve_images", self.serve_images, methods=["GET"])
|
||||
self.add_endpoint("/extensions/<path:filename>", "serve_extensions", self.serve_extensions, methods=["GET"])
|
||||
self.add_endpoint("/bindings/<path:filename>", "serve_bindings", self.serve_bindings, methods=["GET"])
|
||||
@ -922,6 +923,8 @@ try:
|
||||
except Exception as ex:
|
||||
ASCIIColors.warning(f"Couldn't load personality from {personality_folder} [{ex}]")
|
||||
trace_exception(ex)
|
||||
ASCIIColors.green("OK")
|
||||
|
||||
return json.dumps(personalities)
|
||||
|
||||
def get_personality(self):
|
||||
@ -1438,6 +1441,15 @@ try:
|
||||
|
||||
fn = filename.split("/")[-1]
|
||||
return send_from_directory(path, fn)
|
||||
|
||||
def serve_audio(self, filename):
|
||||
root_dir = self.lollms_paths.personal_outputs_path
|
||||
path = os.path.join(root_dir, 'audio_out/')+"/".join(filename.split("/")[:-1])
|
||||
|
||||
fn = filename.split("/")[-1]
|
||||
return send_from_directory(path, fn)
|
||||
|
||||
|
||||
|
||||
def serve_extensions(self, filename):
|
||||
path = str(self.lollms_paths.extensions_zoo_path/("/".join(filename.split("/")[:-1])))
|
||||
@ -1990,7 +2002,7 @@ try:
|
||||
name = data['folder']
|
||||
language = data.get('language',None)
|
||||
try:
|
||||
personality_id = f"{category}/{name}" if language is None else f"{category}/{name}:{language}"
|
||||
personality_id = f"{category}/{name}" if language is None or language=="" else f"{category}/{name}:{language}"
|
||||
index = self.config["personalities"].index(personality_id)
|
||||
self.config["personalities"].remove(personality_id)
|
||||
if self.config["active_personality_id"]>=index:
|
||||
|
@ -1,5 +1,5 @@
|
||||
# =================== Lord Of Large Language Models Configuration file ===========================
|
||||
version: 30
|
||||
version: 31
|
||||
binding_name: null
|
||||
model_name: null
|
||||
|
||||
@ -53,6 +53,7 @@ auto_show_browser: true
|
||||
audio_in_language: 'en-US'
|
||||
audio_out_voice: null
|
||||
auto_speak: false
|
||||
auto_read: false
|
||||
audio_pitch: 1
|
||||
audio_auto_send_input: true
|
||||
audio_silenceTimer: 5000
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 64c54b45933e6155ecc3796fbe55f8893d5f8c96
|
||||
Subproject commit 202b6dc0484fe3da36a729268a544e5af33c7d9f
|
@ -725,6 +725,23 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="auto_read" class="text-sm font-bold" style="margin-right: 1rem;">Enable auto read:</label>
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="auto_read"
|
||||
required
|
||||
v-model="configFile.auto_read"
|
||||
@change="settingsChanged=true"
|
||||
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="audio_pitch" class="text-sm font-bold" style="margin-right: 1rem;">audio pitch:</label>
|
||||
</td>
|
||||
@ -1936,6 +1953,7 @@ export default {
|
||||
// Fetch available voices from the SpeechSynthesis API
|
||||
if ('speechSynthesis' in window) {
|
||||
this.audioVoices = speechSynthesis.getVoices();
|
||||
console.log("Voices:"+this.audioVoices)
|
||||
if (!this.audio_out_voice && this.audioVoices.length > 0) {
|
||||
this.audio_out_voice = this.audioVoices[0].name;
|
||||
}
|
||||
@ -3898,6 +3916,15 @@ export default {
|
||||
this.$store.state.config.auto_speak = value
|
||||
},
|
||||
},
|
||||
auto_read:{
|
||||
get() {
|
||||
return this.$store.state.config.auto_read;
|
||||
},
|
||||
set(value) {
|
||||
// You should not set the value directly here; use the updateSetting method instead
|
||||
this.$store.state.config.auto_read = value
|
||||
},
|
||||
},
|
||||
audio_pitch:{
|
||||
get() {
|
||||
return this.$store.state.config.audio_pitch;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1cc5ce3cc0b2821438def4509acfaef98189bc89
|
||||
Subproject commit 0c7551d80f34fce89144d8913ff862c9d03261e3
|
Loading…
Reference in New Issue
Block a user