Simcenter STAR-CCM+ Giving ears and voice to Simcenter STAR-CCM+

2023-09-19T16:04:33.000-0400
Simcenter STAR-CCM+ Simcenter STAR-CCM+ Virtual Reality Teamcenter Share Simcenter Cloud HPC Simcenter STAR-CCM+ Viewer Simcenter STAR-CCM+ Application Specific Solutions

Summary

the FAQ will explain how to use CMU Sphinx and FreeTTS to allow Simcenter STAR-CCM+ to recognize speech commands


Details

############################################################################################
DISCLAIMER

CMU Sphinx and FreeTTS are OpenSource Speech Recognition and Text to Speech toolkits. Please read the license terms and Readme before using them.

############################################################################################

Nowadays we hear everybody talking about ChatBots, ChatGPT, Google Alexa, and so on. The Speech Recognition is right now ON. You can give commands to the smart phone using your voice, create automatically subtitles watching a movie, and many more uses.


Now, how about to get another kind of input in Simcenter STAR-CCM+, like the speech recognition? Yeap, very sad, but at moment there is none. Ideas are welcome in Idea Storm.

Or wait? How about a macro to hear you and do what you want? And somehow speak with you?


This is the aim of this FAQ. to create a start point of speech recognition and give Simcenter STAR-CCM+ a voice as well.

WHAT WE NEED

Mainly we will need:
  1. The libraries of Simcenter STAR-CCM+. As usual to create any macro, we need the Simcenter STAR-CCM+ libraries to recognize its objects.
  2. The libraries to speech recognition: here we will use the CMU Sphinx 4.0. This is an Open Source library, so please look the Sphinx_license file.
  3. The “voice” libraries: here we will use the FreeTTS 1.2.3. This is an Open Source library as well, so please look the FreeTTS_License file as well.
Getting the libraries
  1. Sphinx: go to their site https://cmusphinx.github.io/ and download the packages from there.
  2. FreeTTS: go to https://freetts.sourceforge.io/ and download the packages from there.
Getting Simcenter STAR-CCM+ set to use the libraries
  1.  Set the path to the jar files in Tools -> Options -> Environment -> User Macro ClassPath to the location of the files
  2.   You are set.
User-added image
* You should give the real path to the Sphinx and FreeTTS libraries instead of PathtoSphinx and Pathtofreetts.
 
DEVELOPING THE MACRO
The main question here it is what commands you would like to recognize, and what they should do. In our example, we will recognize three commands, run, to run the simulation, describe, to give us an idea what is set in the simulation (number of Regions, Continua, …) and stop to stop the speech recognition and the macro.

The macro consists basically in two methods (I am not counting the execute method necessary for Simcenter STAR-CCM+ and the describe method, which is to read collections of different objects in Simcenter STAR-CCM+ and give the number of elements of this collection). One for the speech recognition and the other one the voice. Let us go more in detail of these methods.

Speaking (the voice of Simcenter STAR-CCM+)
This method is very straightforward. It consists of getting a string (as argument), what it will be read. And the voice.
To set the voice we use:

User-added image

The Voice Class has a method called speak, and we give the string to this method, and the string will be read. So, mainly
  1. Set the voice
  2. Make it speak the string
It looks like so:

User-added image

Speech recognition
Now it comes the fun part: Speech recognition. Let us go inside of our speech Recognition Method.
  1. We need to configure the Speech Recognition
User-added image

* you should set the path to where the dic and lm are saved
 
The first is to set how the acoustic is modelled, and we should use the resource given above. The dictionary, I have selected some words, so I am using not all the English words, but only the main ones (run, stop, describe, and some more). The last is to set how the words are spoken, so the speech recognition can recognize the spoken words.
  1. After that we can “start” the recognition
 User-added image
  1. After we get the voiceCommand, we can compare with the by us pre-defined commands
User-added image

For each command, we compare with the defined strings (“run”, “describe”, …), and we call the method we would like to execute.

Voi-la. Simcenter STAR-CCM+ can now speak and understand you.

OBSERVATIONS
  1. The CMU Sphinx 4 has a BUG which does not free the microphone after "closing" the speech recognition. We need to restart Simcenter STAR-CCM+ to free the microphone. The given workaround from Sphinx was not implemented.
  2. Only the main exceptions are caught.
  3. the dic and lm files have some more words than only stop, run and describe. The files can be created using the Sphinx Knowledge Base Tool: http://www.speech.cs.cmu.edu/tools/lmtool-new.html

KB Article ID# KB000112794_EN_US

Contents

SummaryDetails

Associated Components

Design Manager Electronics Cooling In-Cylinder (STAR-ICE) Job Manager Simcenter STAR-CCM+