consider the warnings and fix the errors then return the full script fixed.

'errors'
(uvr) C:\AI\UVR5_UI>python app.py
Discord is not running. Rich Presence will be disabled.
Loading default settings...
* Running on local URL:  http://127.0.0.1:7860
* To create a public link, set `share=True` in `launch()`.
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\middleware\errors.py", line 187, in __call__
    raise exc
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\middleware\errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\gradio\brotli_middleware.py", line 74, in __call__
    return await self.app(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\gradio\route_utils.py", line 850, in __call__
    await self.app(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\routing.py", line 74, in app
    await response(scope, receive, send)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\responses.py", line 359, in __call__
    await self._handle_simple(send, send_header_only)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\responses.py", line 388, in _handle_simple
    await send({"type": "http.response.body", "body": chunk, "more_body": more_body})
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 39, in sender
    await send(message)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\_exception_handler.py", line 39, in sender
    await send(message)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\starlette\middleware\errors.py", line 162, in _send
    await send(message)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 500, in send
    output = self.conn.send(event=h11.Data(data=data))
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\h11\_connection.py", line 538, in send
    data_list = self.send_with_data_passthrough(event)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\h11\_connection.py", line 571, in send_with_data_passthrough
    writer(event, data_list.append)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\h11\_writers.py", line 65, in __call__
    self.send_data(event.data, write)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\site-packages\h11\_writers.py", line 91, in send_data
    raise LocalProtocolError("Too much data for declared Content-Length")
h11._util.LocalProtocolError: Too much data for declared Content-Length
Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
handle: <Handle _ProactorBasePipeTransport._call_connection_lost(None)>
Traceback (most recent call last):
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\asyncio\proactor_events.py", line 165, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Exception in callback _ProactorBasePipeTransport._call_connection_lost(None)
handle: <Handle _ProactorBasePipeTransport._call_connection_lost(None)>
Traceback (most recent call last):
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\DjZaN\miniconda3\envs\uvr\lib\asyncio\proactor_events.py", line 165, in _call_connection_lost
    self._sock.shutdown(socket.SHUT_RDWR)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

'script'
import os
import sys
import subprocess
import re
import platform
import torch
import logging
import yt_dlp
import json
import copy
import spaces
import gradio as gr
import urllib.parse
import assets.themes.loadThemes as loadThemes
from audio_separator.separator import Separator
from assets.i18n.i18n import I18nAuto
from argparse import ArgumentParser
from assets.presence.discord_presence import RPCManager, track_presence

i18n = I18nAuto()

now_dir = os.getcwd()
sys.path.append(now_dir)
config_file = os.path.join(now_dir, "assets", "config.json")
models_file = os.path.join(now_dir, "assets", "models.json")
default_settings_file = os.path.join(now_dir, "assets", "default_settings.json")
custom_settings_file = os.path.join(now_dir, "assets", "custom_settings.json")

device = "cuda" if torch.cuda.is_available() else "cpu"
use_autocast = device == "cuda"

if os.path.isdir("env"):
    if platform.system() == "Windows":
        python_location = ".\\env\\python.exe"
        separator_location = ".\\env\\Scripts\\audio-separator.exe"
    elif platform.system() == "Linux":
        python_location = "env/bin/python"
        separator_location = "env/bin/audio-separator"
else:
    python_location = None
    separator_location = "audio-separator"

#=======================#
#     DEMUCS Models     #
#=======================#
demucs_models = [
    'htdemucs_ft.yaml',
    'htdemucs_6s.yaml',
    'htdemucs.yaml',
    'hdemucs_mmi.yaml',
]

output_format = [
    'wav',
    'flac',
    'mp3',
    'ogg',
    'opus',
    'm4a',
    'aiff',
    'ac3'
]

found_files = []
logs = []
out_dir = "./outputs"
models_dir = "./models"
extensions = (".wav", ".flac", ".mp3", ".ogg", ".opus", ".m4a", ".aiff", ".ac3")

def load_config_presence():
    with open(config_file, "r", encoding="utf8") as file:
        config = json.load(file)
        return config["discord_presence"]

def initialize_presence():
    if load_config_presence():
        RPCManager.start_presence()

initialize_presence()

def download_audio(url, output_dir="ytdl"):

    os.makedirs(output_dir, exist_ok=True)

    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'wav',
            'preferredquality': '32',
        }],
        'outtmpl': os.path.join(output_dir, '%(title)s.%(ext)s'),
        'postprocessor_args': [
            '-acodec', 'pcm_f32le'
        ],
    }

    try:
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            info = ydl.extract_info(url, download=False)
            video_title = info['title']

            ydl.download([url])

            file_path = os.path.join(output_dir, f"{video_title}.wav")

            if os.path.exists(file_path):
                return os.path.abspath(file_path)
            else:
                raise Exception("Something went wrong")

    except Exception as e:
        raise Exception(f"Error extracting audio with yt-dlp: {str(e)}")

