Hello, please edit my Unity Editor C# script... it works perfectly fine I just want to be able to set the output folder as a folder in unity and have the resulting file saved there.

// Save as Assets/Editor/OAS1MEditorWindow.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

public class OAS1MEditorWindow : EditorWindow
{
    // Params
    private string _url = "http://127.0.0.1:8032/v1/tts";
    private string _text = "Hello World";
    private string _apiKey = "YOUR_API_KEY";
    private string _format = "wav";
    private int chunkLength = 0;
    private int maxNewTokens = 0;
    private float topP = 0.9f;
    private float temperature = 0.9f;
    private float repetitionPenalty = 1.1f;
    private int seed = 0;

    // Changed types here
    private List<TextAsset> referenceTextAssets = new List<TextAsset> { null };
    private List<AudioClip> referenceAudioClips = new List<AudioClip> { null };

    private string outputFilePath = "";

    private Vector2 scroll;

    private Texture2D logoTexture;

    [MenuItem("Tools/OAS1M TTS")]
    public static void ShowWindow()
    {
        var window = GetWindow<OAS1MEditorWindow>("OAS1M TTS");
        window.minSize = new Vector2(400, 600);
    }

    private void OnEnable()
    {
        outputFilePath = Path.Combine(Application.persistentDataPath, $"output.{_format}");
        LoadLogo();
    }

    void LoadLogo()
    {
        // Load a logo from Resources folder (place your logo as Assets/Resources/oas1m_logo.png)
        logoTexture = Resources.Load<Texture2D>("oas1m_logo");
    }

