Text to Speech C#
Integrate the Narakeet text to speech API into a C# application to produce audio from text. The example below uses the built-in HttpClient — no NuGet package or third-party SDK needed. The same code compiles on .NET Core, .NET 5+, and .NET Framework.
The Text to Speech API reference documents endpoints, authentication, subtitle conversion, and other cross-language features.
- Text to Speech in C#
- C# Text to Speech with Natural Voices
- .NET Text to Speech
- C# Text to Speech Library
- C# Text to Speech API Options
Text to Speech in C#
POST your text to the API, read the binary response, and write it to a file. The full round-trip for text to speech in C# fits inside a single async method:
private const string voice = "raymond";
private const string DATA = "Hey there, from C Sharp";
private const string RESULTFILE= "result.m4a";
static async Task Main(string[] args)
{
if (args.Length < 1) {
throw new ArgumentException("provide an API key as an argument");
}
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"https://api.narakeet.com/text-to-speech/m4a?voice={voice}");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("accept", "application/octet-stream");
client.DefaultRequestHeaders.Add("x-api-key", args[0]);
request.Content = new StringContent(DATA, Encoding.UTF8, "text/plain");
using HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
using (FileStream DestinationStream = File.Create(RESULTFILE))
{
await response.Content.CopyToAsync(DestinationStream);
}
}
Pass your API key as the first command-line argument. Create one from the API Keys page. The complete project with .csproj configuration is at text-to-speech-api-csharp-example on GitHub.
C# Text to Speech with Natural Voices
The Narakeet API provides C# text to speech with natural voices that sound like real people. The built-in System.Speech.Synthesis namespace relies on whatever voice packs the OS has installed — typically a handful of robotic-sounding options. With the API, your C# application gets C# text to speech with natural voices covering 900 speakers in 100 languages, all from a single HTTP call that works identically on Windows, Linux, and macOS.
.NET Text to Speech
Because the API is a standard REST endpoint, .NET text to speech works with System.Net.Http.HttpClient — part of every .NET installation since .NET Core 1.0. No extra NuGet package, no platform-specific P/Invoke, and no voice runtime to deploy alongside your app.
Where .NET text to speech fits in practice:
- ASP.NET Web API endpoints that return audio for accessibility features
- Azure Functions triggered by queue messages that produce spoken alerts
- WPF or MAUI desktop apps offering a “read aloud” button
- Background services that convert support tickets into audio digests for on-call staff
For requests larger than 1 KB or when you need uncompressed WAV, use the Long Content (Polling) API. A C# polling implementation is at https://github.com/narakeet/text-to-speech-polling-api-csharp-example/.
C# Text to Speech Library
There is no separate C# text to speech library to install. The built-in HttpClient already does everything the API needs — POST a string, read the response stream. This keeps your dependency tree clean and sidesteps the version conflicts that come with wrapping native speech engines in managed code. Console apps, ASP.NET services, Azure Functions, and background workers all use the same approach.
C# Text to Speech API Options
The endpoint URL accepts query parameters that shape the output:
Selecting a voice: Set ?voice=raymond (or any of the 900 names listed at Text to Speech Voices).
Adjusting speed: Add &voice-speed=1.2 for faster reading, or &voice-speed=0.8 to slow it down. The value is a multiplier around normal pace.
Controlling volume: Add &voice-volume=soft or &voice-volume=loud.
Choosing a format: The endpoint path determines the codec — /m4a, /mp3, or /wav. WAV output is only available with the polling API.
For pitch control, multi-voice scripts, and SSML-like stage directions, see Configuring Audio Tasks and the script header format.