How To Analyse Emotions Using Microsoft Azure | R Programming

How To Analyse Emotions Using Microsoft Azure

Objective: To Analyse the emotions of Barack Obama 


Step 1: Get an access to Microsoft Azure Face API using this Link

Step 2: Install and Load the Required Package in R

>install.packages('httr')
>library(httr)

Step 3: Use following commands to analyze the emotions

>URL <- 'https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize'
>EmotionKey <- '4815dd63256245ffa5214e5b14b3721d'

>mybody = upload_file("/Users/planetanalytics/Desktop/image.jpg")

>faceEMO <- POST(
  url = URL,
  content_type('application/octet-stream'), add_headers(.headers = c('Ocp-Apim-Subscription-Key' = emotionKey)),
  body = mybody,
  encode = 'json'
)
>Face_emotions <- content(faceEMO)

>Output_emotions <- as.data.frame(Face_emotions)
>View(Output_emotions)
>write.csv(Output_emotions,file = "Facemotionss.csv")


Output: