Прочитај на енглеском Уреди

Делите путем


PromptBuilder.AppendTextWithHint Method

Definition

Appends text to the PromptBuilder object and specifies the content type of the text.

Overloads

AppendTextWithHint(String, String)

Appends text to the PromptBuilder object and a String that specifies the content type of the text.

AppendTextWithHint(String, SayAs)

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

AppendTextWithHint(String, String)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

Appends text to the PromptBuilder object and a String that specifies the content type of the text.

C#
public void AppendTextWithHint(string textToSpeak, string sayAs);

Parameters

textToSpeak
String

A string containing the text to be spoken.

sayAs
String

The content type of the text.

Remarks

You can use this method to specify a content type that is not included in the SayAs enumeration. However, the TTS engine must support the parameter that you specify.

Applies to

.NET 10 (package-provided) и друге верзије
Производ Верзије
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

AppendTextWithHint(String, SayAs)

Source:
PromptBuilder.cs
Source:
PromptBuilder.cs
Source:
PromptBuilder.cs

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

C#
public void AppendTextWithHint(string textToSpeak, System.Speech.Synthesis.SayAs sayAs);

Parameters

textToSpeak
String

A string containing the text to be spoken.

sayAs
SayAs

The content type of the text.

Examples

C#
using System;  
using System.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();  

        // 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 contents of the SSML prompt.  
        synth.Speak(sayAs);  
      }  

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

Remarks

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

Applies to

.NET 10 (package-provided) и друге верзије
Производ Верзије
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)