PromptBuilder.AppendTextWithHint 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將文字附加到物件上 PromptBuilder ,並指定文字的內容類型。
多載
| 名稱 | Description |
|---|---|
| AppendTextWithHint(String, String) |
在物件和 a PromptBuilder 上附加文字String,並指定文字的內容類型。 |
| AppendTextWithHint(String, SayAs) |
將文字附加於物件上 PromptBuilder ,並使用列舉的成員 SayAs 指定內容類型。 |
AppendTextWithHint(String, String)
在物件和 a PromptBuilder 上附加文字String,並指定文字的內容類型。
public:
void AppendTextWithHint(System::String ^ textToSpeak, System::String ^ sayAs);
public void AppendTextWithHint(string textToSpeak, string sayAs);
member this.AppendTextWithHint : string * string -> unit
Public Sub AppendTextWithHint (textToSpeak As String, sayAs As String)
參數
- textToSpeak
- String
一個包含要說文字的字串。
- sayAs
- String
文本的內容類型。
備註
你可以用這種方法指定一個未包含在 SayAs 列舉中的內容類型。 不過,TTS 引擎必須支援你指定的參數。
適用於
AppendTextWithHint(String, SayAs)
將文字附加於物件上 PromptBuilder ,並使用列舉的成員 SayAs 指定內容類型。
public:
void AppendTextWithHint(System::String ^ textToSpeak, System::Speech::Synthesis::SayAs sayAs);
public void AppendTextWithHint(string textToSpeak, System.Speech.Synthesis.SayAs sayAs);
member this.AppendTextWithHint : string * System.Speech.Synthesis.SayAs -> unit
Public Sub AppendTextWithHint (textToSpeak As String, sayAs As SayAs)
參數
- textToSpeak
- String
一個包含要說文字的字串。
- sayAs
- SayAs
文本的內容類型。
範例
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();
}
}
}
備註
所 sayAs 指定的內容類型可為語音合成引擎提供如何發音的 textToSpeak指引。