Hack windows pc using kali linux

Java Program which speaks


Today you will see a java program which could convert text to speech .The program will ask you to enter  string and then it will spell the string in a natural human voice.

NOTE:- For this app i am using a third party library named FreeTTS 1.2.2 you could download it from here .Here i am assuming that you know how to use the jars of third party libraries if not then you could have a look on here.
If you are using Blue J IDE then see it here.
If you are using Ellipse then look here.

So below is the complete code of our Application


Spell.java



 
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
import java.util.Scanner;

public class Spell {
private static final String VOICE_NAME_KEVIN = "kevin16";
    private final Voice voice;
    
    public Spell() {

        VoiceManager vm = VoiceManager.getInstance();       
        voice = vm.getVoice(VOICE_NAME_KEVIN);
        voice.allocate();
    }

    public void speak(String inputText) {

        if(inputText != null) {
            
            voice.speak(inputText);
        }
else          {
                inputText="Atleast enter something to speak";     
                voice.speak(inputText);
         }
}

    public static void main(String[] args) {

        // Defining Scanner Object to read data from console
        Scanner inputScanner = new Scanner(System.in);
        
        Spell tsc = new Spell();

        System.out.println("Enter the Text : (type 'exit' to terminate)");

        // Reading the text
        String inputText = inputScanner.nextLine();

        while (true) {

            if("exit".equalsIgnoreCase(inputText)) {
                
                inputText = "Good Bye, we will talk later";
                tsc.speak(inputText);
                break;
            }
            
            tsc.speak(inputText);
            
            System.out.println("Enter the Text : (type 'exit' to terminate)");
            inputText = inputScanner.nextLine();
        }

        inputScanner.close();
        
    }
}



Comments