Skip to main content

Sentiment Analysis

The Sentiment Analysis model detects the sentiment of each spoken sentence in the transcript text. Use Sentiment Analysis to get a detailed analysis of the positive, negative, or neutral sentiment conveyed in the audio, along with a confidence score for each result.

Quickstart

Enable Sentiment Analysis by setting sentiment_analysis to true in the transcription config.

Example output

Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US.
SentimentType.negative
0.8181032538414001
Timestamp: 250 - 6350
...

Add speaker labels to sentiments

To add speaker labels to each sentiment analysis result, using Speaker Diarization, enable speaker_labels in the transcription config.

Each sentiment result will then have a speaker field that contains the speaker label.

API reference

Request

curl https://api.assemblyai.com/v2/transcript \
--header "Authorization: YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"audio_url": "YOUR_AUDIO_URL",
"sentiment_analysis": true
}'
KeyTypeDescription
sentiment_analysisbooleanEnable Sentiment Analysis.

Response

sentiment_analysis_resultsarrayA temporal sequence of Sentiment Analysis results for the audio file, one element for each sentence in the file.
sentiment_analysis_results[i].textstringThe transcript of the i-th sentence.
sentiment_analysis_results[i].startnumberThe starting time, in milliseconds, of the i-th sentence.
sentiment_analysis_results[i].endnumberThe ending time, in milliseconds, of the i-th sentence.
sentiment_analysis_results[i].sentimentstringThe detected sentiment for the i-th sentence, one of POSITIVE, NEUTRAL, NEGATIVE.
sentiment_analysis_results[i].confidencenumberThe confidence score for the detected sentiment of the i-th sentence, from 0 to 1.
sentiment_analysis_results[i].speakerstring or nullThe speaker of the i-th sentence if Speaker Diarization is enabled, else null.

Frequently asked questions

What if the model predicts the wrong sentiment label for a sentence?

The Sentiment Analysis model is based on the interpretation of the transcript and may not always accurately capture the intended sentiment of the speaker. It's recommended to take into account the context of the transcript and to validate the sentiment analysis results with human judgment when possible.

What if the transcript contains sensitive or offensive content?

The Content Moderation model can be used to identify and filter out sensitive or offensive content from the transcript.

What if the sentiment analysis results aren't consistent with my expectations?

It's important to ensure that the audio being analyzed is relevant to your use case. Additionally, it's recommended to take into account the context of the transcript and to evaluate the confidence score for each sentiment label.

What if the sentiment analysis is taking too long to process?

The Sentiment Analysis model is designed to be fast and efficient, but processing times may vary depending on the size of the audio file and the complexity of the language used. If you experience longer processing times than expected, don't hesitate to contact our support team.