Analyse ANY Conversation in 10 Minutes with Python and Watson Tone Analyser

Nicholas Renotte · Intermediate ·🤖 AI Agents & Automation ·5y ago

Key Takeaways

The video demonstrates how to analyze conversations using Watson Tone Analyzer and Python, extracting hidden insights from text and understanding user tone in conversational agents. It covers setting up the Watson Tone Analyzer service, authenticating with IAM Authenticator, and analyzing tone in strings and conversations using Python dictionaries and the analyze chat method.

Full Transcript

the tone of a conversation can go a huge way to driving a conversation in a positive or a negative manner i'm very busy well i'm sure you are i don't like your tone i'm sure you are how's that see well for that very reason we're going to be using watson tone analyzer to analyze the tone of a conversation we'll be able to extract hidden insights from a body of text to work out what the real underlying tone is let's take a look in greater detail as to what we're going to be going through so in this video we're going to be covering how to set up a watson tone analyzer service we're also going to use that tone analyzer service to analyze a body of text or a string then what we'll also do is use some advanced capability to analyze an entire conversation so we'll be able to extract a python dictionary and analyze a whole conversation with different users so that we can work out what the tone of each user actually is now in terms of how we're actually going to be doing this we're going to be working inside of a jupiter notebook and working with python we'll then use the ibm watson sdks to be able to connect and use the tone analyzer service and we'll output our results to a json object which can also be output to a text file so ready to get to it let's do it so in order to build our tone analyzer there's three key things that we're going to need to do first up we need to authenticate against the watson tone analyzer service then we're going to be able to analyze tone in a string and then the last thing that we're going to do is analyze tone within a chat so this might be two people conversing at the same time and we're going to be able to break out our chat and analyze both of those in a single api call now before we get on to any of that we need to install one key dependency and that's the ibm watson sdk so we can install that using the pip install command from within our jupyter notebook so let's add an additional cell and do that so that's our ibm watson sdk installed so you can see here that we've just put in an exclamation mark and typed in pip install ibm watson and that's allowed us to install all of those sdks now the next thing that we need to do is actually go on ahead and set up a watson tone analyzer service so this is going to allow us to authenticate to the service and eventually analyze tone and analyze our chat in order to set up a service we just need to go to cloud.ibm.com forward slash catalog and then hit services on the left hand side from here and you can see there's a whole bunch of categories we're looking for ai and machine learning and then the service that we're actually looking for is tone analyzer so that's down here in the bottom corner so let's go ahead and choose tone analyzer and this is going to allow us to set up an instance of the tone analyzer service now you can see that there's a bunch of different pricing plans in this case we're just going to be using the light plan it's more than enough to get through this tutorial and it's free so just go ahead and choose light and hit create so this is going to create a new instance of the tone analyzer service that you're going to be able to use inside of your jupyter notebook so once that service is created you'll come to the getting started with tone analyzer page so you can see all of that here now from this page we actually need to get two key things so we need to get our service url as well as our api key now those are pretty easy to get all you need to do is hit manage and you can see that we've got our api key here as well as our url and you can pretty easily just copy these over now before we copy them over however what we want to do is set up two variables within our jupyter notebook so these are going to allow us to hold our api key as well as our url so let's go back to our jupyter notebook and add in an additional couple of cells and then create some variables to hold those so we'll create one for our api key and one for our url then what we can do is go and copy those values over from our service and paste them into our variables that we've got here so we've now gone and created our two new variables so we've created one variable called api key that's going to hold our api key and then one variable for our url which is going to hold our service url now the next thing that we need to do is import some dependencies so we went and installed the ibm watson service now what we're going to do is import the tone analyzer class from ibm watson and we're also going to import an authenticator so this is going to allow us to authenticate against our tone analyzer service boom all right so that's done so what we've done is we've imported the tone analyzer class from ibm watson so this is going to allow us to use the tone analyzer service and we've also imported iam authenticator from ibm cloud sdk core authenticators so this is going to allow us to set up a new authenticator to use alongside our tone analyzer service now the next thing that we need to do is actually go ahead and authenticate so let's do that so we've now gone and authenticated against our tone analyzer service so we did three key things there so we first set up an instance of the iam authenticator class and we pass through our api key so this is going to allow us to now use that authenticator with our tone analyzer instance here so what we did there is we set up a new instance of our tone analyzer variable or class we then specified the version that we want to use so there's really specific versions that you need to pass through here so in this case it's the 21st of september 2017 and we've also passed through our authenticator that we just set up here then last but not least we set our service url so this is where we take our tone analyzer service aka t a and we set our service url by passing through the url that we just set up here and that is our authentication done now what we can go and do is actually start analyzing some tone so let's delete that cell and add in a few additional ones here now in order to analyze tone it's actually pretty straightforward all we need to do is use our ta service and use the tone method and pass through a string and that's going to allow us to analyze tone so let's try that out that's our first set of tone analysis done now everything's stored within our res variable so before we take a look at that let's actually take a look at the code that we just wrote so we used our ta service which is our tone analyzer service from up here and we pass through a string so i'm feeling amazing thanks to our tone method then we trained on the get result method to basically get our result from the service now if we go and output our res value you can see that in this case the tone that we've detected is joy and we've got a confidence level of about 96 now we could change this to something a little bit more negative so say for example we're feeling a little bit under the weather this sucks i wish i wasn't let's delete that second one and now you can see that it's actually changing our tone so rather than it being joy we're now detecting sadness so this allows us to really quickly just pass through a string and analyze our tone now you can pass through a whole bunch of different strings and pass through a longer block of text and that's going to allow you to analyze tone really quickly now what happens if we wanted to for example analyze a conversation rather than a single string well what we can do is set up a conversation using a python dictionary and then use the analyze chat method to go and do that so we've now gone and set up our chat object so just to quickly go through we set up an array so you can see that we've got our square brackets here and then we've entered two dictionaries into that array so you can see that our first dictionary has two keys so text and the user and within our text we've actually got the conversational component so our first block of text is saying i feel great it's sunny outside and i've got all my work done and that's coming from a user called he who shall not be named now our second dictionary again contains a text key and a user key and in this case the conversational component is basically saying this sucks i have 500 hours more coding to do this is going to take all weekend so that's probably a comment that's typically coming from me hence you can see that you've got the user nick there now what we can do is take this whole chat object and pass it through to the tone chat method and that's going to allow us to analyze our entire chat for tone so let's go and do that so rather than analyzing a single string we've now gone and analyzed an entire chat so you can see the output of that all down here now what we actually did in order to do that bit of a tongue twister there paper piper periboo and pauly pourett need to push back the pitch on the princess and the popper project is we used the ta service but rather than using the tone method that we did up here we now used the tone chat method we then passed through our entire chat object which was this little thing up here and we use the get result method to get our result now if we output it you can see that it's split up everything into two different objects so we've got our first utterance which is this one up here and then we've got our second utterance down here as well so it's actually gone and specified for our first utterance so it's i feel great it's only outside blah blah blah that the tone is excited so it's actually going to detected that tone from that particular block of text now in our second utterance so this sucks i have like 500 hours more coding to do it's detecting that we're frustrated and that we're maybe a little bit impolite and a little bit sad so that basically shows how you can perform tone analysis on a chat rather than just a single string and that about wraps up this video thanks so much for tuning in guys hopefully you found this video useful if you did be sure to give it a thumbs up hit subscribe and tick that bell it'll mean the world to me and if you've got any questions at all or need a hand be sure to drop a mention in the comments below and i'll get right back to you no matter how big or small the question is thanks again for tuning in peace

