Share via


Note

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

SpeechSynthesizer.Volume Property

Get or sets the output volume of the SpeechSynthesizer object.

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

Syntax

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

value = instance.Volume

instance.Volume = value
public int Volume { get; set; }

Property Value

Type: System.Int32
Returns the volume of the SpeechSynthesizer, from 0 through 100.

Remarks

You can use this property to set the combined audio output for both the synthesized voice and the audio files in a prompt. By contrast, the TtsVolume property affects only the output volume of the synthesized voice 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, and then sets the combined output volume for the synthesized voice and the recorded audio file.

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, and the combined output volume.
        synth.TtsVolume = 50;
        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();
    }
  }
}

See Also

Reference

SpeechSynthesizer Class

SpeechSynthesizer Members

Microsoft.Speech.Synthesis Namespace