Export (0) Print
Expand All

SpeechSynthesizer.TtsVolume Property

Gets or sets the volume (loudness) of the synthesized speech in the SpeechSynthesizer's audio output.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

public int TtsVolume { get; set; }

Property Value

Type: System.Int32
Returns the volume of the synthesized voice in the SpeechSynthesizer's audio output, from 0 through 100.

This property controls the volume of the TTS voice. You can use this property to balance the level of the TTS voice with the level of recorded audio in a prompt. By contrast, the Volume property sets the level of the combined audio output for both the synthesized voice and audio files in a prompt.

You can also specify volume levels within a prompt. See PromptVolume.

The following example sets the level of the TTS voice to be compatible with the level of the WAV file ContosoWeather.wav.

using System;
using Microsoft.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 TTS voice.
        synth.TtsVolume = 50;

        // 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();
    }
  }
}
Show:
© 2014 Microsoft