Note

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

PromptBuilder.AppendTextWithHint Method (String, SayAs)

Appends text to the PromptBuilder object and specifies the content type using a member of the SayAs enumeration.

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

Syntax

'Declaration
Public Sub AppendTextWithHint ( _
    textToSpeak As String, _
    sayAs As SayAs _
)
'Usage
Dim instance As PromptBuilder
Dim textToSpeak As String
Dim sayAs As SayAs

instance.AppendTextWithHint(textToSpeak, _
    sayAs)
public void AppendTextWithHint(
    string textToSpeak,
    SayAs sayAs
)

Parameters

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

Remarks

The content type specified by sayAs can provide guidance to the speech synthesis engine about how to pronounce the contents of textToSpeak.

Examples

The content type specified by sayAs can provide guidance to the speech synthesis engine about how to pronounce the contents of textToSpeak.

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.SetOutputToWaveFile(@"C:\test\Confirmation.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\Confirmation.wav");

        // Create a PromptBuilder object and define the data types for some of the added strings.
        PromptBuilder sayAs = new PromptBuilder();
        sayAs.AppendText("Your");
        sayAs.AppendTextWithHint("1st", SayAs.NumberOrdinal);
        sayAs.AppendText("request was for");
        sayAs.AppendTextWithHint("1", SayAs.NumberCardinal);
        sayAs.AppendText("room, on");
        sayAs.AppendTextWithHint("10/19/2012,", SayAs.MonthDayYear);
        sayAs.AppendText("with early arrival at");
        sayAs.AppendTextWithHint("12:35pm", SayAs.Time12);

        // Speak the prompt and play back the output file.
        synth.Speak(sayAs);
        m_SoundPlayer.Play();
      }

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

See Also

Reference

PromptBuilder Class

PromptBuilder Members

AppendTextWithHint Overload

Microsoft.Speech.Synthesis Namespace