def read_main_config():
    try:
        with open(config_file, "r", encoding="utf8") as f:
            return json.load(f)
    except Exception as e:
        print(f"Error reading main config file '{config_file}': {e}")
        gr.Warning(i18n("Error reading main config file"))
    
def write_main_config(data):
    try:
        with open(config_file, "w", encoding="utf8") as f:
            json.dump(data, f, indent=2)
    except Exception as e:
        print(f"Error writing to main config file '{config_file}': {e}")
        gr.Warning(i18n("Error writing to main config file"))

def load_settings_from_file(filepath):
    try:
        with open(filepath, 'r', encoding='utf-8') as f:
            return json.load(f)
    except Exception as e:
        print(f"Error reading settings file '{filepath}': {e}")
        gr.Warning(i18n("Error reading settings file"))
        return None
    
def get_initial_settings():
    main_config = read_main_config()
    load_custom = main_config.get('load_custom_settings', False)

    settings_to_load = {}
    default_settings = load_settings_from_file(default_settings_file)

    if load_custom:
        print("Attempting to load custom settings...")
        custom_settings = load_settings_from_file(custom_settings_file)
        if custom_settings:
            settings_to_load = copy.deepcopy(default_settings)
            for section, params in custom_settings.items():
                if section in settings_to_load:
                    for key, value in params.items():
                        settings_to_load[section][key] = value
                else:
                    settings_to_load[section] = params
            print("Custom settings loaded successfully.")
        else:
            print("Custom settings file not found or invalid. Falling back to default settings.")
            settings_to_load = default_settings
    else:
        print("Loading default settings...")
        settings_to_load = default_settings

    return settings_to_load

initial_settings = get_initial_settings()

components = {
    "Demucs": {}
}

@track_presence("Performing Demucs Separation")
@spaces.GPU(duration=60)
def demucs_separator(audio, model, out_format, shifts, segment_size, segments_enabled, overlap, batch_size, norm_thresh, amp_thresh, progress=gr.Progress(track_tqdm=True)):
    model_path = os.path.join(models_dir, model)
    try:
        if not os.path.exists(model_path):
            gr.Info(f"This is the first time the {model} model is being used. The separation will take a little longer because the model needs to be downloaded.")

        separator = Separator(
            log_level=logging.WARNING,
            model_file_dir=models_dir,
            output_dir=out_dir,
            output_format=out_format,
            use_autocast=use_autocast,
            normalization_threshold=norm_thresh,
            amplification_threshold=amp_thresh,
            demucs_params={
                "batch_size": batch_size,
                "segment_size": segment_size,
                "shifts": shifts,
                "overlap": overlap,
                "segments_enabled": segments_enabled,
            }
        )

        progress(0.2, desc="Loading model...")
        separator.load_model(model_filename=model)

        progress(0.7, desc="Separating audio...")
        separation = separator.separate(audio)

        stems = [os.path.join(out_dir, file_name) for file_name in separation]
        
        if model == "htdemucs_6s.yaml":
            return stems[0], stems[1], stems[2], stems[3], stems[4], stems[5]
        else:
            return stems[0], stems[1], stems[2], stems[3], None, None

    except Exception as e:
        raise RuntimeError(f"Demucs separation failed: {e}") from e

def update_stems(model):
    if model == "htdemucs_6s.yaml":
        return gr.update(visible=True)
    else:
        return gr.update(visible=False)

