SpeakProgressEventArgs クラス

定義

SpeakProgress イベントからデータを返します。

public ref class SpeakProgressEventArgs : System::Speech::Synthesis::PromptEventArgs
public class SpeakProgressEventArgs : System.Speech.Synthesis.PromptEventArgs
type SpeakProgressEventArgs = class
    inherit PromptEventArgs
Public Class SpeakProgressEventArgs
Inherits PromptEventArgs
継承

次の例では、 SpeakProgressEventArgsから使用できる情報を示します。 StartParagraphEndParagraphStartSentence、およびEndSentenceのメソッドが、生成された SSML にCharacterCountp<、><>、>>タグを追加することによって、にどのように影響するかに注意してください。 また、"30%" の出力には 2 つのエントリがあり、この数値文字列を読み上げる単語ごとに 1 つ (30%) です。 CharacterCountCharacterPositionはエントリごとに同じで、文字 "30%. ただし、 AudioPosition は、 SpeechSynthesizerによる "30" と "percent" という単語の話し方を反映するように変わります。

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

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

        // Build a prompt containing a paragraph and two sentences.
        PromptBuilder builder = new PromptBuilder(
          new System.Globalization.CultureInfo("en-US"));
        builder.StartParagraph();
        builder.StartSentence();
        builder.AppendText(
          "The weather forecast for today is partly cloudy with some sun breaks.");
        builder.EndSentence();
        builder.StartSentence();
        builder.AppendText(
          "Tonight's weather will be cloudy with a 30% chance of showers.");
        builder.EndSentence();
        builder.EndParagraph();

        // Add a handler for the SpeakProgress event.
        synth.SpeakProgress +=
          new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);

        // Speak the prompt and play back the output file.
        synth.Speak(builder);
        m_SoundPlayer.Play();
      }

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

    // Write each word and its character position to the console.
    static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e)
    {
      Console.WriteLine("CharPos: {0}   CharCount: {1}   AudioPos: {2}    \"{3}\"",
        e.CharacterPosition, e.CharacterCount, e.AudioPosition, e.Text);
    }
  }
}

注釈

SpeakProgressEventArgsのインスタンスは、SpeechSynthesizer オブジェクトがSpeakProgress イベントを発生させると作成されます。 SpeechSynthesizerは、SpeakSpeakAsyncSpeakSsml、またはSpeakSsmlAsyncのいずれかのメソッドを使用して、プロンプトで読み上げる新しい単語ごとにこのイベントを発生させます。

返されるデータは、コードによって生成される音声合成マークアップ言語 (SSML) に基づいています。 CharacterCountに返される値には、スペースと、コードによって生成される SSML タグの文字と内容が含まれます。

プロパティ

名前 説明
AudioPosition

イベントのオーディオ位置を取得します。

Cancelled

非同期操作が取り消されたかどうかを示す値を取得します。

(継承元 AsyncCompletedEventArgs)
CharacterCount

イベントが発生する直前に読み上げられた単語の文字数を取得します。

CharacterPosition

プロンプトの先頭から、読み上げられた単語の最初の文字の前の位置までの文字数とスペースを取得します。

Error

非同期操作中に発生したエラーを示す値を取得します。

(継承元 AsyncCompletedEventArgs)
Prompt

イベントに関連付けられているプロンプトを取得します。

(継承元 PromptEventArgs)
Text

イベントが発生したときに読み上げられたテキスト。

UserState

非同期タスクの一意識別子を取得します。

(継承元 AsyncCompletedEventArgs)

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
RaiseExceptionIfNecessary()

非同期操作が失敗した場合に、ユーザー指定の例外を発生させます。

(継承元 AsyncCompletedEventArgs)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象