Original Description

Tone is important. Conversational tone can positively (AND negatively) influence a lot of outcomes. This is why it's so important to understand your user's tone, particularly so when working with conversational or virtual agents. But it can be tricky, especially when all you have to go off is some text. Well, Watson Tone Analyzer can make that a helluva lot easier...in just 10 minutes. In this video you'll learn how to: 1. Setup Watson Tone Analyzer 2. Analyze Tone from a Sentence 3. Check Tone from a Conversation Github Repo for the Project: https://github.com/nicknochnack/ToneAnalysis Want to learn more about it all: Tone Analyzer Service: https://cloud.ibm.com/catalog/services/tone-analyzer Oh, and don't forget to connect with me! LinkedIn: https://www.linkedin.com/in/nicholasr... Facebook: https://www.facebook.com/nickrenotte/ GitHub: https://github.com/nicknochnack Happy coding! Nick P.s. Let me know how you go and drop a comment if you need a hand! Music by Lakey Inspired Chill Day - https://www.youtube.com/watch?v=3HjG1Y4QpVA
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Nicholas Renotte · Nicholas Renotte · 54 of 60

1 Face Detection - Build An Image Classifier with IBM Watson - Part 7
Face Detection - Build An Image Classifier with IBM Watson - Part 7
Nicholas Renotte
2 Food Image Classification - Build An Image Classifier with IBM Watson - Part 6
Food Image Classification - Build An Image Classifier with IBM Watson - Part 6
Nicholas Renotte
3 General Image Classification - Build An Image Classifier with IBM Watson - Part 5
General Image Classification - Build An Image Classifier with IBM Watson - Part 5
Nicholas Renotte
4 Installing Watson Developer Cloud - Build An Image Classifier with IBM Watson - Part 4
Installing Watson Developer Cloud - Build An Image Classifier with IBM Watson - Part 4
Nicholas Renotte
5 Generating Credentials - Build An Image Classifier with IBM Watson - Part 3
Generating Credentials - Build An Image Classifier with IBM Watson - Part 3
Nicholas Renotte
6 Creating A Service - Build An Image Classifier with IBM Watson - Part 2
Creating A Service - Build An Image Classifier with IBM Watson - Part 2
Nicholas Renotte
7 Getting an IBMid - Build An Image Classifier with IBM Watson - Part 1
Getting an IBMid - Build An Image Classifier with IBM Watson - Part 1
Nicholas Renotte
8 How to Analyse Review Data - Part 2 - Python Yelp Sentiment Analysis
How to Analyse Review Data - Part 2 - Python Yelp Sentiment Analysis
Nicholas Renotte
9 How to Lemmatize Text - Part 4 - Python Yelp Sentiment Analysis
How to Lemmatize Text - Part 4 - Python Yelp Sentiment Analysis
Nicholas Renotte
10 How to Calculate Sentiment Using TextBlob - Part 5 - Python Yelp Sentiment Analysis
How to Calculate Sentiment Using TextBlob - Part 5 - Python Yelp Sentiment Analysis
Nicholas Renotte
11 How to Collect Business Reviews Using Python - Part 1 - Python Yelp Sentiment Analysis
How to Collect Business Reviews Using Python - Part 1 - Python Yelp Sentiment Analysis
Nicholas Renotte
12 How to Clean Text Based Data for NLP - Part 3 - Python Yelp Sentiment Analysis
How to Clean Text Based Data for NLP - Part 3 - Python Yelp Sentiment Analysis
Nicholas Renotte
13 How to Setup a IBM Watson Personality Insights Service - Part 1 - Watson Personality Insights
How to Setup a IBM Watson Personality Insights Service - Part 1 - Watson Personality Insights
Nicholas Renotte
14 How to Create a Customer Profile with IBM Watson - Part 2 - Watson Personality Insights
How to Create a Customer Profile with IBM Watson - Part 2 - Watson Personality Insights
Nicholas Renotte
15 Visualising The Profile   Part 3   Watson Personality Insights
Visualising The Profile Part 3 Watson Personality Insights
Nicholas Renotte
16 How to Plot Personality Insights Features at Lightspeed - Part 4  - IBM Watson Personality Insights
How to Plot Personality Insights Features at Lightspeed - Part 4 - IBM Watson Personality Insights
Nicholas Renotte
17 Getting Started With IBM Watson Studio Machine Learning - Part 1 - Predicting Used Car Prices
Getting Started With IBM Watson Studio Machine Learning - Part 1 - Predicting Used Car Prices
Nicholas Renotte
18 Upload and Visualize Data In IBM Watson Studio - Part 2 - Predicting Used Car Prices
Upload and Visualize Data In IBM Watson Studio - Part 2 - Predicting Used Car Prices
Nicholas Renotte
19 Clean Data and Feature Engineer in IBM Watson Studio - Part  3 - Predict Used Car Prices
Clean Data and Feature Engineer in IBM Watson Studio - Part 3 - Predict Used Car Prices
Nicholas Renotte
20 Using Watson Model Builder to Predict Car Prices - Part 4 - Predicting Used Car Prices
Using Watson Model Builder to Predict Car Prices - Part 4 - Predicting Used Car Prices
Nicholas Renotte
21 Deploy and Make Predictions With Watson Studio - Part 5 - Predicting Used Car Prices
Deploy and Make Predictions With Watson Studio - Part 5 - Predicting Used Car Prices
Nicholas Renotte
22 Getting Started With IBM Watson Discovery - Part 1 - Stock News Crawler
Getting Started With IBM Watson Discovery - Part 1 - Stock News Crawler
Nicholas Renotte
23 How to Run Advanced Queries with Watson Discovery - Part 5 - Stock News Crawler
How to Run Advanced Queries with Watson Discovery - Part 5 - Stock News Crawler
Nicholas Renotte
24 How to Run Search Queries with IBM Watson Discovery - Part 4 - Stock News Crawler
How to Run Search Queries with IBM Watson Discovery - Part 4 - Stock News Crawler
Nicholas Renotte
25 How to Understand the Watson Discovery Data Schema  - Part 3 - Stock News Crawler
How to Understand the Watson Discovery Data Schema - Part 3 - Stock News Crawler
Nicholas Renotte
26 How to Build a Watson Discovery Web Crawler - Part 2 - Stock News Crawler
How to Build a Watson Discovery Web Crawler - Part 2 - Stock News Crawler
Nicholas Renotte
27 AI learns what to do next using Tensorflow and Python
AI learns what to do next using Tensorflow and Python
Nicholas Renotte
28 Chatbot Crash Course for Absolute Beginners - Full 20 Minute Tutorial
Chatbot Crash Course for Absolute Beginners - Full 20 Minute Tutorial
Nicholas Renotte
29 Shopify Customer Service Chatbot using Python Automation
Shopify Customer Service Chatbot using Python Automation
Nicholas Renotte
30 Building a Reddit Keyword Research Chatbot
Building a Reddit Keyword Research Chatbot
Nicholas Renotte
31 Chatbot App Tutorial with Javascript Node.js [Part 1]
Chatbot App Tutorial with Javascript Node.js [Part 1]
Nicholas Renotte
32 Javascript Chatbot From Scratch with React.Js [Part 2]
Javascript Chatbot From Scratch with React.Js [Part 2]
Nicholas Renotte
33 Predicting Churn with Automated Python Machine Learning
Predicting Churn with Automated Python Machine Learning
Nicholas Renotte
34 Sales Forecasting in Excel with Machine Learning and Python Automation
Sales Forecasting in Excel with Machine Learning and Python Automation
Nicholas Renotte
35 Automate Budgeting with Python and Planning Analytics
Automate Budgeting with Python and Planning Analytics
Nicholas Renotte
36 AI vs Machine Learning vs Deep Learning vs Data Science
AI vs Machine Learning vs Deep Learning vs Data Science
Nicholas Renotte
37 Optimizing Marketing Spend using Linear Programming || Marketing Opt PT.1
Optimizing Marketing Spend using Linear Programming || Marketing Opt PT.1
Nicholas Renotte
38 Solving Optimization Problems with Python Linear Programming
Solving Optimization Problems with Python Linear Programming
Nicholas Renotte
39 Loading Data into Planning Analytics with Python || Marketing Opt PT.2
Loading Data into Planning Analytics with Python || Marketing Opt PT.2
Nicholas Renotte
40 Building Marketing Dashboards with Planning Analytics Workspace || Marketing Opt PT.3
Building Marketing Dashboards with Planning Analytics Workspace || Marketing Opt PT.3
Nicholas Renotte
41 Optimizing Resource Allocation with Docplex and Planning Analytics || Marketing Opt PT.4
Optimizing Resource Allocation with Docplex and Planning Analytics || Marketing Opt PT.4
Nicholas Renotte
42 Exploratory Data Analysis With Pandas || Python Machine Learning PT.1
Exploratory Data Analysis With Pandas || Python Machine Learning PT.1
Nicholas Renotte
43 Preparing Pandas Dataframes for Machine Learning || Python Machine Learning PT.2
Preparing Pandas Dataframes for Machine Learning || Python Machine Learning PT.2
Nicholas Renotte
44 Python Machine Learning with Scikit Learn - Regression || Python Machine Learning PT.3
Python Machine Learning with Scikit Learn - Regression || Python Machine Learning PT.3
Nicholas Renotte
45 Deploying Machine Learning Models with Watson Machine Learning || Python Machine Learning PT.4
Deploying Machine Learning Models with Watson Machine Learning || Python Machine Learning PT.4
Nicholas Renotte
46 Mind Blowing Machine Learning Apps with Node.JS and Watson Machine Learning || Python ML PT.5
Mind Blowing Machine Learning Apps with Node.JS and Watson Machine Learning || Python ML PT.5
Nicholas Renotte
47 Build FAST Machine Learning Apps with Javascript React.Js and Watson || Python ML PT.6
Build FAST Machine Learning Apps with Javascript React.Js and Watson || Python ML PT.6
Nicholas Renotte
48 Analyzing Twitter Accounts with Python and Personality Insights
Analyzing Twitter Accounts with Python and Personality Insights
Nicholas Renotte
49 Converting Speech to Text in 10 Minutes with Python and Watson
Converting Speech to Text in 10 Minutes with Python and Watson
Nicholas Renotte
50 Build a Face Mask Detector in 20 Minutes with Watson and Python
Build a Face Mask Detector in 20 Minutes with Watson and Python
Nicholas Renotte
51 AI Text to Speech in 10 Minutes with Python and Watson TTS
AI Text to Speech in 10 Minutes with Python and Watson TTS
Nicholas Renotte
52 Pandas for Data Science in 20 Minutes | Python Crash Course
Pandas for Data Science in 20 Minutes | Python Crash Course
Nicholas Renotte
53 Language Translation and Identification in 10 Minutes with Python and Watson AI
Language Translation and Identification in 10 Minutes with Python and Watson AI
Nicholas Renotte
Analyse ANY Conversation in 10 Minutes with Python and Watson Tone Analyser
Analyse ANY Conversation in 10 Minutes with Python and Watson Tone Analyser
Nicholas Renotte
55 Deep Reinforcement Learning Tutorial for Python in 20 Minutes
Deep Reinforcement Learning Tutorial for Python in 20 Minutes
Nicholas Renotte
56 NumPy for Beginners in 15 minutes | Python Crash Course
NumPy for Beginners in 15 minutes | Python Crash Course
Nicholas Renotte
57 Real Time Pose Estimation with Tensorflow.Js and Javascript
Real Time Pose Estimation with Tensorflow.Js and Javascript
Nicholas Renotte
58 Transcribe Video to Text with Python and Watson in 15 Minutes
Transcribe Video to Text with Python and Watson in 15 Minutes
Nicholas Renotte
59 Serverless Functions for TM1/Planning Analytics in 20 Minutes
Serverless Functions for TM1/Planning Analytics in 20 Minutes
Nicholas Renotte
60 Building a AI Budget Bot for Planning Analytics with Watson Assistant in 20 Minutes
Building a AI Budget Bot for Planning Analytics with Watson Assistant in 20 Minutes
Nicholas Renotte

