Compartir a través de


Note

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

PromptBuilder.AppendText Method (String, PromptVolume)

Appends text to the PromptBuilder object and specifies a volume for the text to be spoken.

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

Syntax

'Declaration
Public Sub AppendText ( _
    textToSpeak As String, _
    volume As PromptVolume _
)
'Usage
Dim instance As PromptBuilder
Dim textToSpeak As String
Dim volume As PromptVolume

instance.AppendText(textToSpeak, volume)
public void AppendText(
    string textToSpeak,
    PromptVolume volume
)

Parameters

  • textToSpeak
    Type: System.String
    A string containing the text to be spoken.

Remarks

The Default setting for PromptVolume is full volume, which is the same as ExtraLoud. The other settings decrease the volume of speech output relative to full volume.

Examples

The following example uses the AppendText(String, PromptVolume) method to specify volume settings that the synth should apply to speech output.

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

        // Build a prompt that applies different volume settings.
        PromptBuilder builder = new PromptBuilder();
        builder.AppendText("This is the default speaking volume.", PromptVolume.Default);
        builder.AppendBreak();
        builder.AppendText("This is the extra loud speaking volume.", PromptVolume.ExtraLoud);
        builder.AppendBreak();
        builder.AppendText("This is the medium speaking volume.", PromptVolume.Medium);

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

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

See Also

Reference

PromptBuilder Class

PromptBuilder Members

AppendText Overload

Microsoft.Speech.Synthesis Namespace