Blog
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:
_10# start sth_10DEVELOPMENT=1 scramjet-transform-hub
The second terminal:
_10# go to 'voice-recognition' directory_10cd samples/voice-recognition_10_10# install dependencies_10yarn build:refapss_10_10# Deploy sample to STH_10si 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!
_16# You need to pass instane id to listen.py script. Gather it first_16si inst ls_16[{"id":"da9e41d8-e776-491f-b883-6e61afa93b97","sequence":"15228e0e-b7e3-4008-b4ee-e9aa1d0008d9"}]_16_16# Run listen.py script_16SCRAMJET_API_URL="http://localhost:8000/api/v1" INSTANCE_ID="da9e41d8-e776-491f-b883-6e61afa93b97" python3 listen.py_16_16# You should see something similar to this. Now you can start talking :)_16http://localhost:8000/api/v1 f5184065-93a0-4a53-96aa-b28ad87801cd_16ALSA 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_16ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe_16ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side_16ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21_16ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21_16ALSA 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_16(...)
Scramjet Transform Hub will recognize your voice (in this instance ‚I like pink elephants’) and provide it as output data in the logs.
_182022-07-11T08:12:43.021Z INFO Host List Instances_182022-07-11T08:12:43.021Z DEBUG Host Request [_18 'date: 2022-07-11T08:12:43.021Z, method: GET, url: /api/v1/instances, status: 200'_18]_182022-07-11T08:12:57.366Z INFO PythonRunner Input headers: {'content-type': 'text/plain'}_182022-07-11T08:12:57.366Z DEBUG PythonRunner Decoding input stream..._182022-07-11T08:12:57.366Z DEBUG PythonRunner Input stream forwarded to the instance._182022-07-11T08:12:57.369Z DEBUG Host Request [_18 'date: 2022-07-11T08:12:57.365Z, method: POST, url: /input, status: 200'_18]_182022-07-11T08:12:58.702Z DEBUG PythonRunner Output type not set, using default_182022-07-11T08:12:58.702Z INFO PythonRunner Output type: text/plain_182022-07-11T08:12:58.702Z DEBUG PythonRunner Output stream will be treated as text and encoded_18i like pink elephants 2022-07-11T08:12:59.057Z INFO PythonRunner Finished._182022-07-11T08:12:59.069Z TRACE ProcessInstanceAdapter Runner process exited [ 10994 ]_182022-07-11T08:12:59.069Z TRACE CSIController Sequence finished with success [ 0 ]_182022-07-11T08:12:59.070Z TRACE Host CSIControlled ended [ 'Exit code: 0' ]_182022-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.