Speech Buffer Tutorial

Summary. This tutorial explains how to import and run the example Speech and Buffer. This example uses speech synthesis and a buffer so that all sentences are timed perfectly.

Note: We and others have observed problems with the Speech Synthesis from FreeTTS on Ubuntu in combination with OpenJDK. If you are running Ubuntu, use the JDK from Oracle, and ensure that Eclipse launches your programs with it. To select the proper SDK (for instance java-6-sun), follow the instructions given here.

Step 1: Install the Reactive Blocks SDK

In case you have not installed the SDK yet, follow the instructions here.

Step 2: Import the Example

The example is is called (Level 1) Getting started: Speech and Buffer and you can import it from within Reactive Blocks. Importing of tutorials and examples is explained here.

The example will extract into your workspace.

  • Open the Reactive Blocks Perspective, if you have not done so before.
  • The imported project (Level 1) Getting started: Speech and Buffer can be found within tab Projects in the Blocks view to the left.
  • Double-click on the block Speech and Buffer to open it.
  • Your workspace should now look something like this:

Step 3: Build the Application

Before you can start the application, you need to generate it's code:

  • Right-click on the block Speech and Buffer in the Blocks View to show the menu.
  • Select Build → Select Build Target Platform …
  • In the platform dialog, select Java Standard Edition - J2SE as platform.
  • In the parameter dialog, leave the default values.
  • After the generation, the Package Explorer View will open with a new project, called com.bitreactive.examples.speechbuffer.speechandbuffer_exe.
  • It should look something like this:

  • This _exe project is a pure Java project, not dependent on anything from Reactive Blocks.
  • In principle, you may alter code in this project as you want. Just notice that every time you build the system again, these changes are overwritten.

Step 4: Start the Application

  • Since the application uses speech synthesis: Turn up your volume!
  • Right-click on file SpeechandBuffer.launch in the generated _exe project
  • Select Run As → 1 SpeechandBuffer

Note: Depending on settings, internal debugging information may be enabled or disabled. You can change the debug level, as explained here.

  • You should hear now that the application talks three sentences, each spoken nicely after each other.

Step 5: Understand the Example

The example shows how a reactive buffer can be used to queue up jobs. The jobs here are simply to synthesize speech from a given string. This takes of course some time, depending on how long the sentence is that should be spoken. The sentences, however, are created quickly after each other. But with the buffer the sentences are nicely spoken, one after another.

Let's have a look at the example again:

You can also animate the building block to understand each step:

  • Right-click on the block in the Block View.
  • Select Animate.
  • You will see the editor with the animation bar:

  • Two executable activity steps are enabled.
  • You may switch between them with the left and right arrow key.
  • The first executable activity step is displayed in the screenshot above and shows what is happening in case initializing of Speech fails.
  • Switching to the other executable activity step leads to:

  • The left initial node triggers an activity step starting the first timer, executing the operation getFirstSentence and adding the first string to the buffer.
  • The right initial node initializes the Speech block successfully.
  • Use the arrow down key to execute this activity step.
  • The animation continues like this:

  • Again, two activity steps are possible.
  • Use the arrow down key to execute the first activity step, where the buffer pushes out the first string towards Speech.
  • The animation continues like this:

  • Now three executable activity steps are available.
  • The first activity step shown in the screenshot above is triggered by the timer to the very left, starts the second timer, executes the operation getSecondSentence and adds the second string to the buffer. Speech is in state speaking and does not take part in this activity step.

With this animation, you can go through a building block and explore its behavior, step by step.

The ESC key or X key will stop animation at any time.

Step 6: Modify the Application

Once the example is running, you may change it, just to play with it. For example in the following way:

  • Change the length of the pause between each sentence:
    • Right-click on the timer, and select another duration for the delay.
    • Durations are specified in milliseconds
  • Change the contents of the sentences:
    • Double click on the operation getFirstSentence.
    • Change the returned String in that operation.

Note that after each change, you need to build the system again, as having done it for the first time.