Sentiment
Enable this model configuration to analyze speaker sentiment based on spoken text (Lexical Emotion Analysis)

Overview

Sentiment Analysis will help you interpret and quantify if the conversation in the audio or video is Positive, Very Positive, Negative, Very Negative or Neutral. It also provides you a measure as to how subjective the conversation is with a subjectivity score.

Sentiment Types

See the table below for the output definition of the model
Sentiment
Description
Example
Very Positive
a statement or sentence that is highly positive
"Brilliant work John, you really came through."
Positive
a statement or a sentence that is marginally positive
"Okay let's hope everything is fine."
Neutral
a statement or a sentence that is neutral
"..sure I will do that tomorrow"
Very Negative
a statement or sentence that is highly negative
"I don't think that will happen today"
Negative
a statement or a sentence that is marginally Negative
"I am not happy with the outcome.."

modelTypeConfiguration

Keys
Value
modelType
sentiment_analysis
modelConfig
Model Configuration object for sentiment_analysis (No configurations)

Example Request

Curl
Python
1
curl --location --request POST 'https://api.marsview.ai/cb/v1/conversation/compute' \
2
--header 'Content-Type: application/json' \
3
--header "Authorization: {{Insert Auth Token}}" \
4
--data-raw '{
5
"txnId": "{{Insert txn ID}}",
6
"enableModels":[
7
{
8
"modelType":"speech_to_text",
9
"modelConfig":{
10
"automatic_punctuation" : true,
11
"custom_vocabulary":["Marsview", "Communication"],
12
"speaker_seperation":{
13
"num_speakers":2
14
},
15
"enableKeywords":true,
16
"enableTopics":false
17
}
18
},
19
{
20
"modelType":"sentiment_analysis"
21
}
22
]
23
}'
Copied!
1
import requests
2
auth_token = "replace this with your auth token"
3
txn_id = "Replace this with your txn id"
4
request_url = "https://api.marsview.ai/cb/v1/conversation/compute"
5
6
7
def get_sentiment():
8
payload={
9
"txnId": txn_id,
10
"enableModels":[
11
{
12
"modelType":"speech_to_text",
13
"modelConfig":{
14
"automatic_punctuation" : True,
15
"custom_vocabulary":["Marsview", "Communication"],
16
"speaker_seperation":{
17
"num_speakers":2
18
},
19
"enableKeywords":True,
20
"enableTopics":False
21
}
22
},
23
{
24
"modelType":"sentiment_analysis"
25
}
26
]
27
}
28
headers = {'authorization': '{}'.format(auth_token)}
29
30
response = requests.request("POST", headers=headers, json=payload)
31
print(response.text)
32
if response.status_code == 200 and response.json()["status"] == "true":
33
return response.json()["data"]["enableModels"]["state"]["status"]
34
else:
35
raise Exception("Custom exception")
36
37
if __name__ == "__main__":
38
get_sentiment()
Copied!

Example Response

1
"data": {
2
"sentiment": [
3
{
4
"startTime": 1390,
5
"endTime": 2690,
6
"speakers": [
7
"1"
8
],
9
"sentiment": "Very Positive",
10
"polarity": 0.7,
11
"subjectivity": 0.6000000000000001,
12
"sentence": "Good evening teresa."
13
},
14
]
15
}
Copied!

Response Object

Field
Description
emotion(List)
A list of sentiment objects.
startTime
Start time of the sentence in the input Video/Audio in milliseconds.
endTime
End time of the sentence in the input Video/Audio in milliseconds.
speakers
A list of speaker id's whose voices are identified for a given time frame. Normally this list would only have a single speaker Id.
sentiment(String)
The sentiment of the speaker in the given time frame.
polarity
Integer representation of the sentiment of the speaker. Can have values between
subjectivity
A scale of how much the sentence is based on facts and figures. A high subjectivity indicates that the information given by the speaker is not based on facts and that it is highly subjective.
sentence
A sentence identified by the model in the given time frame.
Last modified 1mo ago