JavaVoice

From Carboogle

Contents

Overview

JavaVoice is a library that can be used to add Text-To-Speech support and Voice Recognition in Java. Only English language is available at the moment. It has been built with the Spring Framework and integrates two main components:

  • FreeTTS for the Text-To-Speech support
  • Sphinx-4 for the Voice Recognition API

Usage

See the project sample to see how to declare Spring Beans.

Example to capture voice:

  1.  
  2. final RecognitionService service = VoiceServiceLocator.getDefaultInstance().getRecognitionService();
  3. final Recognizer recognizer = service.getRecognizer("SIMPLE-RECOGNIZER");
  4.  
  5. System.out.println("Loading...");
  6. recognizer.open();
  7. recognizer.startRecording();
  8.  
  9. System.out.println("\nStart speaking some words (start | stop | pause | go | next | previous | new). Press Ctrl-C to quit.\n");
  10.  
  11. while (true)
  12. {
  13. final String text = recognizer.recognize();
  14. System.out.println("You said: " + (StringUtils.isBlank(text) ? "nothing !" : text));
  15. }

Example of the speech API:

  1.  
  2. final String voiceName = "alicia";
  3. final Speaker v = VoiceServiceLocator.getDefaultInstance().getSpeakService().getSpeaker(voiceName);
  4. if (v == null)
  5. {
  6. System.err.println("No voice found for name: " + voiceName);
  7. System.exit(1);
  8. }
  9.  
  10. System.out.println("USING VOICE: " + voiceName);
  11.  
  12. v.open();
  13. v.speak("Hello you !");
  14. v.close();


NB: The VoiceServiceLocator is a Singleton used to retrieve Spring beans.

Download

Requirements

Twister game

This is an example of a small program using this library. We can use this program when playing Twister at only two persons.

You only have to download the program, unzip it, and execute the good script in the bin folder. It will popup a swing dialog box so that you can choose a voice, then you just have to listen and speak to interact with the program.

Mycila.com

Mycila projects

Other projects

ports

articles

lessons