Get the emotion behind a conversation with IBM Watson

 At the end of this article you should be able to:

  • Access the IBM Watson Tone Analysis API.
  • Find the emotional tone behind a sentence.
  • Find the emotional Tone with messages in a chat conversation.

IBM Watson is a PAAS that is used to develop, deploy and scale AI-powered applications. Today we are going to use Watson to analyse the tone of sentences.

Before we begin I will give a simple background on tone analysis


Above is a picture showing a computer classifying human emotions

In simple words, Tone Analysis involves the use of AI to detect seven distinct conversational tones. The seven conversational tones include; frustration, impoliteness, sadness, sympathy, politeness, satisfaction and excitement. To get a more in-depth understanding of tone analysis, click here

Tone Analysis is not Sentiment Analysis

People usually mistake tone analysis for sentiment analysis but in reality, they are subtly different concepts.

Sentiment analysis tools are typically used to determine the tone of short social media communication like tweets, stays updates etc. Based on the usage of words the social media content is tagged as positive, negative and neutral.

Tone analysis involves a more detailed document-level analysis of larger documents or communication. It primarily reveals the author's writing style and the social and emotional sentiment of the article or communication. This is typically recommended on marketing material, employee commination, chat transcripts etc. to ensure that the document is in line with strategy or standards expected.

Now that we've given a base for the topic let's look at...

The Prerequisites for this Article

  • Knowledge of Python and use of pip.
  • Internet Connection.
  • An email address (to get an IBMId).
  • A text editor or Jupyter Notebook.

Before we continue you need to have an IBMID, if you don't have one, click here to get one.

Getting an IBMID is essential because we will be using the IBM text-to-speech API to build our software if you have never used IBM PAAS don't fret I'll walk you through it.

Before we get building, if you at any point during the tutorial get confused you can:

  • View the article's GitHub repository by clicking here.
  • Edit and Play around with the code in google's colab by clicking here.

    Project Flow

    Below I will explain the steps which this project is going to take
  • Install Dependencies:: Here we are going to install the necessary python packages needed to use the API.
  • Authenticate:Here we are going to provide our API credentials and link to the API.
  • Analyze Tone:Here we are going to analyze the tone of a particular sentence.
  • Analyze Chat Tone:Here we are going to analyze the tone of chats. Let us Begin

    Install Dependencies

    I am assuming you have pythonpip and a text editor or jupyter notebooks installed.

If you have the above-listed let's begin, to make use of the IBM Text-to-Speech API we are going to install the IBM-Watson library, by typing in the command listed below in your terminal or command line.

pip install ibm-watson

If you are using the jupyter notebook environment you can put down the command listed below in a cell.

Comments