Emotion Analysis

Analyze speaker emotions based on spoken text (Lexical Emotion Analysis)

‚Äč

Overview

The Emotion Analysis model will help you understand and interpret speaker emotions in a conversation or text. It is designed to understand human conversation in the form or free text or spoken text and is designed after the emotion wheel.

The Emotion wheel describes eight basic emotions: anger, anticipation, disgust, fear, joy, sadness, surprise, and trust. People can use the wheel to identify themselves and come to terms with how they are feeling and, ultimately, become more self-aware and self-compassionate.

Emotion Wheel

Emotion Types

Types of Emotions detected by enabling this setting in the Conversation API:

  • Anger

  • Anticipation

  • Disgust

  • Fear

  • Joy

  • Love

  • Optimism

  • Pessimism

  • Sadness

  • Surprise

  • Trust

Input Type Supported: Text

post
Compute Metadata

https://api.marsview.ai/v1/nlp/emotion
Request
Response
Request
Headers
appSecret
required
string
<sample-app-secret>
appId
required
string
<sample-app-Id>
Content-Type
optional
string
application/json
Body Parameters
data.text
required
boolean
Raw text on which sentiments have to be computed.
Response
200: OK
A Transaction ID is returned in the JSON body once the processing job is launched successfully. This Transaction ID can be used to check the status of the job or fetch the results of the job once the metadata is computed
{
"status":true,
"transaction_id":32dcef1a-5724-4df8-a4a5-fb43c047716b,
"message": " Compute job for file-id: 32dcef1a-5724-4df8-a4a5-fb43c047716b launched successfully"
}

Example API Call

Request

CURL
CURL
curl --request POST 'https://api.marsview.ai/v1/nlp/emotion' \
--header 'appSecret: 32dcef1a-5724-4df8-a4a5-fb43c047716b' \
--header 'appId: 1ZrKT0tTv7rVWX-qNAKLc' \
--header 'Content-Type: application/json' \
--data-raw '{
"data":{
"text":"A watch is a portable timepiece intended to be carried or worn by a person. It is designed to keep a consistent movement despite the motions caused by the person's activities. A wristwatch is designed to be worn around the wrist, attached by a watch strap or other type of bracelet, including metal bands, leather straps or any other kind of bracelet. A pocket watch is designed for a person to carry in a pocket, often attached to a chain. The study of timekeeping is known as horology. Watches progressed in the 17th century from spring-powered clocks, which appeared as early as the 14th century. During most of its history the watch was a mechanical device, driven by clockwork, powered by winding a mainspring, and keeping time with an oscillating balance wheel. These are called mechanical watches.[1][2] In the 1960s the electronic quartz watch was invented, which was powered by a battery and kept time with a vibrating quartz crystal.
By the 1980s the quartz watch had taken over most of the market from the mechanical watch. Historically, this is called the quartz revolution (also known as quartz crisis in Swiss)."
}
}'

Response

Given below is a sample response JSON when the Status code is 200.

{
"status":true,
"transaction_id":32dcef1a-5724-4df8-a4a5-fb43c047716b,
"message": " Compute job for file-id: 32dcef1a-5724-4df8-a4a5-fb43c047716b launched successfully"
}

post
Request Metadata

https://api.marsview.ai/v1/nlp/emotion/fetch
This method is used to fetch soecific Metadata for a particular file_id. It can also be used for long polling to track the progress of compute under the status object.
Request
Response
Request
Headers
Content-Type
optional
string
application/json
appId
optional
string
<sample-app-id>
appSecret
optional
string
<sample-app-secret>
Body Parameters
fileID
optional
string
fileId of the audio/video file
Response
200: OK
The output consists of two objects. The data object returns the requested metadata if it is computed. The status object shows the current state of the requested metadata. Status for each metadata field can take values "Queued"/"Processing"/"Completed". Shown below is a case where "emotion analysis" Job is in "Queued" state and "Completed" state.
QUEUED STATE
COMPLETED STATE
QUEUED STATE
{
"status":{
"emotion_analysis":"Queued",
}
"data":{
"emotion_analysis":{}
}
}
COMPLETED STATE
{
"status":{
"emotion_analysis":"Completed"
}
"data":{
"emotion_analysis":{
"sentences":[
...
{
"start_char" : "1235"
"end_char" : "1347",
"sentence": "A watch is a portable timepiece intended to be carried or worn by a person",
"emotions" : [
{
"emotion":"Happy",
"confidence":0.081
},
{
"emotion":"Neutral",
"confidence":0.71
},
]
},
{
"start_time" : "1349"
"end_time" : "1450",
"sentence":" It is designed to keep a consistent movement despite the motions caused by the person's activities",
"emotions" : [
{
"emotion":"Neutral",
"confidence":0.97
}
]
},
...
]
}
}
}

Response Object Fields

Fields

Description

start_char

Starting character of the sentence in original text

end_time

Ending character of the sentence in original text

emotions

List of emotion objects for that particular chunk

emotions.emotion

Name Tag for the Type of emotion detected.

emotion.confidence

Confidence of the emotion (ranges from 0 to 1). Higher the better

emotion.sentence

A sentence extracted from original text