python-voice-recognition

This Sequence is a trivial example of voice recognition with Scramjet and speech_recognition Python library.

Description

  • Name: @scramjet/python-voice-recognition
  • Version: 0.23.0
  • Language: python
  • Author: Tatarinho
  • Tags: medium,Speech recognition,Speech-to-Text,AI and ML,Data Transformer

Prerequisites

Our sample needs some external dependencies to run properly, however we are packing them in sample. The one thing that you need to run this sample is dependency needed by our listen.py script, to gather audio data from your microphone.

sudo apt-get install python3-pyaudio

💡NOTE: Packaging of Python Sequences is not very "pythonic" for now. If you have any idea, how we should resolve it for your comfort, please let us know here.

Running

❗ Remember to setup transform-hub locally or use the platform's environment for the sequence deployment.

Open the terminal and run the following commands:

# go to 'voice-recognition' directory cd python/voice-recognition # install dependencies npm run build # Deploy sample to STH si seq deploy dist

Output

# You need to pass INSTANCE_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 (...)

For test purpose, I said that I like pink elephants. You can notice that it is visible in STH 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.