Sentiment Analysis

    With Sentiment Analysis, AssemblyAI can detect the sentiment of each sentence of speech. Sentiment Analysis returns a result of "POSITIVE", "NEGATIVE", or "NEUTRAL" for each sentence in the transcript.

    Enabling Sentiment Analysis

    To include Sentiment Analysis in your transcript, add the sentiment_analysis in your POST request when launching transcription jobs using the /v2/transcript endpoint, and set this parameter to true, as shown in the cURL request below.

    curl -- request POST \
        --url \
        --header 'authorization: YOUR-API-TOKEN' \
        --header 'content-type: application/json' \
        --data '{"audio_url": "", "sentiment_analysis": true}'

    Interpreting the Sentiment Analysis response

    Once the transcription is complete, you make a GET request to /v2/transcript/<id> to receive the transcription. There will be an additional key sentiment_analysis_results in the JSON response:

        "id": "5551722-f677-48a6-9287-39c0aafd9ac1",
        "status": "completed",
        "text": "...",
        "words": [...],
        # sentiment analysis results are below
                "text": "Speaking of being in a shadow, didn't you feel yourself in the shadow of those Hollywood A-listers?",
                "start": 106090,
                "end": 112806,
                "sentiment": "NEUTRAL",
                "confidence": 0.5466495752334595,
                "speaker": null
                "text": "It's my privilege to work with these actors.",
                "start": 114790,
                "end": 116994,
                "sentiment": "POSITIVE",
                "confidence": 0.9224883317947388,
                "speaker": null

    Reviewing the response

    For each sentence in the transcription text, the API will return the sentiment, confidence score, the start and end time for when that sentence was spoken, and, if applicable, the speaker label for that sentence. A detailed explanation of each key in the list of objects returned in the sentiment_analysis_results array can be found below:

    Key Value
    text The text for the sentence being analyzed
    start Starting timestamp (in milliseconds) of the text in the transcript
    end Ending timestamp (in milliseconds) of the text in the transcript
    sentiment The detected sentiment "POSITIVE", "NEGATIVE", or "NEUTRAL"
    confidence Confidence score for the detected sentiment
    speaker If using dual_channel or speaker_labels, then the speaker that spoke this sentence