開始使用免費開始

針對已格式化文字進行情緒分析

在這個練習中,你要對 call_2.wavfile)中顧客端的聲道進行情緒分析。

你已經分離出顧客聲道,並將其存成 call_2_channel_2.wavfile)。

不過,依你對情緒分析的經驗,情緒可能會在不同句子之間改變。

若要逐句計算,你會使用 NLTKsent_tokenize() 模組將文字切成句子。

transcribe_audio() 不會回傳分句結果。為了嘗試以句子為單位的情緒分析,你改用了付費的 API 服務取得帶有句子的 call_2_channel_2_paid_api_text

本練習屬於課程

Python 的口語語言處理

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

from nltk.sentiment.vader import SentimentIntensityAnalyzer

# Create SentimentIntensityAnalyzer instance
sid = SentimentIntensityAnalyzer()

# Transcribe customer channel of call 2
call_2_channel_2_text = transcribe_audio(____)

# Display text and sentiment polarity scores
print(call_2_channel_2_text)
print(sid.____(call_2_channel_2_text))
編輯並執行程式碼