    private void OnGUI()
    {
        scroll = EditorGUILayout.BeginScrollView(scroll);

        GUILayout.Space(10);

        if (logoTexture != null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(logoTexture, GUILayout.Width(256), GUILayout.Height(128));
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(10);
        EditorGUILayout.LabelField("TTS Configuration", EditorStyles.boldLabel);
        EditorGUILayout.Space();

        _url = EditorGUILayout.TextField("URL", _url);
        _text = EditorGUILayout.TextField("Text", _text);
        _apiKey = EditorGUILayout.TextField("API Key", _apiKey);
        _format = EditorGUILayout.TextField("Format", _format);

        chunkLength = EditorGUILayout.IntField("Chunk Length", chunkLength);
        maxNewTokens = EditorGUILayout.IntField("Max New Tokens", maxNewTokens);
        topP = EditorGUILayout.Slider("Top P", topP, 0f, 1f);
        temperature = EditorGUILayout.Slider("Temperature", temperature, 0f, 2f);
        repetitionPenalty = EditorGUILayout.FloatField("Repetition Penalty", repetitionPenalty);
        seed = EditorGUILayout.IntField("Seed", seed);

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Reference Text Assets", EditorStyles.boldLabel);
        int removeTextIndex = -1;
        for (int i = 0; i < referenceTextAssets.Count; i++)
        {
            GUILayout.BeginHorizontal();
            referenceTextAssets[i] = (TextAsset)EditorGUILayout.ObjectField(referenceTextAssets[i], typeof(TextAsset), false);
            if (GUILayout.Button("X", GUILayout.Width(20))) removeTextIndex = i;
            GUILayout.EndHorizontal();
        }
        if (removeTextIndex >= 0)
        {
            referenceTextAssets.RemoveAt(removeTextIndex);
            if (referenceAudioClips.Count > removeTextIndex)
                referenceAudioClips.RemoveAt(removeTextIndex);
        }
        if (GUILayout.Button("+ Add Reference Text"))
        {
            referenceTextAssets.Add(null);
            referenceAudioClips.Add(null);
        }

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Reference Audio Clips", EditorStyles.boldLabel);
        for (int i = 0; i < referenceAudioClips.Count; i++)
        {
            GUILayout.BeginHorizontal();
            referenceAudioClips[i] = (AudioClip)EditorGUILayout.ObjectField(referenceAudioClips[i], typeof(AudioClip), false);
            if (GUILayout.Button("Clear", GUILayout.Width(50)))
            {
                referenceAudioClips[i] = null;
            }
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Output File Path", EditorStyles.boldLabel);
        outputFilePath = EditorGUILayout.TextField(outputFilePath);

        GUILayout.Space(20);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Generate Audio", GUILayout.Height(40)))
        {
            _ = GenerateAudioAsync();
        }
        if (GUILayout.Button("Boot OAS1M API Server", GUILayout.Height(40)))
        {
            BootOAS1M();
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.EndScrollView();
    }

    private async Task GenerateAudioAsync()
    {
        if (referenceTextAssets.Count != referenceAudioClips.Count)
        {
            UnityEngine.Debug.LogError("Reference texts and reference audios counts do not match.");
            EditorUtility.DisplayDialog("Error", "Reference Text Assets and Reference Audio Clips count mismatch.", "OK");
            return;
        }

        // Convert TextAssets to strings
        List<string> referenceTexts = new List<string>(referenceTextAssets.Count);
        for (int i = 0; i < referenceTextAssets.Count; i++)
        {
            if (referenceTextAssets[i] != null)
                referenceTexts.Add(referenceTextAssets[i].text);
            else
                referenceTexts.Add(string.Empty);
        }

        // Convert AudioClips to byte arrays
        List<byte[]> referenceAudios = new List<byte[]>(referenceAudioClips.Count);
        for (int i = 0; i < referenceAudioClips.Count; i++)
        {
            AudioClip clip = referenceAudioClips[i];
            if (clip != null)
            {
                try
                {
                    byte[] wavData = AudioClipToWav(clip);
                    referenceAudios.Add(wavData);
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.LogError($"Failed to convert AudioClip '{clip.name}' to WAV bytes: {ex.Message}");
                    referenceAudios.Add(null);
                }
            }
            else
            {
                referenceAudios.Add(null);
            }
        }

        var client = new TTSClient(
            url: _url,
            text: _text,
            apiKey: _apiKey,
            referenceTexts: referenceTexts,
            referenceAudios: referenceAudios,
            format: _format,
            chunkLength: chunkLength,
            topP: topP,
            temperature: temperature,
            seed: seed,
            maxNewTokens: maxNewTokens,
            repetitionPenalty: repetitionPenalty,
            outputFilePath: outputFilePath
            );

        EditorUtility.DisplayProgressBar("OAS1M", "Sending TTS request...", 0.5f);
        var (success, message) = await client.SendRequestAndSaveAudioAsync();
        EditorUtility.ClearProgressBar();

        if (success)
        {
            EditorUtility.DisplayDialog("Success", $"Audio saved to:\n{message}", "OK");
            UnityEngine.Debug.Log("TTS audio saved: " + message);
            EditorUtility.RevealInFinder(message);
        }
        else
        {
            EditorUtility.DisplayDialog("Failure", message, "OK");
            UnityEngine.Debug.LogError("TTS failed: " + message);
        }
    }

    private void BootOAS1M()
    {
        string command = "cd ~/fish-speech && conda activate fish-speech && python -m tools.api_server --listen 0.0.0.0:8032 --llama-checkpoint-path \"checkpoints/openaudio-s1-mini\" --decoder-checkpoint-path \"checkpoints/openaudio-s1-mini/codec.pth\" --decoder-config-name modded_dac_vq --compile";

        var psi = new ProcessStartInfo
        {
            FileName = "wt.exe",
            Arguments = $"wsl -e bash -li -c \"{command}\"",
            UseShellExecute = true,
            CreateNoWindow = true,
            WindowStyle = ProcessWindowStyle.Hidden
        };

        try
        {
            Process.Start(psi);
            EditorUtility.DisplayDialog("Boot OAS1M", "Launched OAS1M API Server command in WSL terminal.", "OK");
        }
        catch (Exception ex)
        {
            EditorUtility.DisplayDialog("Error", "Failed to launch WSL command:\n" + ex.Message, "OK");
        }
    }


    /// <summary>
    /// Converts an AudioClip to a WAV byte array.
    /// This method encodes the AudioClip samples into a WAV file format in memory.
    /// </summary>
    /// <param name="clip">AudioClip to convert.</param>
    /// <returns>WAV file content as byte array.</returns>
    private byte[] AudioClipToWav(AudioClip clip)
    {
        if (clip == null)
            throw new ArgumentNullException(nameof(clip));

        // Get raw audio samples
        float[] samples = new float[clip.samples * clip.channels];
        clip.GetData(samples, 0);

        // Convert float samples [-1..1] to 16-bit PCM data
        byte[] pcmData = new byte[samples.Length * 2];
        int rescaleFactor = 32767; // to convert float to Int16

        for (int i = 0; i < samples.Length; i++)
        {
            short intData = (short)(samples[i] * rescaleFactor);
            pcmData[i * 2] = (byte)(intData & 0xff);
            pcmData[i * 2 + 1] = (byte)((intData >> 8) & 0xff);
        }

        using (MemoryStream memoryStream = new MemoryStream())
        using (BinaryWriter writer = new BinaryWriter(memoryStream))
        {
            int sampleRate = clip.frequency;
            int channels = clip.channels;
            int byteRate = sampleRate * channels * 2; // 16 bit

            // RIFF header
            writer.Write(System.Text.Encoding.ASCII.GetBytes("RIFF"));
            writer.Write(36 + pcmData.Length); // file size minus 8 bytes
            writer.Write(System.Text.Encoding.ASCII.GetBytes("WAVE"));

            // fmt subchunk
            writer.Write(System.Text.Encoding.ASCII.GetBytes("fmt "));
            writer.Write(16); // Subchunk1Size (16 for PCM)
            writer.Write((short)1); // AudioFormat (1 = PCM)
            writer.Write((short)channels);
            writer.Write(sampleRate);
            writer.Write(byteRate);
            writer.Write((short)(channels * 2)); // BlockAlign
            writer.Write((short)16); // BitsPerSample

            // data subchunk
            writer.Write(System.Text.Encoding.ASCII.GetBytes("data"));
            writer.Write(pcmData.Length);
            writer.Write(pcmData);

            writer.Flush();
            return memoryStream.ToArray();
        }
    }
}