PromptBuilder.StartSentence 方法

定義

指定 PromptBuilder 物件中的句子開頭,並選擇性地指定語言。

多載

StartSentence()

指定 PromptBuilder 物件中的段落開頭。

StartSentence(CultureInfo)

指定 PromptBuilder 物件中指定文化特性的句子開頭。

備註

長提示可以像人類語音一樣呈現,如果它們分成句子和段落。

StartSentence()

指定 PromptBuilder 物件中的段落開頭。

public:
 void StartSentence();
public void StartSentence ();
member this.StartSentence : unit -> unit
Public Sub StartSentence ()

範例

下列範例會建立 PromptBuilder 物件、附加內容,並將內容組織成段落和句子。

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 add content as paragraphs and sentences.  
        PromptBuilder parSent = new PromptBuilder();  
        parSent.StartParagraph();  
        parSent.StartSentence();  
        parSent.AppendText("Introducing the sentence element.");  
        parSent.EndSentence();  
        parSent.StartSentence();  
        parSent.AppendText("You can use it to mark individual sentences.");  
        parSent.EndSentence();  
        parSent.EndParagraph();  
        parSent.StartParagraph();  
        parSent.AppendText("Another simple paragraph. Sentence structure in this paragraph" +  
          "is not explicitly marked.");  
        parSent.EndParagraph();  

        // Speak the contents of the SSML prompt.  
        synth.Speak(parSent);  
      }  

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

備註

長提示可以像人類語音一樣呈現,如果它們分成句子和段落。

適用於

StartSentence(CultureInfo)

指定 PromptBuilder 物件中指定文化特性的句子開頭。

public:
 void StartSentence(System::Globalization::CultureInfo ^ culture);
public void StartSentence (System.Globalization.CultureInfo culture);
member this.StartSentence : System.Globalization.CultureInfo -> unit
Public Sub StartSentence (culture As CultureInfo)

參數

culture
CultureInfo

提供特定文化特性的相關資訊,例如語言、文化特性的名稱、書寫系統、使用的行事曆,以及如何格式化日期和排序字串。

備註

長提示可以像人類語音一樣呈現,如果它們分成句子和段落。

culture句子的參數可以與包含 culture 句子之段落的參數或 Culture PromptBuilder 包含它們之物件的屬性不同。

實際上,參數的值 culture 將會覆寫 Culture 包含句子之段落的屬性和 culture 參數。 SpeechSynthesizer會嘗試選取支援參數所指定之語言的已安裝語音 culture 來說出句子。 如果找到具有指定文化特性的語音,則會使用它。 如果找不到具有指定文化特性的語音,則會使用預設的語音。 若要停止使用指定的語音 StartSentence ,請呼叫 EndSentence

若要使用參數所指定的語言來正確發音文字 culture ,必須安裝支援語言的語音合成 (文字轉換語音或 TTS) 引擎。 已安裝的 TTS 引擎稱為語音。 若要取得特定文化特性所安裝之語音的相關資訊,請使用 GetInstalledVoices 方法。

Microsoft Windows 和 System. Speech API 接受所有有效的語言國家/地區代碼,作為的值 culture 。 隨附于 Windows 7 的 TTS 引擎支援下列語言國家/地區代碼:

  • en-us。 英文 (美國)

  • zh-CN。 簡體中文

  • zh-幼圓。 中文 (台灣)

也允許兩個字母的語言代碼(例如 "en")。

適用於