概要
歌を聞かせた。
彼はその歌を聴き、
Positiveな感情になると笑い😃、
Negativeな感情になると怒り😠、
Neutralな感情になると。。。😐
(COTOHAの感情分析APIを使って、歌の歌詞からどのような感情をくみ取るのかを試した。COTOHA API for Developersに登録してすぐに、感情分析APIを試せるようWEBアプリも作った。)
結果
とりあえず歴代CDシングル売り上げ枚数ランキングを聞かせた。
「1位から順に!カウントアップ!👆」
1.(457.7万枚)およげ!たいやきくん
😠
"sentiment": "Negative"
"score": 0.5
Response
{"result":{"sentiment":"Negative","score":0.5,"emotional_phrase":[{"form":"こころがはずむ","emotion":"喜ぶ"},{"form":"たのしい","emotion":"P"},{"form":"おもい","emotion":"N"},{"form":"ひろいぜ","emotion":"PN"},{"form":"いじめられる","emotion":"N"},{"form":"もがいて","emotion":"N"},{"form":"こげある","emotion":"N"},{"form":"うまそう","emotion":"P"}]},"status":0,"message":"OK"}
2.(325.6万枚)女のみち
😠
"sentiment": "Negative"
"score": 0.2011977885862898
Response
{"result":{"sentiment":"Negative","score":0.2011977885862898,"emotional_phrase":[{"form":"みちならば暗い","emotion":"N"},{"form":"恋","emotion":"好ましい,切ない"},{"form":"幸せ","emotion":"P"},{"form":"つらい","emotion":"N"},{"form":"泣","emotion":"喜ぶ,悲しい,切ない"},{"form":"すがって泣いたうぶな","emotion":"PN"},{"form":"いけない","emotion":"N"},{"form":"みちならば","emotion":"PN"},{"form":"捨てた","emotion":"N"},{"form":"いじめる","emotion":"N"}]},"status":0,"message":"OK"}
3.(313.2万枚)世界に一つだけの花
😃
"sentiment": "Positive"
"score": 0.08995079776388203
Response
{"result":{"sentiment":"Positive","score":0.08995079776388203,"emotional_phrase":[{"form":"うれしそうな","emotion":"P"},{"form":"笑顔","emotion":"安心"},{"form":"好み","emotion":"好ましい"},{"form":"困った","emotion":"N"},{"form":"迷","emotion":"不安"},{"form":"笑い","emotion":"喜ぶ"},{"form":"もともと特別な","emotion":"PN"},{"form":"ひとそれぞれ","emotion":"PN"},{"form":"きれいだ","emotion":"P"},{"form":"争う","emotion":"N"},{"form":"誇らしげ","emotion":"P"},{"form":"咲かせる","emotion":"P"},{"form":"一生懸命","emotion":"PN"},{"form":"頑張って","emotion":"P"},{"form":"仕方ないね","emotion":"N"},{"form":"色とりどり","emotion":"P"},{"form":"気づかない","emotion":"N"},{"form":"小さい","emotion":"PN"},{"form":"同じものはない","emotion":"PN"}]},"status":0,"message":"OK"}
4.(293.6万枚)TSUNAMI
😠
"sentiment": "Negative"
"score": 0.10121480950551423
Response
{"result":{"sentiment":"Negative","score":0.10121480950551423,"emotional_phrase":[{"form":"愛","emotion":"安心,好ましい"},{"form":"愛しい","emotion":"P"},{"form":"怯えてる","emotion":"不安"},{"form":"悲しみ","emotion":"悲しい"},{"form":"恋","emotion":"好ましい,切ない"},{"form":"好きな","emotion":"P"},{"form":"戸惑う","emotion":"N"},{"form":"泣いた","emotion":"N"},{"form":"涙","emotion":"喜ぶ,不安,悲しい,切ない"},{"form":"微笑","emotion":"安心"},{"form":"弱気な","emotion":"N"},{"form":"すがる","emotion":"N"},{"form":"涙もろい","emotion":"PN"},{"form":"清か","emotion":"P"},{"form":"魔性","emotion":"N"},{"form":"彷徨う","emotion":"N"},{"form":"枯れる","emotion":"N"},{"form":"素直に","emotion":"P"},{"form":"侘しさ","emotion":"PN"},{"form":"鏡のような","emotion":"P"},{"form":"深い","emotion":"PN"},{"form":"気付いてる","emotion":"P"},{"form":"張り裂けそうな","emotion":"N"}]},"status":0,"message":"OK"}
5.(291.8万枚)だんご3兄弟
😠
"sentiment": "Negative"
"score": 0.06456371454543736
Response
{"result":{"sentiment":"Negative","score":0.06456371454543736,"emotional_phrase":[{"form":"かたくな","emotion":"不安"},{"form":"ささって","emotion":"P"},{"form":"まれ","emotion":"PN"},{"form":"たくさん","emotion":"PN"},{"form":"こげ","emotion":"N"},{"form":"かたくなりました","emotion":"PN"}]},"status":0,"message":"OK"}
6.(289.5万枚)君がいるだけで
😃
"sentiment": "Positive"
"score": 0.009547567550434202
Response
{"result":{"sentiment":"Positive","score":0.009547567550434202,"emotional_phrase":[{"form":"憧れ","emotion":"P"},{"form":"笑顔","emotion":"安心"},{"form":"くやしい","emotion":"N"},{"form":"何より大切な","emotion":"P"},{"form":"涙","emotion":"喜ぶ,切ない,不安,悲しい"},{"form":"儚い","emotion":"PN"},{"form":"強く","emotion":"PN"},{"form":"気付かせてくれたね","emotion":"P"},{"form":"ありがちな","emotion":"PN"},{"form":"つい引き込まれ","emotion":"P"},{"form":"弱さ","emotion":"N"},{"form":"忘れてた","emotion":"PN"},{"form":"もっと素直になれなかった","emotion":"N"},{"form":"わかって","emotion":"P"}]},"status":0,"message":"OK"}
7.(282.2万枚)SAY YES
😠
"sentiment": "Negative"
"score": 0.2490204168421342
Response
{"result":{"sentiment":"Negative","score":0.2490204168421342,"emotional_phrase":[{"form":"愛","emotion":"好ましい,安心"},{"form":"愛してる","emotion":"P"},{"form":"恋","emotion":"好ましい,切ない"},{"form":"寂しい","emotion":"N"},{"form":"切なさ","emotion":"PN"},{"form":"迷","emotion":"不安"},{"form":"ワガママ","emotion":"N"},{"form":"余計な","emotion":"N"},{"form":"何げなく暮らさない","emotion":"PN"},{"form":"あふれてる","emotion":"N"},{"form":"勝てない","emotion":"N"},{"form":"消えない","emotion":"P"}]},"status":0,"message":"OK"}
8.(276.6万枚)Tomorrow never knows
😃
"sentiment": "Positive"
"score": 0.007165278534051281
Response
{"result":{"sentiment":"Positive","score":0.007165278534051281,"emotional_phrase":[{"form":"愛した","emotion":"P"},{"form":"悲しい","emotion":"N"},{"form":"孤独な","emotion":"PN"},{"form":"寂しい","emotion":"N"},{"form":"愛される喜び","emotion":"P"},{"form":"消えた帰らぬ","emotion":"P"},{"form":"すれ違う","emotion":"N"},{"form":"無邪気に","emotion":"P"},{"form":"裏切れる","emotion":"N"},{"form":"欲しがっていた","emotion":"P"},{"form":"分かり合えた","emotion":"P"},{"form":"夢中で駆け抜ける","emotion":"P"},{"form":"勝利","emotion":"P"},{"form":"敗北もない","emotion":"P"},{"form":"忘れてゆく","emotion":"PN"},{"form":"避けて通れない","emotion":"P"},{"form":"果てしない","emotion":"P"},{"form":"優しさ","emotion":"P"},{"form":"長い","emotion":"PN"},{"form":"癒える","emotion":"P"},{"form":"少し","emotion":"PN"}]},"status":0,"message":"OK"}
9.(258.8万枚)ラブ・ストーリーは突然に
😃
"sentiment": "Positive"
"score": 0.060429544970368884
Response
{"result":{"sentiment":"Positive","score":0.060429544970368884,"emotional_phrase":[{"form":"もっと好き","emotion":"P"},{"form":"もう心揺れたりしないで切ない","emotion":"PN"},{"form":"揺れたり","emotion":"興奮"},{"form":"いい","emotion":"P"},{"form":"分からない","emotion":"N"},{"form":"消えてゆく","emotion":"N"},{"form":"あんまりすてきだ","emotion":"P"},{"form":"甘く","emotion":"PN"},{"form":"やわらかく","emotion":"PN"},{"form":"心が動いた","emotion":"P"},{"form":"忘れない","emotion":"PN"},{"form":"心揺れたりしないで","emotion":"PN"}]},"status":0,"message":"OK"}
10.(248.9万枚)LOVE LOVE LOVE
😃
"sentiment": "Positive"
"score": 0.24542462771149284
Response
{"result":{"sentiment":"Positive","score":0.24542462771149284,"emotional_phrase":[{"form":"愛","emotion":"安心,好ましい"},{"form":"愛してる","emotion":"P"},{"form":"すごく好きな","emotion":"P"},{"form":"涙","emotion":"喜ぶ,切ない,不安,悲しい"},{"form":"すっごく","emotion":"PN"},{"form":"うまく","emotion":"P"},{"form":"願う","emotion":"P"},{"form":"少しずつ思い出になって","emotion":"P"}]},"status":0,"message":"OK"}
番外編(何となく気になった曲)
大きなのっぽの古時計
😃
"sentiment": "Positive"
"score": 0.30601098537139876
Response
{"result":{"sentiment":"Positive","score":0.30601098537139876,"emotional_phrase":[{"form":"うれしい","emotion":"P"},{"form":"かなしい","emotion":"N"},{"form":"のっぽの","emotion":"PN"},{"form":"ごじまんの","emotion":"PN"},{"form":"きれいな","emotion":"P"}]},"status":0,"message":"OK"}
千の風になって
😃
"sentiment": "Positive"
"score": 0.14780720679775194,
Response
{"result":{"sentiment":"Positive""score":0.14780720679775194,"emotional_phrase":[{"form":"泣かないでください","emotion":"P"},{"form":"きらめく","emotion":"P"},{"form":"見守る","emotion":"P"}]},"status":0,"message":"OK"}
パプリカ
😃
"sentiment": "Positive"
"score": 0.01385186275421083
Response
{"result":{"sentiment":"Positive","score":0.01385186275421083,"emotional_phrase":[{"form":"泣いてた","emotion":"N"},{"form":"喜び","emotion":"P"},{"form":"晴れた","emotion":"P"},{"form":"燻り","emotion":"N"},{"form":"慰める","emotion":"P"},{"form":"まれ","emotion":"PN"}]},"status":0,"message":"OK"}
WEBアプリ化
COTOHA API for Developersに登録した人限定ではあるが、同じ遊びが出来るようにした。(簡単に登録可)
以下URLで遊ぶには、登録後に取得できる、Client IDとClient secretが必要。
https://cotoha-demo.now.sh/
Client IDとClient secretは、画面リフレッシュのたびに入力しなおすのは面倒。なので、ブラウザのlocalstrageにて情報を保持している。
技術
アプリ化に伴い、以下の技術を使用。
- Nuxt.js【JavaScript framework】
- ant-design-vue【Css framework】
- Now【Deploy】
- Express【API】
server.js
server.js
constexpress=require('express')constrequest=require('request')constapp=express()// serverconstport=process.env.PORT||5000app.listen(port,err=>{if(err)throwerrconsole.log(`> Ready On Server http://localhost:${port}`)})// APIapp.get('/getToken',function(req,res,next){(()=>{returnnewPromise(r=>{if(req.query.ClientID&&req.query.Clientsecret&&req.query.AccessTokenPublishURL){constAccessTokenPublishURL=req.query.AccessTokenPublishURLconstClientID=req.query.ClientIDconstClientsecret=req.query.Clientsecretconstheaders={'Content-Type':'application/json'}constdata={'grantType':'client_credentials','clientId':ClientID,'clientSecret':Clientsecret}constoptions={url:AccessTokenPublishURL,method:'POST',headers:headers,json:data}request(options,(error,response,body)=>{returnr(body)})}else{r('Parameter is incorrect')}})})().then(data=>{res.send(data)}).catch(error=>{res.send(error)})})app.get('/cotohaApiSimilarity',function(req,res,next){(()=>{returnnewPromise(r=>{if(req.query.sentence&&req.query.token){constsentence=req.query.sentenceconsttoken=req.query.tokenconstheaders={'Content-Type':'application/json;charset=UTF-8','Authorization':`Bearer ${token}`}constdata={'sentence':sentence,}constoptions={url:'https://api.ce-cotoha.com/api/dev/nlp/v1/sentiment',method:'POST',headers:headers,json:data}request(options,(error,response,body)=>{returnr(body)})}else{r('Parameter is incorrect')}})})().then(data=>{res.send(data)}).catch(error=>{res.send(error)})})
あとがき
他のAPIと組み合わせれば、話す内容によって表情を変えるbotが簡単に出来そう。
あと要約(β)API・キーワード抽出API・言い淀み除去(β)・音声認識誤り検知(β)・音声認識API ここら辺のを使って、音声データから議事録を作るWEBアプリ(WEBサービス)作りたい。。。時間が欲しい。。。
おまけ
Q. さて、これは誰が歌っているのさくらの結果でしょうか???↓
さくら
😃
"sentiment": "Positive",
"score": 0.0010436678748683892,
Response
{"result":{"sentiment":"Positive","score":0.0010436678748683892,"emotional_phrase":[{"form":"また気になる","emotion":"PN"},{"form":"忘れた","emotion":"PN"},{"form":"淡い","emotion":"PN"},{"form":"意味なく","emotion":"N"},{"form":"変わらない","emotion":"PN"},{"form":"甦る","emotion":"PN"},{"form":"長い","emotion":"PN"},{"form":"たわいない","emotion":"PN"},{"form":"気付けば","emotion":"P"},{"form":"誘われ","emotion":"P"},{"form":"すり抜けた","emotion":"PN"},{"form":"分からなかった","emotion":"N"},{"form":"若かった","emotion":"P"},{"form":"香る","emotion":"P"},{"form":"暖かい","emotion":"P"},{"form":"こぼれる","emotion":"N"},{"form":"消えてしまうよ","emotion":"N"}]},"status":0,"message":"OK"}