From 4f3100d5888e22d44337e04c69fa2b284e2d982f Mon Sep 17 00:00:00 2001 From: SugarcaneDefender Date: Wed, 23 Oct 2024 15:42:26 -0700 Subject: [PATCH] Version 1.1-R2 - Fixed a few major bugs: - Fixed the "Error" taking over all of the Gradio WebUI - Happened due to Gradio & FastAPI dependency conflict (reminder: always vet your stuff~!) - Fixed issues with the software failing gently when you have no mic - Fixed crashes relating to searching for "Minecraft" logs, it now check to see if the module is enabled first --- changelog.txt | 10 ++++++++++ requirements.txt | 7 ++++--- utils/minecraft.py | 5 ++++- utils/volume_listener.py | 27 ++++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index f1b8891..817c437 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,16 @@ Changelog ---.---.---.--- +v1.1-R2 + +- Fixed a few major bugs: + - Fixed the "Error" taking over all of the Gradio WebUI + - Happened due to Gradio & FastAPI dependency conflict (reminder: always vet your stuff~!) + - Fixed issues with the software failing gently when you have no mic + - Fixed crashes relating to searching for "Minecraft" logs, it now check to see if the module is enabled first + +---.---.---.--- + v1.1 - Visual System diff --git a/requirements.txt b/requirements.txt index 4de4259..3865d5a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ opencv-python -gradio~=4.25.0 +gradio==4.36.1 keyboard~=0.13.5 mouse~=0.7.1 PyGetWindow~=0.0.9 PythMC~=1.2.2 sounddevice~=0.4.6 -colorama~=0.4.6 +colorama humanize~=4.7.0 emoji~=2.9.0 discord @@ -14,4 +14,5 @@ python-dotenv~=1.0.0 PyAudio~=0.2.14 pydub~=0.25.1 pyvts~=0.3.2 -numpy~=1.24.4 \ No newline at end of file +numpy~=1.24.4 +fastapi==0.112.2 \ No newline at end of file diff --git a/utils/minecraft.py b/utils/minecraft.py index 763a6a1..cff19e3 100644 --- a/utils/minecraft.py +++ b/utils/minecraft.py @@ -9,7 +9,10 @@ import utils.settings import json -chat = ChatLink() # Initialises an instance of ChatLink, to take control of the Minecraft Chat. +from utils.settings import minecraft_enabled + +if minecraft_enabled: + chat = ChatLink() # Initialises an instance of ChatLink, to take control of the Minecraft Chat. last_chat = "None!" remembered_messages = ["", "Minecraft Chat Loaded!"] diff --git a/utils/volume_listener.py b/utils/volume_listener.py index ac208d2..a1d4387 100644 --- a/utils/volume_listener.py +++ b/utils/volume_listener.py @@ -1,5 +1,7 @@ import numpy as np import sounddevice as sd +from numba.cuda.libdevice import trunc +from sympy import false duration = 10 #in seconds @@ -11,10 +13,15 @@ SPEAKING_DETECTED = False SPEAKING_TIMER = 0 +no_mic = False + def audio_callback(indata, frames, time, status): global VOL_LISTENER_LEVEL + if no_mic: + VOL_LISTENER_LEVEL = 0 + volume_norm = np.linalg.norm(indata) * 10 # for reference, 0-2 is quiet background, 20 - 30 is non direct talking, 40+ is identified talking @@ -33,6 +40,24 @@ def get_vol_level(): def run_volume_listener(): + allow_mic = False + + sound_query = sd.query_devices() + for devices in sound_query: + if devices['max_input_channels'] != 0: + allow_mic = True + + if not allow_mic: + print("No mic detected!") + + global no_mic + no_mic = True + + global VOL_LISTENER_LEVEL + VOL_LISTENER_LEVEL = 0 + + return + while True: # Run Stream stream = sd.InputStream(callback=audio_callback) @@ -40,4 +65,4 @@ def run_volume_listener(): # Wait up! with stream: - sd.sleep(duration * 1000) \ No newline at end of file + sd.sleep(duration * 1000)