'The Task'
Please fix my script it works fine but at the end it opens the resulting saved file in the operating systems filebrowser, I need it to instead show it in editor in unity since it saves in editor and its an editor script I need it to show the file point to it in the unity asset browser not the os file browser. Please return entire script fixed ty.

'The Script'
// 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 enum AudioFormat { WAV, MP3 }
    private AudioFormat _format = AudioFormat.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 enum SeedMode { Random, Fixed }
    private SeedMode seedMode = SeedMode.Random;
    private int seed = 0;

    private bool normalize = false;
    private bool streaming = false;
    private string use_memory_cache = "off";

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

    private DefaultAsset outputFolder; // The Unity project folder chosen
    private string outputFileName = "output"; // filename without extension

    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, 650);
    }

    private void OnEnable()
    {
        // Default output folder = "Assets"
        outputFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>("Assets");
        outputFileName = "output";
        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 dropdown
        _format = (AudioFormat)EditorGUILayout.EnumPopup("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 mode dropdown + seed input (only enabled if Fixed)
        seedMode = (SeedMode)EditorGUILayout.EnumPopup("Seed Mode", seedMode);
        using (new EditorGUI.DisabledScope(seedMode == SeedMode.Random))
        {
            seed = EditorGUILayout.IntField("Seed Value", seed);
        }

        EditorGUILayout.Space();

        // Missing parameters GUI
        normalize = EditorGUILayout.Toggle("Normalize", normalize);
        streaming = EditorGUILayout.Toggle("Streaming", streaming);

        // use_memory_cache dropdown
        string[] cacheOptions = new string[] { "off", "on" };
        int currentCacheIndex = Array.IndexOf(cacheOptions, use_memory_cache);
        if (currentCacheIndex < 0) currentCacheIndex = 0;
        int selectedCache = EditorGUILayout.Popup("Use Memory Cache", currentCacheIndex, cacheOptions);
        use_memory_cache = cacheOptions[selectedCache];

        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 Folder (project folder)", EditorStyles.boldLabel);
        outputFolder = (DefaultAsset)EditorGUILayout.ObjectField(outputFolder, typeof(DefaultAsset), false);

        EditorGUILayout.LabelField("Output Filename (without extension)", EditorStyles.boldLabel);
        outputFileName = EditorGUILayout.TextField(outputFileName);

        GUILayout.Space(20);

        if (GUILayout.Button("Generate Audio", GUILayout.Height(40)))
        {
            _ = GenerateAudioAsync();
        }

        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;
        }

        // Resolve output folder path in filesystem:
        string folderPath = AssetDatabase.GetAssetPath(outputFolder);
        if (string.IsNullOrEmpty(folderPath) || !Directory.Exists(folderPath))
        {
            EditorUtility.DisplayDialog("Error", "Output folder is invalid or does not exist.", "OK");
            return;
        }

        // Compose full output path
        string extension = _format.ToString().ToLower();
        if (!extension.StartsWith("."))
            extension = "." + extension;
        string outputFilePath = Path.Combine(folderPath, outputFileName + extension);

        // 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);
            }
        }

        // Handle seed generation based on seed mode
        if (seedMode == SeedMode.Random)
        {
            seed = new System.Random().Next(int.MinValue, int.MaxValue);
        }
        // else use fixed seed from user input

        var client = new TTSClient(
            url: _url,
            text: _text,
            apiKey: _apiKey,
            referenceTexts: referenceTexts,
            referenceAudios: referenceAudios,
            format: extension.TrimStart('.'),
            chunkLength: chunkLength,
            topP: topP,
            temperature: temperature,
            seed: seed,
            maxNewTokens: maxNewTokens,
            repetitionPenalty: repetitionPenalty,
            outputFilePath: outputFilePath,
            normalize: normalize,
            streaming: streaming,
            use_memory_cache: use_memory_cache
            );

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

        if (success)
        {
            AssetDatabase.Refresh(); // Refresh the AssetDatabase to show the new file if inside Assets folder or subfolder
            UnityEngine.Debug.Log("TTS audio saved: " + message);

            // Reveal the saved file in Finder/Explorer if it is inside the project folder or external
            if (File.Exists(message))
            {
                EditorUtility.RevealInFinder(message);
            }
        }
        else
        {
            EditorUtility.DisplayDialog("Failure", message, "OK");
            UnityEngine.Debug.LogError("TTS failed: " + message);
        }
    }


    /// <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();
        }
    }
}