전화 통화의 감성 분석
오디오 파일에서 텍스트로 전사했다면, 그 텍스트에 자연어 처리를 적용할 수 있어요.
이 연습 문제에서는 NLTK의 VADER(Valence Aware Dictionary and sEntiment Reasoner)를 사용해 call_2.wav(file)의 전사 텍스트 감성을 분석하겠습니다.
텍스트 전사에는 앞에서 만든 transcribe_audio() 함수를 사용할 거예요.
텍스트를 얻은 뒤에는 NLTK의 SentimentIntensityAnalyzer() 클래스를 사용해 감성 극성 점수를 구합니다.
.polarity_scores(text)는 pos(positive), neu(neutral), neg(negative), compound 값을 반환해요. compound는 앞의 세 값을 종합한 점수로, 값이 클수록 텍스트가 더 긍정적이고, 작을수록 더 부정적입니다.
이 연습은 강의의 일부입니다
Python으로 배우는 음성 언어 처리
연습 안내
SentimentIntensityAnalyzer()인스턴스를 생성해 변수sid에 저장하세요.- 대상 통화를 전사해
call_2_text에 저장하세요. call_2_text의polarity_scores()를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
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))