add a new function to be able to provide a string which is an audio file path and get back a string in return which is the result of the transcription without altering the rest of the script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System.IO;
using System.Text;
using TMPro;

// Response data model matching JSON output: { "text": "some transcription" }
[System.Serializable]
public class TranscriptionResponse
{
    public string text;
}

public class FastAPIAudioTranscriber : MonoBehaviour
{
    public TMP_InputField inputField;

    // URL of the FastAPI transcription endpoint
    [Tooltip("Set this to your FastAPI server's /transcribe endpoint")]
    public string apiUrl = "http://yourserver.com/transcribe";

    // Path to the audio file on the device
    [Tooltip("Local path to the audio file to transcribe")]
    public string audioFilePath;

    // Use this to start the transcription process
    public void StartTranscription()
    {
        if (string.IsNullOrEmpty(audioFilePath))
        {
            Debug.LogError("Audio file path is empty.");
            return;
        }

        if (!File.Exists(audioFilePath))
        {
            Debug.LogError("Audio file does not exist at path: " + audioFilePath);
            return;
        }

        StartCoroutine(UploadAndTranscribeCoroutine(audioFilePath));
    }

    private IEnumerator UploadAndTranscribeCoroutine(string path)
    {
        // Read audio file bytes
        byte[] audioData = File.ReadAllBytes(path);
        if (audioData == null || audioData.Length == 0)
        {
            Debug.LogError("Failed to read audio data from file.");
            yield break;
        }

        // Construct multipart form data request
        List<IMultipartFormSection> formData = new List<IMultipartFormSection>();

        // Add audio_file (as UploadFile)
        formData.Add(new MultipartFormFileSection(
            "audio_file",        // field name must match FastAPI parameter
            audioData,
            Path.GetFileName(path),
            "audio/wav"          // mime type (adjust if mp3, etc.)
        ));

        // Add form field "task" with value "transcribe"
        formData.Add(new MultipartFormDataSection("task", "transcribe"));

        using (UnityWebRequest www = UnityWebRequest.Post(apiUrl, formData))
        {
            // Set a timeout if needed (seconds)
            www.timeout = 60;

            // Send request and wait for response
            yield return www.SendWebRequest();

#if UNITY_2020_1_OR_NEWER
            if (www.result == UnityWebRequest.Result.ConnectionError || www.result == UnityWebRequest.Result.ProtocolError)
#else
            if (www.isNetworkError || www.isHttpError)
#endif
            {
                Debug.LogError($"Error uploading audio: {www.error}");
                Debug.LogError($"Response: {www.downloadHandler.text}");
            }
            else
            {
                // Debug.Log("Upload complete! Response: " + www.downloadHandler.text);

                try
                {
                    // Parse JSON response
                    TranscriptionResponse response = JsonUtility.FromJson<TranscriptionResponse>(www.downloadHandler.text);
                    if (response != null)
                    {
                        Debug.Log("Transcription text: " + response.text);
                        inputField.text = response.text;
                    }
                    else
                    {
                        Debug.LogWarning("Failed to parse transcription response JSON.");
                    }
                }
                catch (System.Exception ex)
                {
                    Debug.LogError("Exception parsing JSON response: " + ex.Message);
                }
            }
        }
    }
}

provide full script update ty