How you can use Scramjet for voice recognition?

Our dev team wrote a very easy sample of voice recognition using Scramjet Transform Hub and the speech_recognition Python library. You can use it to change words into a data output for any of your projects with a couple strokes of your keyboard and some copy/paste. The sample needs some external dependencies to run, but we packaged all of them in the sample to limit what you need to install to play around with Scramjet technology.

The first terminal:

# start sth DEVELOPMENT=1 scramjet-transform-hub

The second terminal:

# go to 'voice-recognition' directory cd samples/voice-recognition # install dependencies yarn build:refapss # Deploy sample to STH si seq deploy dist/

Now that you’ve deployed the code, you need to gather the voice and pass it over to the listen.py script, then you can start running the script and start talking!

# You need to pass instane id to listen.py script. Gather it first si inst ls [{"id":"da9e41d8-e776-491f-b883-6e61afa93b97","sequence":"15228e0e-b7e3-4008-b4ee-e9aa1d0008d9"}] # Run listen.py script SCRAMJET_API_URL="http://localhost:8000/api/v1" INSTANCE_ID="da9e41d8-e776-491f-b883-6e61afa93b97" python3 listen.py # You should see something similar to this. Now you can start talking :) http://localhost:8000/api/v1 f5184065-93a0-4a53-96aa-b28ad87801cd ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'AC97 2ch->4ch Copy Switch',0,0,0): No such file or directory ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib setup.c:547:(add_elem) Cannot obtain info for CTL elem (MIXER,'AC97 2ch->4ch Copy Switch',0,0,0): No such file or directory (...)

Scramjet Transform Hub will recognize your voice (in this instance ‚I like pink elephants’) and provide it as output data in the logs.

2022-07-11T08:12:43.021Z INFO Host List Instances 2022-07-11T08:12:43.021Z DEBUG Host Request [ 'date: 2022-07-11T08:12:43.021Z, method: GET, url: /api/v1/instances, status: 200' ] 2022-07-11T08:12:57.366Z INFO PythonRunner Input headers: {'content-type': 'text/plain'} 2022-07-11T08:12:57.366Z DEBUG PythonRunner Decoding input stream... 2022-07-11T08:12:57.366Z DEBUG PythonRunner Input stream forwarded to the instance. 2022-07-11T08:12:57.369Z DEBUG Host Request [ 'date: 2022-07-11T08:12:57.365Z, method: POST, url: /input, status: 200' ] 2022-07-11T08:12:58.702Z DEBUG PythonRunner Output type not set, using default 2022-07-11T08:12:58.702Z INFO PythonRunner Output type: text/plain 2022-07-11T08:12:58.702Z DEBUG PythonRunner Output stream will be treated as text and encoded i like pink elephants 2022-07-11T08:12:59.057Z INFO PythonRunner Finished. 2022-07-11T08:12:59.069Z TRACE ProcessInstanceAdapter Runner process exited [ 10994 ] 2022-07-11T08:12:59.069Z TRACE CSIController Sequence finished with success [ 0 ] 2022-07-11T08:12:59.070Z TRACE Host CSIControlled ended [ 'Exit code: 0' ] 2022-07-11T08:12:59.070Z TRACE CSIController Instance stopped.

Deploying this code takes just a couple keystrokes and is super easy, yet the applications are really broad and can be collected even on a Raspberry Pi somewhere on the edge.

Feel free to use this sample and play around with our technology.

Feel free to check other samples developed by our team in GitHub Platform Samples Repository.

If you like it, consider joining our beta program.

Happy coding!

Project co-financed by the European Union from the European Regional Development Fund under the Knowledge Education Development Program. The project is carried out as a part of the competition of the National for Research and Development: Szybka Ścieżka.

Author:

Natalia Czapracka

Natalia Czapracka

Marketing expert with 13 years professional experience.