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:
The libraries of Simcenter STAR-CCM+. As usual to create any macro, we need the Simcenter STAR-CCM+ libraries to recognize its objects.
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.
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 Simcenter STAR-CCM+ set to use the libraries
Set the path to the jar files in Tools -> Options -> Environment -> User Macro ClassPath to the location of the files
You are set.
* 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:
The Voice Class has a method called speak, and we give the string to this method, and the string will be read. So, mainly
Set the voice
Make it speak the string
It looks like so:
Speech recognition Now it comes the fun part: Speech recognition. Let us go inside of our speech Recognition Method.
We need to configure the Speech Recognition
* 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.
After that we can “start” the recognition
After we get the voiceCommand, we can compare with the by us pre-defined commands
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
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.