@track_presence("Performing Demucs Batch Separation")
@spaces.GPU(duration=60)
def demucs_batch(path_input, path_output, model, out_format, shifts, segment_size, segments_enabled, overlap, batch_size, norm_thresh, amp_thresh, progress=gr.Progress()):
    found_files.clear()
    logs.clear()
    model_path = os.path.join(models_dir, model)

    if not os.path.exists(model_path):
        gr.Info(f"This is the first time the {model} model is being used. The separation will take a little longer because the model needs to be downloaded.")

    for audio_files in os.listdir(path_input):
        if audio_files.endswith(extensions):
            found_files.append(audio_files)
    total_files = len(found_files)

    if total_files == 0:
        logs.append("No valid audio files.")
        return "\n".join(logs)
    else:
        logs.append(f"{total_files} audio files found")
        found_files.sort()
        progress(0, desc="Starting processing...")

        for i, audio_files in enumerate(found_files):
            progress((i / total_files), desc=f"Processing file {i+1}/{total_files}")
            file_path = os.path.join(path_input, audio_files)
            try:
                separator = Separator(
                    log_level=logging.WARNING,
                    model_file_dir=models_dir,
                    output_dir=path_output,
                    output_format=out_format,
                    use_autocast=use_autocast,
                    normalization_threshold=norm_thresh,
                    amplification_threshold=amp_thresh,
                    demucs_params={
                        "batch_size": batch_size,
                        "segment_size": segment_size,
                        "shifts": shifts,
                        "overlap": overlap,
                        "segments_enabled": segments_enabled,
                    }
                )

                logs.append("Loading model...")
                separator.load_model(model_filename=model)

                logs.append(f"Separating file: {audio_files}")
                separator.separate(file_path)
                logs.append(f"File: {audio_files} separated!")
            except Exception as e:
                raise RuntimeError(f"Demucs batch separation failed: {e}") from e
            
        progress(1.0, desc="Processing complete")
        return "\n".join(logs)

