rahulbprakash / Realtime-streams-playground-python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Realtime-streams-playground-python

Marsview Realtime Speech Analytics API Client end code for Marsview Speech Analytics APIs

⚠️ Audio should be of format LINEAR16 at 16000hz for best performance

Step 1:

Installing the dependencies for the python application

$ pip install pyaudio==0.2.11
$ pip install "python-socketio[client]"==5.3.0

Step 2:

Signup on Marsview portal and fetch API Key and API Token Update these values in py-client.py IM-1

Step 3:

Paste the API key, secret and user_id in the space provided for these keys and run the python script (py-client.py) Note: You can also add custom model configurations along with these values It will take some time to authenticate the user, generate Transaction and initiate stream. You can start speaking when you see the following logs in the console

Token is valid
* recording

Shown below is the output from the python script (py-client.py) Output

Handling response:

You will get the response in the following function inside the code.

@sio.event
def output(data):
    data = json.loads(data)
    print(data)
    print('Trascript : ', data.get('sentence'))
    print('Sentiment : ', data.get('sentiment'))
    print('Intent : ', data.get('intent'))
    print('Tone : ', data.get('tone'))
    print('Statement Tag : ', data.get('dialog_tag'))
    print('Emotion : ', data.get('emotion'))

**note: Audio should be of format LINEAR16 at 16000hz for best performance

⚠️ Audio should be of format LINEAR16 at 16000hz for best performance

About


Languages

Language:Python 100.0%