-4

I am writing a text to speech application in java, but I want a situation whereby as the user strikes a key, the application speaks that key as he presses it, pls am stuck I need help.! I am using the jframe class(GUI drag and drop netbeans) scanner won't work. Its for console!!! I need to get individual characters pressed by the user in a container and pass it to the speech engine to speak from a JText area

  • Welcome to Stack Overflow. In order to be able to help you, we need to have more information: what platform are you using and what have you tried so far. – Paul Floyd Aug 29 '18 at 10:16
  • Please post additional details such as code lines where is it failing, etc. – Ranielle Canlas Aug 29 '18 at 10:57
  • Possible duplicate of [How can I read input from the console using the Scanner class in Java?](https://stackoverflow.com/questions/11871520/how-can-i-read-input-from-the-console-using-the-scanner-class-in-java) – Michu93 Aug 29 '18 at 11:21
  • Thanks a lot guys!! Well I HV thought of the scanner class but after creating an object of the scanner class am stuck, I need to get d particular key pressed by the user, and pass it in to the voice synthesis engine for it to say d particular letter pressed – Emmanuel Chizimuzo Aug 30 '18 at 00:31

1 Answers1

0

This is a very broad question so I can only give a little bit of help. To get you started, you should use the basic java.util.Scannerthat is used for most keyboard input readers.

You would have to import at least these two tools like this:

import java.util.Scanner;  //reads input from keys
import java.speech.Engine; //allows java to "speak"

An alternative for the Scanner tool is BufferReader or KeyboardReader. However, I suggest Scanner because it is easiest to use and is built-in with java.

The rest of how to use the speaking Engine in java you can find here: https://www.geeksforgeeks.org/converting-text-speech-java/

Hope this helps :)

Edward Dan
  • 114
  • 1
  • 10