私はC#が初めてで、SpeechSynthesizerを使用していくつかの単語を読み上げています。しかし、話している間に何語話したかを数える必要があります。そのための方法はありますか?? どんな助けでも大歓迎です。ありがとう
2 に答える
2
System.Speech.Synthesizer.SpeakProgress
これにはイベントを使用できます。次のコードを参照してください。
int WordCount = 0;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SpeakProgress += new EventHandler<System.Speech.Synthesis.SpeakProgressEventArgs>(synthesizer_SpeakProgress);
synthesizer.SpeakAsync("Hello How Are You?");
}
void synthesizer_SpeakProgress(object sender, System.Speech.Synthesis.SpeakProgressEventArgs e)
{
WordCount++;
//To Write word count
Console.WriteLine(WordCount.toString());
//To Write each word and its character postion to the console.
Console.WriteLine("CharPos: {0} CharCount: {1} AudioPos: {2} \"{3}\"", e.CharacterPosition, e.CharacterCount, e.AudioPosition, e.Text);
}
于 2016-12-22T06:40:49.527 に答える