This video teaches how to analyze conversations using Watson Tone Analyzer and Python, enabling developers to understand user tone in conversational agents and extract hidden insights from text. By following the steps outlined in the video, developers can set up the Watson Tone Analyzer service, authenticate with IAM Authenticator, and analyze tone in strings and conversations.

Key Takeaways
  1. Install IBM Watson SDK using pip install command
  2. Set up a Watson Tone Analyzer service on cloud.ibm.com
  3. Get service URL and API key from the service page
  4. Create variables to hold API key and URL in Jupyter Notebook
  5. Import dependencies from IBM Watson and IBM Cloud SDK Core Authenticators
  6. Authenticate against Tone Analyzer service using IAM Authenticator
  7. Use Tone Analyzer service to analyze tone in a string
  8. Analyze tone in a conversation using a Python dictionary and the analyze chat method
💡 Tone analysis can be performed on a chat rather than just a single string, and the Tone Analyzer can detect tone such as excited, frustrated, impolite, and sad

Related AI Lessons

I Found Firecrawl Too Expensive for My AI Agent's Knowledge Base, So I Built My Own
Learn how to build a custom knowledge base for AI agents when existing tools like Firecrawl are too expensive, and why this matters for cost-effective AI development
Dev.to · Samuel Raphael
How Managing 500+ Employees Led Me to Build WorkforceIQ: The AI Platform I Wish I Had
Learn how managing a large workforce led to the creation of WorkforceIQ, an AI platform for workforce management, and discover its key features and benefits
Medium · Startup
AI-First MVP Development: How Startups Should Build Products in 2026
Learn how AI-first MVP development can revolutionize startup product building in 2026
Dev.to · Nasif Sid
The Three Pillars of AI Agents: Platform, LLM, and Harness
Learn the three pillars of AI agents: platform, LLM, and harness, to understand the foundation of AI development
Medium · LLM
Up next
Building Great Agent Skills: The Missing Manual
AI Engineer
Watch →