SpeechSynthesizer.Volume Property

Definition

Get or sets the output volume of the SpeechSynthesizer object.

public int Volume { get; set; }

Property Value

Returns the volume of the SpeechSynthesizer, from 0 through 100.

Examples

The following example sets the volume of the SpeechSynthesizer's audio output for the synthesized voice and the WAV file.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
{
  class Program
  {
    static void Main(string[] args)
    {

      // Initialize a new instance of the SpeechSynthesizer.
      using (SpeechSynthesizer synth = new SpeechSynthesizer())
      {

        // Configure the audio output.
        synth.SetOutputToDefaultAudioDevice();

        // Set the volume of the SpeechSynthesizer's ouput.
        synth.Volume = 60;

        // Build a prompt containing recorded audio and synthesized speech.
        PromptBuilder builder = new PromptBuilder(
          new System.Globalization.CultureInfo("en-US"));
        builder.AppendAudio("C:\\Test\\WelcomeToContosoRadio.wav");
        builder.AppendText(
          "The weather forecast for today is partly cloudy with some sun breaks.");

        // Speak the prompt.
        synth.Speak(builder);
      }

      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }
  }
}

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)