with gr.Blocks(theme = loadThemes.load_json() or "NoCrypt/miku", title = "🎵 UVR5 UI 🎵") as app:
    gr.Markdown("<h1> 🎵 UVR5 UI 🎵 </h1>")
    gr.Markdown(i18n("If you liked this HF Space you can give me a ❤️"))
    gr.Markdown(i18n("Try UVR5 UI using Colab [here](https://colab.research.google.com/github/Eddycrack864/UVR5-UI/blob/main/UVR_UI.ipynb)"))
    all_configurable_inputs = []

    with gr.Tabs():
        with gr.TabItem("Demucs"):
            with gr.Row():
                demucs_model = gr.Dropdown(
                    label = i18n("Select the model"),
                    choices = demucs_models,
                    value = initial_settings.get("Demucs", {}).get("model", None),
                    interactive = True
                )
                demucs_output_format = gr.Dropdown(
                    label = i18n("Select the output format"),
                    choices = output_format,
                    value = initial_settings.get("Demucs", {}).get("output_format", None),
                    interactive = True
                )
            with gr.Accordion(i18n("Advanced settings"), open = False):
                with gr.Group():
                    with gr.Row():
                        demucs_shifts = gr.Slider(
                            label = i18n("Shifts"),
                            info = i18n("Number of predictions with random shifts, higher = slower but better quality"),
                            minimum = 1,
                            maximum = 20,
                            step = 1,
                            value = initial_settings.get("Demucs", {}).get("shifts", 2),
                            interactive = True
                        )
                        demucs_segment_size = gr.Slider(
                            label = i18n("Segment size"),
                            info = i18n("Size of segments into which the audio is split. Higher = slower but better quality"),
                            minimum = 1,
                            maximum = 100,
                            step = 1,
                            value = initial_settings.get("Demucs", {}).get("segment_size", 40),
                            interactive = True
                        )
                        demucs_segments_enabled = gr.Checkbox(
                            label = i18n("Segment-wise processing"),
                            info = i18n("Enable segment-wise processing"),
                            value = initial_settings.get("Demucs", {}).get("segments_enabled", True),
                            interactive = True
                        )
                    with gr.Row():
                        demucs_overlap = gr.Slider(
                            label = i18n("Overlap"),
                            info = i18n("Overlap between prediction windows. Higher = slower but better quality"),
                            minimum=0.001,
                            maximum=0.999,
                            step=0.001,
                            value = initial_settings.get("Demucs", {}).get("overlap", 0.25),
                            interactive = True
                        )
                        demucs_batch_size = gr.Slider(
                            label = i18n("Batch size"),
                            info = i18n("Larger consumes more RAM but may process slightly faster"),
                            minimum = 1,
                            maximum = 16,
                            step = 1,
                            value = initial_settings.get("Demucs", {}).get("batch_size", 1),
                            interactive = True
                        )
                    with gr.Row():
                        demucs_normalization_threshold = gr.Slider(
                            label = i18n("Normalization threshold"),
                            info = i18n("The threshold for audio normalization"),
                            minimum = 0.1,
                            maximum = 1,
                            step = 0.1,
                            value = initial_settings.get("Demucs", {}).get("normalization_threshold", 0.9),
                            interactive = True
                        )
                        demucs_amplification_threshold = gr.Slider(
                            label = i18n("Amplification threshold"),
                            info = i18n("The threshold for audio amplification"),
                            minimum = 0.1,
                            maximum = 1,
                            step = 0.1,
                            value = initial_settings.get("Demucs", {}).get("amplification_threshold", 0.7),
                            interactive = True
                        )

                    components["Demucs"] = {
                        "model": demucs_model,
                        "output_format": demucs_output_format,
                        "shifts": demucs_shifts,
                        "segment_size": demucs_segment_size,
                        "segments_enabled": demucs_segments_enabled,
                        "overlap": demucs_overlap,
                        "batch_size": demucs_batch_size,
                        "normalization_threshold": demucs_normalization_threshold,
                        "amplification_threshold": demucs_amplification_threshold
                    }
                    all_configurable_inputs.extend(components["Demucs"].values())

            with gr.Row():
                demucs_audio = gr.Audio(
                    label = i18n("Input audio"),
                    type = "filepath",
                    interactive = True
                )
            with gr.Accordion(i18n("Separation by link"), open = False):
                with gr.Row():
                    demucs_link = gr.Textbox(
                        label = i18n("Link"),
                        placeholder = i18n("Paste the link here"),
                        interactive = True
                    )
                with gr.Row():
                    gr.Markdown(i18n("You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)"))
                with gr.Row():
                    demucs_download_button = gr.Button(
                        i18n("Download!"),
                        variant = "primary"
                    )

            demucs_download_button.click(download_audio, [demucs_link], [demucs_audio])

            with gr.Accordion(i18n("Batch separation"), open = False):
                with gr.Row():
                    demucs_input_path = gr.Textbox(
                        label = i18n("Input path"),
                        placeholder = i18n("Place the input path here"),
                        interactive = True
                    )
                    demucs_output_path = gr.Textbox(
                        label = i18n("Output path"),
                        placeholder = i18n("Place the output path here"),
                        interactive = True
                    )
                with gr.Row():
                    demucs_bath_button = gr.Button(i18n("Separate!"), variant = "primary")
                with gr.Row():
                    demucs_info = gr.Textbox(
                        label = i18n("Output information"),
                        interactive = False
                    )

            demucs_bath_button.click(demucs_batch, [demucs_input_path, demucs_output_path, demucs_model, demucs_output_format, demucs_shifts, demucs_segment_size, demucs_segments_enabled, demucs_overlap, demucs_batch_size, demucs_normalization_threshold, demucs_amplification_threshold], [demucs_info])

            with gr.Row():
                demucs_button = gr.Button(i18n("Separate!"), variant = "primary")
            with gr.Row():
                demucs_stem1 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 1")
                )
                demucs_stem2 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 2")
                )
            with gr.Row():
                demucs_stem3 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 3")
                )
                demucs_stem4 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 4")
                )
            with gr.Row(visible=False) as stem6:
                demucs_stem5 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 5")
                )
                demucs_stem6 = gr.Audio(
                    show_download_button = True,
                    interactive = False,
                    type = "filepath",
                    label = i18n("Stem 6")
                )

            demucs_model.change(update_stems, inputs=[demucs_model], outputs=stem6)
                
            demucs_button.click(demucs_separator, [demucs_audio, demucs_model, demucs_output_format, demucs_shifts, demucs_segment_size, demucs_segments_enabled, demucs_overlap, demucs_batch_size, demucs_normalization_threshold, demucs_amplification_threshold], [demucs_stem1, demucs_stem2, demucs_stem3, demucs_stem4, demucs_stem5, demucs_stem6])

app.queue()
app.launch()