HOME

  • ABOUT
  • PORTFOLIO
  • NEWS, TECH & ART
    • Websites
    • WordPress Plugins
    • Processing.org
    • Neural networks
    • New Media Art
  • RASPBERRY PI
  • ABOUT
  • PORTFOLIO
  • NEWS, TECH & ART
    • Websites
    • WordPress Plugins
    • Processing.org
    • Neural networks
    • New Media Art
  • RASPBERRY PI
SimpleSpeech – Processing Library
simplespeech

SimpleSpeech – Processing Library

  • cmu, freetts, java, library, processing, processing.org, recognizer, speech, speech recognizer, speech synthesis, sphinx, synthesizer, tts

SimpleSpeech is a Processing Library for Speech Synthesis and Speech Recognition, based on the great work by Bryan Chung.

I upgraded and extended Byan’s original library to make it Processing 2.x / 3.x compatible and added some new functionality.
The library has been tested up to version 3.4.

It’s a wrapper for the Java libraries:

  • FreeTTS (Speech Synthesis)
  • CMUSphinx (Speech Recognition)

Download

Click HERE to download the latest version (10/23/2018).

simplespeech

Usage

Download and install the SimpleSpeech library in your processing / libraries folder.

Simple example for the Speech Synthesizer (A Processing sketch):

// IMPORT THE LIBRARY
import simpleSpeech.*;
// SPEAKER
Speak speaker;
void setup() {
  speaker = new Speak(this, "kevin16");
  speaker.speak("Hello World!");
] // setup()

Simple example for the Speech Recognizer:

// IMPORT THE LIBRARY
import simpleSpeech.*;
// LISTENER
Listen listener;
void setup() {
   listener = new Listen(this, "\\sample.config.xml");
} // setup()
void draw() {
} // draw()
void listenEvent(Listen _l) {
  String s = _l.readString();
  if (s != null) {
    if (s.equals("hello")) println("I recognized HELLO!");
  } // if (s != null)
} // listenEvent()

Grammar

The grammar (Java Speech Grammar Format, JSGF) for the recognition is defined in the file sample.gram (in the data folder of your sketch).

Example of the grammar file:

grammar sample;
public <command> = <word> | <color> | <shape>;

<word> = (hello)
<color> = (red | blue | green | yellow);
<shape> = (circle | square);

Speech Recognition Configuration

The configuration for the Speech Recognition in deis stored in a file called sample.config.xml in the data folder of your sketch.

IMPORTANT:
Make sure the location of your grammar file is pointing to your data folder in sample.config.xml!

<!-- ******************************************************** -->
<!-- The Grammar configuration -->
<!-- ******************************************************** -->
<component name="jsgfGrammar" type="edu.cmu.sphinx.jsapi.JSGFGrammar">
<property name="dictionary" value="dictionary"/>
<property name="grammarLocation" value="file:///D:\Dropbox\Processing\processing%20rvg%20libs\simpleSpeech\examples\listener\data"/>
<property name="grammarName" value="sample"/>
<property name="logMath" value="logMath"/>
</component>

Questions / comments?

Just send me an email ()

Donations

Please support the development of my Processing libraries!



previous article next article
profile background
profile image

Rolf van Gelder

Owner of CAGE Web Design

CAGE was established in the year 2000

What’s new?

  • WebImageLoader – Processing Library
  • Responsive P5JS for WP – WordPress plugin
  • Optimize Database after Deleting Revisions – WordPress plugin
© 1995-2025 CAGE Web Design, Eindhoven, NL | +31 (0)6 22 66 3193