Skip to main content

Sentiment Analysis

Sentiment analysis, also known as sentiment detection, is the process of determining the emotional tone or attitude expressed in a piece of text. It can identify whether the sentiment is positive, negative, or neutral.

For a call transcript, sentiment analysis can be useful to find insights into customer satisfaction, analyse trends to make data-driven decisions and also to enhance training for customer service executives.

File Transcription Job with Sentiment Analysis

Copy and paste the below curl request on your terminal to start a transcription using the API. Fill the variables with the appropriate values, as mentioned in the overview.

curl --location 'https://voice.neuralspace.ai/api/v2/jobs' \
--header 'Authorization: {{API_KEY}}' \
--form 'files=@"{{LOCAL_AUDIO_FILE_PATH}}"' \
--form 'config="{\"file_transcription\":{\"language_id\":\"{{LANG}}\", \"mode\":\"{{MODE}}\"},
\"sentiment_detect\":true}"'

In the above request, sentiment_detect is an extra configuration that is being passed. It also returns a response similar to the regular file transcription API as seen in overview.

{
"success": true,
"message": "Job created successfully",
"data": {
"jobId": "281f8662-cdc3-4c76-82d0-e7d14af52c46"
}
}

Fetch Transcription and Sentiment Analysis Results

When you pass the jobId (received in response to the transcription API) to the API below, it fetches the status and results of the job.

curl --location 'https://voice.neuralspace.ai/api/v2/jobs/{{jobId}}' \
--header 'Authorization: {{API_KEY}}'

The response of the request above appears as follows:

{
...
"data": {
...
"result": {
"transcription": {
...
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.45,
"text": "We've been at this for hours\nnow.",
"speaker": "Speaker 1",
"channel": 0,
"sentiment": "neutral"
},
{
"startTime": 8.45,
"endTime": 10.200937500000002,
"text": "Have you found anything useful\nin any of those books?",
"speaker": "Speaker 1",
"channel": 0,
"sentiment": "neutral"
},
{
"startTime": 10.740937500000001,
"endTime": 12.41,
"text": "Not a single thing,\nLewis.",
"speaker": "Speaker 0",
"channel": 0,
"sentiment": "negative"
},
{
"startTime": 12.41,
"endTime": 14.81,
"text": "I'm sure that there must be\nsomething in this library.",
"speaker": "Speaker 0",
"channel": 0,
"sentiment": "neutral"
},
...
]
},
"sentiment_detection": {
"overall": "neutral",
},
...
}
}
}

In the response above, an overall sentiment is returned. Segment-wise sentiments, if speaker diarization is enabled, would be returned like above as well.

info
  • If you have selected the speaker diarization feature while creating the job, you will also receive a segment-wise list of sentiments in addition to overall sentiment. This list of segments is unavailable when speaker diarization is not enabled, and only an overall sentiment for the whole audio file is returned.

Troubleshooting and FAQ

Negative? Check out our FAQ page. If you still need help, feel free to reach out to us directly at support@neuralspace.ai or join our Slack community.