diff --git a/lollms/server/endpoints/lollms_xtts.py b/lollms/server/endpoints/lollms_xtts.py index 9dae008..e2f7e3e 100644 --- a/lollms/server/endpoints/lollms_xtts.py +++ b/lollms/server/endpoints/lollms_xtts.py @@ -122,8 +122,11 @@ async def text2Audio(request: LollmsText2AudioRequest): lollmsElfServer.tts.set_speaker_folder(voices_folder) url = f"audio/{output_fn}" preprocessed_text= add_period(request.text) + voice_file = [v for v in voices_folder.iterdir() if v.stem==voice] + if len(voice_file)==0: + return {"status":False,"error":"Voice not found"} - lollmsElfServer.tts.tts_to_file(preprocessed_text, f"{voice}.wav", f"{output_fn}", language=language) + lollmsElfServer.tts.tts_to_file(preprocessed_text, voice_file[0].name, f"{output_fn}", language=language) lollmsElfServer.info(f"Voice file ready at {url}") return {"url": url} except Exception as ex: @@ -171,14 +174,14 @@ def start_xtts(): @router.post("/upload_voice/") async def upload_voice_file(file: UploadFile = File(...)): - allowed_extensions = {'wav', 'mp3'} + allowed_extensions = {'wav'} # Use Pathlib to handle the filename file_path = Path(file.filename) file_extension = file_path.suffix[1:].lower() if file_extension not in allowed_extensions: - return {"message": "Invalid file type. Only .wav and .mp3 files are allowed."} + return {"message": "Invalid file type. Only .wav files are allowed."} # Check for path traversal attempts if file_path.is_absolute() or any(part == '..' for part in file_path.parts): @@ -190,5 +193,8 @@ async def upload_voice_file(file: UploadFile = File(...)): safe_file_path = lollmsElfServer.lollms_paths.custom_voices_path/safe_filename with safe_file_path.open("wb") as f: f.write(contents) + lollmsElfServer.config.current_voice=safe_filename + if lollmsElfServer.config.auto_save: + lollmsElfServer.config.save_config() return {"message": f"Successfully uploaded {safe_filename}"} \ No newline at end of file diff --git a/lollms/utilities.py b/lollms/utilities.py index 4be511d..9537818 100644 --- a/lollms/utilities.py +++ b/lollms/utilities.py @@ -678,7 +678,7 @@ def reinstall_pytorch_with_cuda(): except Exception as ex: ASCIIColors.error(ex) try: - ASCIIColors.info("Installing pytorch 2.1.1") + ASCIIColors.info("Installing pytorch 2.2.1") result = subprocess.run([sys.executable, "-m", "pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir", "--index-url", "https://download.pytorch.org/whl/cu121"]) except Exception as ex: ASCIIColors.error(ex) @@ -714,7 +714,7 @@ def reinstall_pytorch_with_cpu(): ASCIIColors.error("Pytorch installed successfully!!") -def check_and_install_torch(enable_gpu:bool, version:float=2.1): +def check_and_install_torch(enable_gpu:bool, version:float=2.2): if enable_gpu: ASCIIColors.yellow("This installation has enabled GPU support. Trying to install with GPU support") ASCIIColors.info("Checking pytorch")