From acf6a3918ec0f6dbd7628abd471a32df33b14674 Mon Sep 17 00:00:00 2001 From: Dan Clipca Date: Sat, 7 Dec 2024 00:01:52 +0200 Subject: [PATCH] Update README.md --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index b72b9a1..c63782b 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,32 @@ foreach (var model in models) } ``` +## Audio Format +FakeYou.NET returns WAV audio data exactly as received from the FakeYou API, which is: + +- Sample Rate: 44.1 kHz +- Channels: 2 (Stereo) +- Bit Depth: 8-bit PCM + +Many modern applications and platforms expect 16-bit PCM WAV files, so you may need to convert the audio data. Here's an example using NAudio: + +```csharp +// Example using NAudio to convert from 8-bit to 16-bit PCM +using NAudio.Wave; + +byte[] audioData = await client.GenerateAudioAsync(modelToken, text); + +using var inputStream = new MemoryStream(audioData); +using var reader = new WaveFileReader(inputStream); + +// Convert from 8-bit to 16-bit PCM +var targetFormat = new WaveFormat(44100, 16, 2); +using var conversionStream = new WaveFormatConversionStream(targetFormat, reader); +using var outputStream = new MemoryStream(); +WaveFileWriter.WriteWavFileToStream(outputStream, conversionStream); +audioData = outputStream.ToArray(); +``` + ## Advanced Usage ### Custom Configuration