convert the class to work with unity provide back the full script

using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

public class TTSClient
{
    private static readonly HttpClient HttpClient = new(); // Reuse client
    private static readonly JsonSerializerOptions JsonOpts = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };

    private readonly string _url, _text, _apiKey, _format, _outputFilePath;
    private readonly int _chunkLength, _maxNewTokens;
    private readonly float _topP, _temperature, _repetitionPenalty;
    private readonly int? _seed;
    private readonly List<string> _referenceTexts;
    private readonly List<byte[]> _referenceAudios;

    public TTSClient(
        string url,
        string text,
        string apiKey,
        List<string> referenceTexts,
        List<byte[]> referenceAudios,
        string format = "wav",
        int chunkLength = 0,
        float topP = 0.9f,
        float temperature = 0.9f,
        int? seed = 0,
        int maxNewTokens = 0,
        float repetitionPenalty = 1.1f,
        string outputFilePath = null)
    {
        _url = url ?? throw new ArgumentNullException(nameof(url));
        _text = text ?? throw new ArgumentNullException(nameof(text));
        _apiKey = apiKey ?? throw new ArgumentNullException(nameof(apiKey));
        _referenceTexts = referenceTexts ?? throw new ArgumentNullException(nameof(referenceTexts));
        _referenceAudios = referenceAudios ?? throw new ArgumentNullException(nameof(referenceAudios));
        _format = format;
        _chunkLength = chunkLength;
        _topP = topP;
        _temperature = temperature;
        _seed = seed;
        _maxNewTokens = maxNewTokens;
        _repetitionPenalty = repetitionPenalty;

        HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey);
        _outputFilePath = outputFilePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"output.{_format}");
    }

    public async Task<(bool success, string message)> SendRequestAndSaveAudioAsync()
    {
        var requestData = new
        {
            text = _text,
            references = CreateReferenceObjects(),
            normalize = true,
            format = _format,
            max_new_tokens = _maxNewTokens,
            chunk_length = _chunkLength,
            top_p = _topP,
            repetition_penalty = _repetitionPenalty,
            temperature = _temperature,
            streaming = false,
            use_memory_cache = "on",
            seed = _seed
        };

        var json = JsonSerializer.Serialize(requestData, JsonOpts);
        using var content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response;
        try
        {
            response = await HttpClient.PostAsync(_url, content).ConfigureAwait(false);
        }
        catch (Exception ex)
        {
            return (false, $"Request error: {ex.Message}");
        }

        if (!response.IsSuccessStatusCode)
        {
            string error = await SafeReadResponseContentAsync(response).ConfigureAwait(false);
            return (false, $"Server error {response.StatusCode}: {error}");
        }

        try
        {
            byte[] audioBytes = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
            using var fs = new FileStream(_outputFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 81920, true);
            await fs.WriteAsync(audioBytes, 0, audioBytes.Length).ConfigureAwait(false);

            return (true, _outputFilePath);
        }
        catch (Exception ex)
        {
            return (false, $"Failed to save audio: {ex.Message}");
        }
    }

    private List<object> CreateReferenceObjects()
    {
        int count = Math.Min(_referenceTexts.Count, _referenceAudios.Count);
        var refs = new List<object>(count);

        for (int i = 0; i < count; i++)
        {
            string base64Audio = _referenceAudios[i] is { Length: > 0 } data ? Convert.ToBase64String(data) : null;
            refs.Add(new { text = _referenceTexts[i], audio = base64Audio });
        }

        return refs;
    }

    private static async Task<string> SafeReadResponseContentAsync(HttpResponseMessage response)
    {
        try
        {
            return await response.Content.ReadAsStringAsync().ConfigureAwait(false);
        }
        catch
        {
            return "<Unable to read response content>";
        }
    }
}