2013-09-16 5 views
2

나는 winform에 100 개의 버튼이 있습니다. 각 버튼은 자신의 번호를 말하기와 유사한 동작을 수행합니다.음성 성능 향상 합성

SpeechSynthesizer synthesizer = new SpeechSynthesizer(); 
     ............... 

private void Form1_Load(object sender, EventArgs e) 
    { 

     seme_comboBox.SelectedIndex = 0; 
     dpt_comboBox.SelectedIndex = 0; 


     foreach (var button in Controls.OfType<Button>()) 
     { 
      button.Click += button_Click; 
     } 


    } 
다음

private void button_Click(object sender, EventArgs e) 
    { 
     Button button = (Button)sender; 
     string text = button.Name.Substring("button".Length); 

     synthesizer.Speak(text); 
    } 

하지만 두개의 버튼을 클릭 할 경우 순차적으로 다음 적어도 2 또는 3을 얻어 : 이러한 코드를 사용하는 100

Button60 것 스피치 60 button100 의지 음성 말해 초를 눌러 다른 버튼과 말로 전환 할 수 있습니다. 그리고 그 소리도 충분하지 않습니다. 그래서 약간의 시간 내에서 버튼 동작의 성능을 향상시켜야합니다. 또한 나는 연설의 소리를 증가시키고 싶습니다. 어떻게하면 되나요? ???

답변

2

SpeechSynthesizer가 UI 스레드를 차단하고있는 것처럼 들립니다. 취소

대신 (http://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer.speakasync.aspx에서)) SpeakAsync를 (사용, 당신은 할 수있다

참고 다음을 시도 할 수 또는 행을 원하지 않을 수있는 모든 (주석) :

private void button_Click(object sender, EventArgs e) 
{ 
    Button button = (Button)sender; 
    string text = button.Name.Substring("button".Length); 
    synthesizer.SpeakAsyncCancelAll(); // cancel anything that's playing 
    synthesizer.SpeakAsync(text); 
} 

당신이 할 수 있다는 실패 다른 스레드에서 sythesizer를 실행할 것입니다.

synthesizer.Volume = 100; // maximum volume (range 0-100) 
:

당신은 .Volume 속성을 사용하여 사운드 볼륨을 제어 할 수 있습니다