openai/openai-dotnet

Can't get the Audio Transcription to work in Unity C#

chiddyBenno opened this issue · 2 comments

Hello dear openai-dotnet Community.
Im currently working on a OpenAI integration in my VR-Unity Project.
I was previously working with Azure SST & TTS and want to change it all to the OpenAI-API.

Even trying out the simple Example:
`public async Task Example02_SimpleTranscriptionAsync()
{
AudioClient client = new("whisper-1", Environment.GetEnvironmentVariable("OPENAI_API_KEY"));

    string audioFilePath = Path.Combine("Assets", "audio_houseplant_care.mp3");

    AudioTranscription transcription = await client.TranscribeAudioAsync(audioFilePath);

    Console.WriteLine($"{transcription.Text}");
}`

it will give me this error:

Error: boundary
UnityEngine.Debug:Log (object)
SpeechToTextManager/<Example02_SimpleTranscriptionAsync>d__14:MoveNext () (at Assets/02-KiChatGPT/SpeechToTextManager.cs:70)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<SpeechToTextManager/<Example02_SimpleTranscriptionAsync>d__14> (SpeechToTextManager/<Example02_SimpleTranscriptionAsync>d__14&)
SpeechToTextManager:Example02_SimpleTranscriptionAsync ()
SpeechToTextManager:StartSpeechToText () (at Assets/02-KiChatGPT/SpeechToTextManager.cs:47)
NewOpenAIController:Start () (at Assets/02-KiChatGPT/NewOpenAIController.cs:57)

I would be very grateful if somebody could help me with it.
Greetings,
Benjamin

Thank you for reaching out, @chiddyBenno ! This one is tricky. 🤔 Based on the information above, I can't tell if the TranscribeAudioAsync method is actually getting called. Here are a couple of ideas to try to get more details:

  • If you put a breakpoint on the line where it calls TranscribeAudioAsync, does it actually get hit?
  • This sample requires the "audio_houseplant_care.mp3" file to be present under a folder called "Assets". Please make sure that you have copied it to your project.
  • Is "Error: boundary" the only message that you're seeing? Is there perhaps an inner error with more information?

I will close this issue for now, but please feel free to re-open it if you still have questions. Thank you!