Find the error(s) in the following code. The method should have a Synthesizer object say, “Hello, here are the instructions to run the application.” This should happen when the user clicks the Instructions JButton. The speechSynthesizer variable references a Synthesizer object, which is declared as an instance variable.
```
1 private void instructionsJButtonActionPerformed( ActionEvent event )
2 {
3 speechSynthesizer.setSpeakingRate( 100.0f );
4 speechSynthesizer.speakPlainText(
5 "Hello, here are the instructions to run the application" );
6
7 } // end method instructionsJButtonActionPerformed
```
1) The Sythesizer object speechSynthesizer does not have a method called setSpeakingRate. To set the speakingRate property, you need to obtain the Synthesizer- Properties object by invoking the getSynthesizerProperties method of speechSynthesizer. Then invoke the setSpeakingRate method of SythesizerProperties to set the speakingRate property. 2) Method speakPlainText takes two arguments, not one. The correct code is:
```
1 private void instructionsJButtonActionPerformed( ActionEvent event )
2 {
3 // get synthesizer properties
4 SynthesizerProperties properties =
5 speechSynthesizer.getSynthesizerProperties();
6
7 properties.setSpeakingRate( 100.0f );
8
9 speechSynthesizer.speakPlainText( "Hello, here are " +
10 "the instructions to run the application", null );
11
12 } // end method instructionsJButtonActionPerformed
```
You might also like to view...
Match the following buttons to their views
I. II. III. IV. V. A. Normal B. Notes Page C. Reading D. Outline E. Slide Sorter
A black-and-white effect achieved through a series of shades of gray from white to black
A) Grayscale B) Sepia C) Gradient fill