'code'
public static async Task ConvertVocals(string selectedVoicePath, string singingVoiceFile, int qualityValue)
{
    const string outputsDir = @"C:\AI\UVR5_UI\outputs";
    const string finalOutputPath = @"C:\output\folder\NewVoice.wav";

    // Clear output directory
    try
    {
        if (Directory.Exists(outputsDir))
        {
            foreach (var file in Directory.GetFiles(outputsDir))
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Failed to delete file '{file}': {ex.Message}");
                }
            }
        }
        else
        {
            MessageBox.Show($"Outputs directory does not exist: {outputsDir}");
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show($"Failed to clear output directory: {ex.Message}");
    }

    using var client = new HttpClient { Timeout = Timeout.InfiniteTimeSpan };

    try
    {
        // Validate input files existence before opening
        if (!File.Exists(singingVoiceFile))
        {
            MessageBox.Show($"Singing voice file not found: {singingVoiceFile}");
            return;
        }

        if (!File.Exists(selectedVoicePath))
        {
            MessageBox.Show($"Selected voice path not found: {selectedVoicePath}");
            return;
        }

        using var sourceStream = File.OpenRead(singingVoiceFile);
        using var referenceStream = File.OpenRead(selectedVoicePath);

        using var sourceContent = new StreamContent(sourceStream);
        sourceContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
        {
            Name = "source_file",
            FileName = "source.wav"
        };

        using var referenceContent = new StreamContent(referenceStream);
        referenceContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
        {
            Name = "reference_file",
            FileName = "reference.wav"
        };

        using var form = new MultipartFormDataContent
{
    { sourceContent, "source_file", "source.wav" },
    { referenceContent, "reference_file", "reference.wav" },
    { new StringContent(qualityValue.ToString()), "diffusion_steps" },
    { new StringContent("1.0"), "length_adjust" },
    { new StringContent("0.7"), "inference_cfg_rate" },
    { new StringContent("true"), "auto_f0_adjust" },
    { new StringContent("0"), "pitch_shift" }
};

        HttpResponseMessage response = await client.PostAsync("http://localhost:6576/convert", form);

        if (!response.IsSuccessStatusCode)
        {
            MessageBox.Show($"Server error: {response.StatusCode}");
            return;
        }

        var jsonString = await response.Content.ReadAsStringAsync();

        using var jsonDoc = JsonDocument.Parse(jsonString);
        var root = jsonDoc.RootElement;

        JsonElement pathElem;
        if (!root.TryGetProperty("windows_path", out pathElem) && !root.TryGetProperty("file_path", out pathElem))
        {
            MessageBox.Show("Server response missing 'windows_path' or 'file_path'");
            return;
        }

        string serverFilePath = pathElem.GetString();

        if (string.IsNullOrWhiteSpace(serverFilePath) || !File.Exists(serverFilePath))
        {
            MessageBox.Show($"Output file from server not found: {serverFilePath}");
            return;
        }

        

        // Delete existing final output file to avoid locks during copy
        if (File.Exists(finalOutputPath))
        {
            try
            {
                File.Delete(finalOutputPath);
            }
            catch (Exception ex)
            {
                //MessageBox.Show($"Failed to delete existing final output file '{finalOutputPath}': {ex.Message}");
                return;
            }
        }

        // Copy new converted vocals
        File.Copy(serverFilePath, finalOutputPath);
        
    }
    catch (TaskCanceledException)
    {
        MessageBox.Show("Request was canceled. It may have taken too long.");
    }
    catch (System.Text.Json.JsonException jEx)
    {
        MessageBox.Show($"Failed to parse server response: {jEx.Message}");
    }
    catch (Exception ex)
    {
        MessageBox.Show($"Error during conversion: {ex.Message}");
    }

    // Call CombineWavs synchronously
    CombineWavs();
}

'error'
Severity	Code	Description	Project	File	Line	Suppression State	Details
Error (active)	CS0120	An object reference is required for the non-static field, method, or property 'Form1.CombineWavs()'	ByteBreath	C:\Users\DjZaN\source\repos\Byte_Breath\ByteBreath\Form1.cs	7261