BaşlayınÜcretsiz Başlayın

Analyzing sentiment of a phone call

Once you've transcribed the text from an audio file, it's possible to perform natural language processing on the text.

In this exercise, we'll use NLTK's VADER (Valence Aware Dictionary and sEntiment Reasoner) to analyze the sentiment of the transcribed text of call_2.wav (file).

To transcribe the text, we'll use the transcribe_audio() function we created earlier.

Once we have the text, we'll use NLTK's SentimentIntensityAnalyzer() class to obtain a sentiment polarity score.

.polarity_scores(text) returns a value for pos (positive), neu (neutral), neg (negative) and compound. Compound is a mixture of the other three values. The higher it is, the more positive the text. Lower means more negative.

Bu egzersiz

Spoken Language Processing in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Instantiate an instance of SentimentIntensityAnalyzer() and save it to the variable sid.
  • Transcribe the target call and save it to call_2_text.
  • Print the polarity_scores() of call_2_text.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from nltk.sentiment.vader import SentimentIntensityAnalyzer

# Create SentimentIntensityAnalyzer instance
sid = ____

# Let's try it on one of our phone calls
call_2_text = transcribe_audio(____)

# Display text and sentiment polarity scores
print(call_2_text)
print(sid.____(call_2_text))
Kodu Düzenle ve Çalıştır