PromptBuilder.StartSentence 方法

定義

指定 PromptBuilder 物件中的句子開頭,並選擇性指定語言。Specifies the start of a sentence in the PromptBuilder object, and optionally specifies a language.

多載

StartSentence()

指定 PromptBuilder 物件中的段落開頭。Specifies the start of a sentence in the PromptBuilder object.

StartSentence(CultureInfo)

指定 PromptBuilder 物件中指定之文化特性中的句子開頭。Specifies the start of a sentence in the specified culture in the PromptBuilder object.

備註

長時間提示可以像「人類語音」一樣轉譯, 如果它們分成句子與段落。Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

StartSentence()

指定 PromptBuilder 物件中的段落開頭。Specifies the start of a sentence in the PromptBuilder object.

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

範例

下列範例會建立PromptBuilder物件、附加內容, 並將內容組織成段落和句子。The following example creates a PromptBuilder object, appends content, and organizes the content into paragraphs and sentences.

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();  
    }  
  }  
}  
  

備註

長時間提示可以像「人類語音」一樣轉譯, 如果它們分成句子與段落。Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

StartSentence(CultureInfo)

指定 PromptBuilder 物件中指定之文化特性中的句子開頭。Specifies the start of a sentence in the specified culture in the PromptBuilder object.

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

提供特定文化特性的相關資訊,例如語言、文化特性名稱、書寫系統、使用的行事曆,以及如何格式化日期和排序字串。Provides information about a specific culture, such as the language, the name of the culture, the writing system, the calendar used, and how to format dates and sort strings.

備註

長時間提示可以像「人類語音」一樣轉譯, 如果它們分成句子與段落。Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

句子culture的參數可以不同cultureCulture包含句子之段落的參數, PromptBuilder或包含它們之物件的屬性。The culture parameter for a sentence can be different than the culture parameter for the paragraph that contains the sentence or the Culture property of the PromptBuilder object that contains them.

實際上, culture參數的值將會覆Culture寫包含句子之段落的屬性culture和參數。While in effect, the value of the culture parameter will override the Culture property and the culture parameter for the paragraph that contains the sentence. 會嘗試選取支援culture參數所指定語言的已安裝語音, 以說出句子。 SpeechSynthesizerThe SpeechSynthesizer will attempt to select an installed voice that supports the language specified by the culture parameter to speak the sentence. 如果找到具有指定文化特性的語音, 則會使用它。If a voice with the specified culture is found, it will be used. 如果找不到具有指定文化特性的語音, 則會使用預設聲音。If a voice with the specified culture cannot be found, the default voice will be used. 若要停止使用指定StartSentence的語音, 請呼叫。 EndSentenceTo stop using the voice specified by StartSentence, call EndSentence.

若要以culture參數所指定的語言正確地發音文字, 必須安裝支援該語言的語音合成 (文字轉換語音或 TTS) 引擎。To correctly pronounce words in the language specified by the culture parameter, a speech synthesis (text-to-speech or TTS) engine that supports the language must be installed. 已安裝的 TTS 引擎稱為「語音」。An installed TTS engine is called a voice. 若要取得針對特定文化特性所安裝之語音的相關資訊, GetInstalledVoices請使用方法。To get information about which voices are installed for a specific culture, use the GetInstalledVoices method.

Microsoft Windows 和 System. Speech API 接受所有有效的語言國家/地區代碼作為的culture值。Microsoft Windows and the System.Speech API accept all valid language-country codes as values for culture. 隨附于 Windows 7 的 TTS 引擎支援下列語言國家/地區代碼:The TTS engines that shipped with Windows 7 support the following language-country codes:

  • en-us。en-US. 英文 (美國)English (United States)

  • zh-CN。zh-CN. 中文 (中國)Chinese (China)

  • zh-幼圓。zh-TW. 中文 (臺灣)Chinese (Taiwan)

也允許使用兩個字母的語言代碼, 例如 "en"。Two-letter language codes such as "en" are also permitted.

適用於