mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-21 05:33:12 +00:00
upgraded
This commit is contained in:
parent
32789a26af
commit
15dceb83bb
@ -47,6 +47,7 @@ def open_and_fill_udio(song_description: str, lyrics: str) -> str:
|
||||
# Start generation
|
||||
pyautogui.click(x=1660, y=120)
|
||||
|
||||
pyautogui.click(x=500, y=120)
|
||||
return "Successfully filled the song description and lyrics."
|
||||
except Exception as e:
|
||||
return trace_exception(e)
|
||||
@ -57,8 +58,8 @@ def open_and_fill_udio_function():
|
||||
"function": open_and_fill_udio,
|
||||
"function_description": "Opens udio.com page and fills in the song description and lyrics fields to start generating the music.",
|
||||
"function_parameters": [
|
||||
{"name": "song_description", "type": "str"},
|
||||
{"name": "lyrics", "type": "str"}
|
||||
{"name": "song_description", "type": "str", "description":"a list of tags describing the song style and vibes. Make it short"},
|
||||
{"name": "lyrics", "type": "str","description":"The lyrics of the song"}
|
||||
]
|
||||
}
|
||||
|
||||
|
0
lollms/functions/youtube/__init__.py
Normal file
0
lollms/functions/youtube/__init__.py
Normal file
82
lollms/functions/youtube/search_and_show.py
Normal file
82
lollms/functions/youtube/search_and_show.py
Normal file
@ -0,0 +1,82 @@
|
||||
# Lollms function call definition file
|
||||
|
||||
# Partial is useful if we need to preset some parameters
|
||||
from functools import partial
|
||||
|
||||
# It is advised to import typing elements
|
||||
from typing import List
|
||||
|
||||
# Import PackageManager if there are potential libraries that need to be installed
|
||||
from lollms.utilities import PackageManager
|
||||
|
||||
# ascii_colors offers advanced console coloring and bug tracing
|
||||
from ascii_colors import trace_exception
|
||||
|
||||
# Here is an example of how we install a non installed library using PackageManager
|
||||
if not PackageManager.check_package_installed("pyautogui"):
|
||||
PackageManager.install_package("pyautogui")
|
||||
if not PackageManager.check_package_installed("webbrowser"):
|
||||
PackageManager.install_package("webbrowser")
|
||||
if not PackageManager.check_package_installed("time"):
|
||||
PackageManager.install_package("time")
|
||||
if not PackageManager.check_package_installed("os"):
|
||||
PackageManager.install_package("os")
|
||||
|
||||
# now we can import the libraries
|
||||
import pyautogui
|
||||
import webbrowser
|
||||
import time
|
||||
import os
|
||||
|
||||
# Function to open YouTube, search for a specific video, and play the first one
|
||||
def search_youtube_and_play(video_title: str = "lollms paris neo") -> str:
|
||||
"""
|
||||
Opens YouTube, searches for a specific video, and plays the first one in the list.
|
||||
|
||||
Parameters:
|
||||
video_title (str): The title of the video to search for.
|
||||
|
||||
Returns:
|
||||
str: Success or error message.
|
||||
"""
|
||||
try:
|
||||
# Open YouTube
|
||||
webbrowser.open("https://www.youtube.com")
|
||||
time.sleep(5) # Wait for the browser to open YouTube
|
||||
|
||||
# Click on the search bar (searching for the element named 'search_query')
|
||||
script_dir = os.path.dirname(__file__)
|
||||
search_query_path = os.path.join(script_dir, 'search_query.png')
|
||||
search_bar_position = pyautogui.locateCenterOnScreen(search_query_path, confidence=0.8)
|
||||
if search_bar_position:
|
||||
pyautogui.click(search_bar_position)
|
||||
else:
|
||||
return "Search bar not found on the screen."
|
||||
|
||||
# Type the video title and press Enter
|
||||
pyautogui.write(video_title, interval=0.1)
|
||||
pyautogui.press('enter')
|
||||
time.sleep(5) # Wait for the search results to load
|
||||
|
||||
# Click on the first video in the search results (assuming it's in a consistent position)
|
||||
pyautogui.click(500, 400) # Adjust the coordinates as needed
|
||||
return "Video is playing."
|
||||
|
||||
except Exception as e:
|
||||
return trace_exception(e)
|
||||
|
||||
|
||||
# Metadata function
|
||||
def search_youtube_and_play_function():
|
||||
return {
|
||||
"function_name": "search_youtube_and_play", # The function name in string
|
||||
"function": search_youtube_and_play, # The function to be called
|
||||
"function_description": "Opens YouTube, searches for a specific video, and plays the first one in the list.", # Description
|
||||
"function_parameters": [{"name": "video_title", "type": "str"}] # Parameters
|
||||
}
|
||||
|
||||
# Add the if __name__ statement for testing
|
||||
if __name__ == "__main__":
|
||||
video_title = "lollms paris neo"
|
||||
result = search_youtube_and_play(video_title)
|
||||
print(result)
|
BIN
lollms/functions/youtube/search_query.png
Normal file
BIN
lollms/functions/youtube/search_query.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -437,7 +437,7 @@ class RTCom:
|
||||
ASCIIColors.red(" -------------------------------------------------")
|
||||
self.lc.info("Talking")
|
||||
ASCIIColors.green("<<TALKING>>")
|
||||
self.lc.tts.tts_audio(lollms_text, file_name_or_path=str(Path(self.logs_folder)/filename)+"_answer.wav")
|
||||
self.lc.tts.tts_audio(lollms_text, file_name_or_path=str(Path(self.logs_folder)/filename)+"_answer.wav", use_threading=True)
|
||||
except Exception as ex:
|
||||
trace_exception(ex)
|
||||
self.block_listening = False
|
||||
|
@ -134,7 +134,7 @@ async def text2Audio(request: LollmsText2AudioRequest):
|
||||
if lollmsElfServer.tts is None:
|
||||
return {"url": None, "error":f"No TTS service is on"}
|
||||
if lollmsElfServer.tts.ready:
|
||||
response = lollmsElfServer.tts.tts_audio(request.text, request.voice, file_name_or_path=request.fn)
|
||||
response = lollmsElfServer.tts.tts_audio(request.text, request.voice, file_name_or_path=request.fn, use_threading=True)
|
||||
return response
|
||||
else:
|
||||
return {"url": None, "error":f"TTS service is not ready yet"}
|
||||
|
@ -37,8 +37,11 @@ def add_events(sio:socketio):
|
||||
#kill thread
|
||||
ASCIIColors.error(f'Client {sid} requested cancelling generation')
|
||||
terminate_thread(client.generation_thread)
|
||||
ASCIIColors.error(f'Client {sid} canceled generation')
|
||||
lollmsElfServer.busy=False
|
||||
if lollmsElfServer.tts:
|
||||
lollmsElfServer.tts.stop()
|
||||
|
||||
ASCIIColors.error(f'Client {sid} canceled generation')
|
||||
|
||||
|
||||
@sio.on('cancel_text_generation')
|
||||
|
@ -74,9 +74,8 @@ def install_diffusers(lollms_app:LollmsApplication):
|
||||
shared_folder = root_dir/"shared"
|
||||
diffusers_folder = shared_folder / "diffusers"
|
||||
diffusers_folder.mkdir(exist_ok=True, parents=True)
|
||||
if not PackageManager.check_package_installed("diffusers"):
|
||||
PackageManager.install_or_update("diffusers")
|
||||
PackageManager.install_or_update("xformers")
|
||||
PackageManager.reinstall("diffusers")
|
||||
PackageManager.reinstall("xformers")
|
||||
|
||||
|
||||
|
||||
|
@ -367,12 +367,31 @@ class LollmsXTTS(LollmsTTS):
|
||||
thread_uid = str(uuid.uuid4())
|
||||
thread = threading.Thread(target=tts2_audio_th, args=(thread_uid,))
|
||||
self.generation_threads[thread_uid]=thread
|
||||
self.thread = thread
|
||||
thread.start()
|
||||
ASCIIColors.green("Generation started")
|
||||
return thread
|
||||
else:
|
||||
return tts2_audio_th()
|
||||
|
||||
def stop(self):
|
||||
url = f"{self.xtts_base_url}/stop_streaming"
|
||||
|
||||
# Define the request body
|
||||
payload = {
|
||||
}
|
||||
headers = {
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
# Send the POST request
|
||||
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
||||
|
||||
if response.status_code == 200:
|
||||
print("Request successful")
|
||||
|
||||
|
||||
def get_voices(self):
|
||||
ASCIIColors.yellow("Listing voices")
|
||||
voices=["main_voice"]
|
||||
|
@ -1048,6 +1048,48 @@ class PackageManager:
|
||||
print(f"{package} is not installed. Time to add it to your collection!")
|
||||
return PackageManager.install_package(package)
|
||||
|
||||
@staticmethod
|
||||
def uninstall_package(package):
|
||||
"""
|
||||
Uninstall a Python package.
|
||||
|
||||
Args:
|
||||
package (str): The name of the package to uninstall.
|
||||
|
||||
Returns:
|
||||
bool: True if the package was uninstalled successfully, False otherwise.
|
||||
"""
|
||||
try:
|
||||
subprocess.run([sys.executable, "-m", "pip", "uninstall", "-y", package], check=True)
|
||||
print(f"Successfully uninstalled {package}. Goodbye, old friend!")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error uninstalling {package}: {e}. Uninstallation wizard failed!")
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def reinstall(package):
|
||||
"""
|
||||
Reinstall a Python package.
|
||||
|
||||
Args:
|
||||
package (str): The name of the package to reinstall.
|
||||
|
||||
Returns:
|
||||
bool: True if the package was reinstalled successfully, False otherwise.
|
||||
"""
|
||||
if PackageManager.check_package_installed(package):
|
||||
print(f"{package} is already installed. Let's give it a fresh start!")
|
||||
if PackageManager.uninstall_package(package):
|
||||
print(f"{package} uninstalled successfully. Now, let's reinstall it.")
|
||||
return PackageManager.install_package(package)
|
||||
else:
|
||||
print(f"Failed to uninstall {package}. Reinstallation aborted.")
|
||||
return False
|
||||
else:
|
||||
print(f"{package} is not installed. Installing it now.")
|
||||
return PackageManager.install_package(package)
|
||||
|
||||
class GitManager:
|
||||
@staticmethod
|
||||
def git_pull(folder_path):
|
||||
|
Loading…
Reference in New Issue
Block a user