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.."

modelType Configuration

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

Example Request

Curl
Python
curl --location --request POST 'https://api.marsview.ai/cb/v1/conversation/compute' \
--header 'Content-Type: application/json' \
--header "Authorization: {{Insert Auth Token}}" \
--data-raw '{
"txnId": "{{Insert txn ID}}",
"enableModels":[
{
"modelType":"speech_to_text",
"modelConfig":{
"automatic_punctuation" : true,
"custom_vocabulary":["Marsview", "Communication"],
"speaker_seperation":{
"num_speakers":2
},
"enableKeywords":true,
"enableTopics":false
}
},
{
"modelType":"sentiment_analysis"
}
]
}'
import requests
auth_token = "replace this with your auth token"
txn_id = "Replace this with your txn id"
request_url = "https://api.marsview.ai/cb/v1/conversation/compute"
def get_sentiment():
payload={
"txnId": txn_id,
"enableModels":[
{
"modelType":"speech_to_text",
"modelConfig":{
"automatic_punctuation" : True,
"custom_vocabulary":["Marsview", "Communication"],
"speaker_seperation":{
"num_speakers":2
},
"enableKeywords":True,
"enableTopics":False
}
},
{
"modelType":"sentiment_analysis"
}
]
}
headers = {'authorization': '{}'.format(auth_token)}
response = requests.request("POST", headers=headers, json=payload)
print(response.text)
if response.status_code == 200 and response.json()["status"] == "true":
return response.json()["data"]["enableModels"]["state"]["status"]
else:
raise Exception("Custom exception")
if __name__ == "__main__":
get_sentiment()

Example Response

"data": {
"sentiment": [
{
"startTime": 1390,
"endTime": 2690,
"speakers": [
"1"
],
"sentiment": "Very Positive",
"polarity": 0.7,
"subjectivity": 0.6000000000000001,
"sentence": "Good evening teresa."
},
]
}

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.