TtsVolume Property

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

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

Visual Basic (Declaration)
Public Property TtsVolume As Integer
	Get
	Set
Visual Basic (Usage)
Dim instance As SpeechSynthesizer
Dim value As Integer

value = instance.TtsVolume

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

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.

Examples

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

 Copy imageCopy Code
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