fixed whisper install

This commit is contained in:
Saifeddine ALOUI 2024-05-20 21:52:35 +02:00
parent 3741be3f3a
commit 939d80ddd1
2 changed files with 22 additions and 1 deletions

View File

@ -7,7 +7,7 @@ from pathlib import Path
from lollms.app import LollmsApplication from lollms.app import LollmsApplication
from lollms.paths import LollmsPaths from lollms.paths import LollmsPaths
from lollms.config import TypedConfig, ConfigTemplate, BaseConfig from lollms.config import TypedConfig, ConfigTemplate, BaseConfig
from lollms.utilities import PackageManager from lollms.utilities import PackageManager, install_conda_package
from lollms.stt import LollmsSTT from lollms.stt import LollmsSTT
from dataclasses import dataclass from dataclasses import dataclass
from PIL import Image, PngImagePlugin from PIL import Image, PngImagePlugin
@ -19,6 +19,7 @@ from lollms.paths import LollmsPaths
import subprocess import subprocess
if not PackageManager.check_package_installed("whisper"): if not PackageManager.check_package_installed("whisper"):
install_conda_package("ffmpeg")
PackageManager.install_package("whisper") PackageManager.install_package("whisper")
import whisper import whisper

View File

@ -56,6 +56,26 @@ def install_conda_utility():
# Create a new Conda environment with the specified Python version # Create a new Conda environment with the specified Python version
#run_command(Commands.CREATE, "-n", env_name, f"python={python_version}") #run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
def install_conda_package(package_name):
try:
import platform
if platform.system()=="Windows":
conda_path = Path(sys.executable).parent.parent/"miniconda3"/"condabin"/"conda"
else:
conda_path = Path(sys.executable).parent.parent.parent/"miniconda3"/"bin"/"conda"
ASCIIColors.red("Conda path:")
ASCIIColors.yellow(conda_path)
process = subprocess.Popen(f'{conda_path} install {package_name} -y', shell=True)
# Wait for the process to finish
process.wait()
#from conda.cli.python_api import run_command, Commands
# Create a new Conda environment with the specified Python version
#run_command(Commands.CREATE, "-n", env_name, f"python={python_version}")
return True
except Exception as ex:
trace_exception(ex)
return False
def create_conda_env(env_name, python_version): def create_conda_env(env_name, python_version):
from lollms.security import sanitize_shell_code from lollms.security import sanitize_shell_code