public static async Task<string> GetMicrophoneTextFromWhisper(string path)
{
if (!File.Exists(path))
{
Debug.LogError("Audio file not found: " + path);
return null;
}
string transcription = string.Empty;
using (Py.GIL())
{
dynamic whisper = Py.Import("whisper");
dynamic model = whisper.load_model("base");
dynamic transcriptionResult = model.transcribe(path); //awaiting this never finishes
transcription = transcriptionResult["text"];
}
OnTranscribed?.Invoke(SpeechResult.New(transcription, filePath));
return transcription;
}
Hey all, I am having an issue with this speech to text program. It runs fine, I am just trying to optimize it. Since the model takes a second to process the audio file and I don't want to stall the main thread for that long I tried awaiting it but it seems to never reach the line under it. Is there some other way I can optimize this without Task.Run? From what I know I can't find a solution. Only thing I can find is making the python function async but I tried that too and the same result is happening so I am not sure what the best way to make this fast would be. Any thoughts or solutions would be helpful, thanks 🙏