Replies: 2 comments 1 reply
-
Have you tried FFmpeg? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Scraped together with gpt4, tested using the output with whisper and it produce some transcripts. using Concentus.Oggfile;
using Concentus.Structs;
using NAudio.Lame;
namespace OpusConverter;
public class OpusStreamToMp3BytesConverter
{
public static async Task<byte[]> ConvertOpusToMp3(Stream opusStream)
{
OpusDecoder opusDecoder = new(48000, 2);
OpusOggReadStream oggReadStream = new(opusDecoder, opusStream);
using MemoryStream intermediateStream = new();
await using (LameMP3FileWriter mp3Writer = new(intermediateStream, new(48000, 16, 2), 128))
{
while (oggReadStream.DecodeNextPacket() is { } decodedSamples)
{
byte[] buffer = new byte[decodedSamples.Length * sizeof(short)];
Buffer.BlockCopy(decodedSamples, 0, buffer, 0, buffer.Length);
mp3Writer.Write(buffer, 0, buffer.Length);
}
await mp3Writer.FlushAsync();
}
intermediateStream.Position = 0;
return intermediateStream.ToArray();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know this strictly isn't the place for this but I've been smashing my head into a wall on this. I've got a .ogg file stored in an azure blob. I can't find a solution for converting the file into any of the formats supported Wisper.
I'm sure there is a easy solution to this would really appreciate some help.
Beta Was this translation helpful? Give feedback.
All reactions