Prompt 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建 Prompt 类的新实例。
重载
| Prompt(PromptBuilder) | 从 PromptBuilder 对象创建 Prompt 类的新实例。 | 
| Prompt(String) | 创建 Prompt 类的新实例,并指定要朗读的文本。 | 
| Prompt(String, SynthesisTextFormat) | 创建 Prompt 类的新实例,并指定要朗读的文本以及其格式是纯文本还是标记语言。 | 
Prompt(PromptBuilder)
- Source:
- Prompt.cs
- Source:
- Prompt.cs
- Source:
- Prompt.cs
从 PromptBuilder 对象创建 Prompt 类的新实例。
public:
 Prompt(System::Speech::Synthesis::PromptBuilder ^ promptBuilder);public Prompt (System.Speech.Synthesis.PromptBuilder promptBuilder);new System.Speech.Synthesis.Prompt : System.Speech.Synthesis.PromptBuilder -> System.Speech.Synthesis.PromptPublic Sub New (promptBuilder As PromptBuilder)参数
- promptBuilder
- PromptBuilder
要讲述的内容。
适用于
Prompt(String)
- Source:
- Prompt.cs
- Source:
- Prompt.cs
- Source:
- Prompt.cs
创建 Prompt 类的新实例,并指定要朗读的文本。
public:
 Prompt(System::String ^ textToSpeak);public Prompt (string textToSpeak);new System.Speech.Synthesis.Prompt : string -> System.Speech.Synthesis.PromptPublic Sub New (textToSpeak As String)参数
- textToSpeak
- String
要朗读的文本。
示例
以下示例从字符串创建 对象 Prompt ,并将 对象作为参数传递给 Speak 方法。
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 prompt from a string.  
        Prompt color = new Prompt("What is your favorite color?");  
        // Speak the contents of the prompt synchronously.  
        synth.Speak(color);  
      }  
      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  
适用于
Prompt(String, SynthesisTextFormat)
- Source:
- Prompt.cs
- Source:
- Prompt.cs
- Source:
- Prompt.cs
创建 Prompt 类的新实例,并指定要朗读的文本以及其格式是纯文本还是标记语言。
public:
 Prompt(System::String ^ textToSpeak, System::Speech::Synthesis::SynthesisTextFormat media);public Prompt (string textToSpeak, System.Speech.Synthesis.SynthesisTextFormat media);new System.Speech.Synthesis.Prompt : string * System.Speech.Synthesis.SynthesisTextFormat -> System.Speech.Synthesis.PromptPublic Sub New (textToSpeak As String, media As SynthesisTextFormat)参数
- textToSpeak
- String
要朗读的文本。
- media
- SynthesisTextFormat
用来指定文本格式的值。
示例
下面的示例生成一个包含 SSML 标记的字符串,从该字符串创建 对象 Prompt ,并说出提示符。
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();  
        // Build an SSML prompt in a string.  
        string fileName = "<speak version=\"1.0\" ";  
        fileName += "xmlns=\"http://www.w3.org/2001/10/synthesis\" ";  
        fileName += "xml:lang=\"en-US\">";  
        fileName += "Say a name for the new file <mark name=\"fileName\" />.";  
        fileName += "</speak>";  
        // Create a Prompt object from the string.  
        Prompt ssmlFile = new Prompt(fileName, SynthesisTextFormat.Ssml);  
        // Speak the contents of the SSML prompt.  
        synth.Speak(ssmlFile);  
      }  
      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  
注解
参数的内容 textToSpeak 必须包含 speak 元素,并且必须符合 SSML) 版本 1.0 (语音合成标记语言。 有关详细信息,请参阅 语音合成标记语言参考。