Condividi tramite


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

PromptBuilder.StartSentence Method

Specifies the start of a sentence in the PromptBuilder object.

Namespace:  Microsoft.Speech.Synthesis
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Sub StartSentence
'Usage
Dim instance As PromptBuilder

instance.StartSentence()
public void StartSentence()

Remarks

Long prompts can be rendered more like human speech if they are broken into sentences and paragraphs.

Examples

The following example creates a PromptBuilder object, appends content, and organizes the content into paragraphs and sentences.

using System;
using Microsoft.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.SetOutputToWaveFile(@"C:\test\Sentence.wav");

        // Create a SoundPlayer instance to play the output audio file.
        System.Media.SoundPlayer m_SoundPlayer =
          new System.Media.SoundPlayer(@"C:\test\Sentence.wav");

        // 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 prompt and play back the output file.
        synth.Speak(parSent);
        m_SoundPlayer.Play();
      }

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

See Also

Reference

PromptBuilder Class

PromptBuilder Members

StartSentence Overload

Microsoft.Speech.Synthesis Namespace