음성 텍스트 감성 분석

Python으로 배우는 음성 언어 처리

Daniel Bourke

Machine Learning Engineer/YouTube Creator

감성 분석 라이브러리 설치

$ pip install nltk
# 필요한 NLTK 패키지 다운로드
import nltk
nltk.download("punkt")
nltk.download("vader_lexicon")
Python으로 배우는 음성 언어 처리

VADER로 감성 분석

# 감성 분석 클래스 불러오기
from nltk.sentiment.vader import SentimentIntensityAnalyzer

# 감성 분석 인스턴스 생성 sid = SentimentIntensityAnalyzer()
# 부정 문장으로 테스트 print(sid.polarity_scores("This customer service is terrible."))
{'neg': 0.437, 'neu': 0.563, 'pos': 0.0, 'compound': -0.4767}
Python으로 배우는 음성 언어 처리

전사 텍스트 감성 분석

# call_3의 고객 채널을 전사
call_3_channel_2_text = transcribe_audio("call_3_channel_2.wav")
print(call_3_channel_2_text)
"hey Dave is this any better do I order products are currently on July 1st and I haven't 
received the product a three-week step down this parable 6987 5"
# call_3 고객 채널에 감성 분석 수행
sid.polarity_scores(call_3_channel_2_text)
{'neg': 0.0, 'neu': 0.892, 'pos': 0.108, 'compound': 0.4404}
Python으로 배우는 음성 언어 처리

문장 단위 분석

call_3_paid_api_text = "Okay. Yeah. Hi, Diane. This is paid on this call and obvi..."
# 문장 토크나이저 불러오기
from nltk.tokenize import sent_tokenize

# 문장별 감성 측정 for sentence in sent_tokenize(call_3_paid_api_text): print(sentence) print(sid.polarity_scores(sentence))
Python으로 배우는 음성 언어 처리

문장 단위 분석

Okay.
{'neg': 0.0, 'neu': 0.0, 'pos': 1.0, 'compound': 0.2263}
Yeah.
{'neg': 0.0, 'neu': 0.0, 'pos': 1.0, 'compound': 0.296}
Hi, Diane.
{'neg': 0.0, 'neu': 1.0, 'pos': 0.0, 'compound': 0.0}
This is paid on this call and obviously the status of my orders at three weeks ago, 
and that service is terrible.
{'neg': 0.129, 'neu': 0.871, 'pos': 0.0, 'compound': -0.4767}
Is this any better?
{'neg': 0.0, 'neu': 0.508, 'pos': 0.492, 'compound': 0.4404}
Yes...
Python으로 배우는 음성 언어 처리

코딩해 봅시다!

Python으로 배우는 음성 언어 처리

Preparing Video For Download...