Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

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)

Syntax

'Declaration
Public Property TtsVolume As Integer
    Get
    Set
'Usage
Dim instance As SpeechSynthesizer
Dim value As Integer

value = instance.TtsVolume

instance.TtsVolume = value
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.

Remarks

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.

Examples

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();
    }
  }
}

See Also

Reference

SpeechSynthesizer Class

SpeechSynthesizer Members

Microsoft.Speech.Synthesis Namespace