Skip to main content

How To Use Sentiment Analysis

Process file#

The first thing you need to do before getting your Sentiment Analysis is to process your audio, video or text file. This code is taken directly from our POST Video URL page. If you want to use an audio or text file you can use the code from the POST Audio URL or POST Text File pages.

While we provide you with a default video URL, you can replace that with any other video URL.

Request Example#

curl --location --request POST "https://api.symbl.ai/v1/process/video/url" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $AUTH_TOKEN" \
--data-raw '{
"url": "https://symbltestdata.s3.us-east-2.amazonaws.com/sample_video_file.mp4",
"name": "BusinessMeeting",
}'

Response Example#

{
"conversationId": "5815170693595136",
"jobId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
}

Receive Sentiment Analysis#

In the response above, you will notice the conversationId field. Using the conversationId you can send a request to GET Speech to Text endpoint in the Conversation API. Sentiment Analysis also works with the GET Topics endpoint. **In order to get the Sentiment Analysis from the endpoint you must pass the query parameter sentiment=true in the Conversation API URL. Below is an example

Request Example#

curl "https://api.symbl.ai/v1/conversations/$CONVERSATION_ID/messages?sentiment=true" \
-H "Authorization: Bearer $AUTH_TOKEN"

Response Example#

{
"messages": [{
"id": "6412283618000896",
"text": "Best package for you is $69.99 per month.",
"from": {
"name": "Roger",
"email": "Roger@example.com"
},
"startTime": "2020-07-10T11:16:21.024Z",
"endTime": "2020-07-10T11:16:26.724Z",
"conversationId": "6749556955938816",
"phrases": [{
"type": "action_phrase",
"text": "$69.99 per month"
}],
"sentiment": {
"polarity": {
"score": 0.6
}
}
}]
}

Polarity#

In the response you'll noitice the polaritgy field which shows the intensity of the sentiment. It rnages from -1.0 to 1.0, where -1.0 is the most negative sentiment and 1.0 is the most positive sentiment.

{
"sentiment": {
"polarity": {
"score": 0.6
}
}
}
info

We have chosen the below polarity ranges wrt sentiment type which covers a wide range of conversations. Polarity Sentiment may vary for your use case. We recommend that you define a threshold that works for you, and then adjust the threshold after testing and verifying the results.

polaritySuggested Sentiment
-1.0 => x > -0.3negative
-0.3 => x <= 0.3neutral
0.3 < x <= 1.0positive