-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetSpeechAsStreamAsync - NAudio #186
Comments
NAudio is not good at playing streamed audio that's in MP3 format. Try saving it to disk first and having NAudio play it back from disk. Unfortunately OpenAI does not let you request audio to be output in wave format directly. It is theoretically possible to use NAudio to convert it to wave format in memory, but it's a lot more work and I personally haven't been able to make it work either. You're going to have to do some deep dives on Google to figure that out. |
Hello, Thx for response ! And you have already success to read stream flow in audio ouput ? With another lib than NAudio ? |
With CSCORE :) async Task PlayAudioStreamAsync(Stream audioStream)
{
// Assurez-vous que le flux est positionné au début
if (audioStream.CanSeek)
audioStream.Position = 0;
// Utilisez CSCore pour lire le flux
using (var soundOut = new WasapiOut())
{
// Utilisez MediaFoundationDecoder pour décoder le flux MP3
using (var mp3Stream = new MediaFoundationDecoder(audioStream))
{
soundOut.Initialize(mp3Stream);
soundOut.Play();
// Attendre que la lecture soit terminée
while (soundOut.PlaybackState != PlaybackState.Stopped)
{
await Task.Delay(100); // Ne pas utiliser Thread.Sleep dans une application async
}
}
}
} |
With NAudio I just save it to disk and play it that way. Is CSCORE working for you? Can I close this issue as resolved or is there something I need to do on my end? |
Hello,
I try to used the GetSpeechAsStreamAsync but, i didn't find any solution/configuration to play received sound, it's always a "blank noise" output.
I've try with NAudio.
I've miss something in audio configuration ? In stream processing ? Any idea ?
Kr,
The text was updated successfully, but these errors were encountered: