2014-02-24 2 views

답변

0

확실히 여기에 System.Speech.Synthesizer.SpeakProgress 이벤트가 있습니다. 이 이벤트에는 단어 수를 계산하는 데 사용할 수있는 문자 수 및 문자 위치 (문자열의 시작부터)가 있습니다. (모든 언어에 해당하는지는 모르지만 한 단어 당 이벤트가 표시 될 수도 있습니다.)

1

이 경우 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); 
      }