Skip to content

Instantly share code, notes, and snippets.

@robertmeta
Last active April 15, 2024 01:38
Show Gist options
  • Save robertmeta/42358108f589ebd740ca0c8669cb381e to your computer and use it in GitHub Desktop.
Save robertmeta/42358108f589ebd740ca0c8669cb381e to your computer and use it in GitHub Desktop.
Program.cs
// to use:
// 1. make directory
// 2. switch to directory
// 3. dotnet new console
// 4. dotnet add package System.Speech
// 5. copy this file into Program.cs
// 6. dotnet run
using System;
using System.Speech.Synthesis;
class Program
{
static void Main(string[] args)
{
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SelectVoice("Microsoft Zira Desktop");
string ssml = @"<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>
<prosody pitch='0%'>hello</prosody>
<prosody pitch='+20%'>world</prosody>
</speak>";
synth.SpeakSsml(ssml);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment