Language Translation and Identification in 10 Minutes with Python and Watson AI

Nicholas Renotte · Intermediate ·💻 AI-Assisted Coding ·5y ago

Key Takeaways

The video demonstrates language translation and identification using IBM Watson Language Translator with Python in a Jupyter Notebook, showcasing the use of Watson Language Translator service to convert text to speech and build an AI-powered travel assistant.

Full Transcript

language barriers are a thing of the past mayday mayday hello can you hear us can you hear us we are thinking we are thinking hello this is the german coast guard we are thinking we're thinking what are you thinking about all right maybe not just yet so in today's video we're going to be taking a look at how we can use what's in language translation to convert text into different languages we're also going to be building an ai powered travel assistant want to learn more let's take a look at what we're going through in greater detail so we're going to be covering everything you need to get up and started to translate languages specifically we're going to be taking a look at how we can translate text from one language to another as well as how to use different language models we'll then also look at how we can identify different languages from a piece of text and last but not least we're going to be building an ai powered travel assistant so we'll be able to take text from one language convert it to another and then generate the speech for that as well so this is going to allow us to speak in english and convert all the way through to generating speech in a different language so in terms of how we're going to be doing it we're going to be capturing text using python inside of a jupyter notebook we'll then take that text send it to the watson language translator service to convert it into a different language likewise we'll also do a similar thing in order to identify languages and in order to build our ai powered travel assistant we'll take that same text first convert it to a different language and then we'll take that converted text send it to our text to speech service in order to generate our ai powered speech ready to get to it let's do it so we're going to be working inside of jupiter notebooks for this now there's four key steps that we need to go through these are authenticating translating identifying languages and then last but not least we're also going to make an ai travel guide now before we actually get to authenticating we need to install some dependencies and the main dependency that we need is ibm watson perfect so that's our main dependency installed so in order to install it all we needed to do was type in exclamation mark pip install ibm watson that's all done and dusted now what we can get to doing is authenticating so let's just minimize this and create a few cells underneath our authenticate tab and in order to authenticate we first need to set up a service so specifically we're going to be setting up a watson language translation service in order to do that it's pretty easy all we need to do is go to cloud.ibm.com forward slash catalog then hit services and then from down here you can see that we've got a category called ai machine learning so if we select that there's going to be a heap of services now the one that we're specifically looking for is language translator so select language translator and then as soon as the language translator service page comes up you can choose which type of service you want so for this particular video we're going to be working with the light tier and that's more than enough if you're just getting started so it allows you to translate up to a million characters per month more than enough to get through this so let's choose light and hit create so once this service has been created we're going to get an api key as well as a url so these are going to be the two things that we need in order to go and translate so you can see that we've now set up our service all we need to do is select manage from over here and we'll have our api key as well as our url so let's create two variables to hold those inside of our drupal notebook so one our api key and two for our url and then what we can do is copy those into our notebook now that's done and dusted so we won't need to step into the cloud.ibm page until we get back to our ai travel guide so everything from here on out is mainly going to be inside of our drupal notebook now the next thing that we want to do is import our dependencies so in this case we're going to need to import the text translation service as well as our authenticators boom that's done so we've imported two key dependencies there so the first one is our language translator class so this is going to allow us to set up an instance of our language translator and we've brought that in from ibm watson and we've also imported the iam authenticator class so this is going to allow us to authenticate against our language translation service now the next thing that we want to do is actually authenticate so we've now gone and set up our service now what we did is we used the im authenticator class and we passed through our api key so that allows us to now use that authenticator to go and authenticate against our language translation service somebody say authenticate access now within our language translation service we've also specified our version so in this case it's the 1st of may 2018 and we've also passed through our authenticator class that we just set up here so this means that our service is going to screw that up so this means that our service is going to be accessible through the lt variable and last but not least we set our service url so this url is basically the url that we set up here and it specifies where our service is in the world wide web so that's pretty much it for authenticating now what we can actually go and do is start translating so say for example we wanted to translate hello world for example pretty simple let's go and do that now in this particular case we've got a bunch of different languages that we can actually translate from now i'll include these links in the description below so you've got access to all of these but you can see that there are a whole heap of supported languages that you can use within the watson servers so for example say we wanted to translate hello world from english to german for example similar to what we saw our coast guard do at the start of the video well what we need to do is pass through a combination of these language codes so say for example we wanted to convert english to german then we'd pass through english which is i believe en up here so you can see we've got en and then if we wanted to convert it to german then we pass through the second parameter as de so ideally what you get is something like this e n d e so that basically means that our language translator is now going to convert an english text so hello world from english to german then all we need to do is type in get result and that's our translation done now if we go and pass that out you can see that our model has converted hello world to hello welt i don't exactly have a german accent but you kind of get the idea now say for example we wanted to translate a longer body of text well what we can do is just change this text here to whatever we wanted to do so say for example we wanted to pass through we are syncing you've now got the translation stored here now if we wanted to actually access that specific piece of text what we can do is traverse our translation object and you can now see that we're extracting the translation we are sinking so this might have actually helped our submariner or our navy at the start of the video to ideally get the right message across now if we take a look at what we actually did for our translate service what we basically did is we grabbed our language translation service from up here and then used the translate method to actually go and translate our text we then pass through the text that we want to translate as well as the model so that was that code that we took a look at here so basically we combine english with german in order to perform that conversion and last but not least we use the get result method to actually go and perform that translation and grab the result back now another cool feature that you've got within the watson translation service is the ability to identify languages so say for example we didn't want to translate text we actually wanted to go and identify a specific language well we can do that as well so in order to do that we're going to run through a similar method to what we did up here for lt.translate rather this time we're going to use lt.identified identifier language so we've now gone and tried to identify the language that's stored within this sentence here now we can obviously see that that is english but let's take a look at how what's in language translation is performed so if we go and pass out our language it's giving us all of our different confidence intervals and pretty clearly it's identified english as the most likely prediction so you can see it's got a confidence of about 99.99 now what happens if we were to try to identify this particular line of text here so ideally what you'd want to see is that it's able to identify that that's german so let's try that out and there you go so it's actually gone and predicted that it's german with a reasonable degree of confidence so d e being the language code for german and our confidence in this case is about 94.8 percent so what we actually did there is we used the language translation service again but this time we used the identify method again passing through our text and using get result to identify language rather than just translate now the last thing that we might want to do is actually do a two-part conversion and this is where we get to our ai travel guide so say we wanted to convert a piece of text and then actually generate the speech from that text well we can actually stack these services together to one go and convert our text from one language to another and then two take that text and convert it to speech so this basically allows us to have a bit of a travel guide so for example our navy sailors could have gone and typed in we are sinking into german converted that to german text and then had that german text converted to speech so that he could pass it through to our coast guard so now let's go on ahead and take a look at how we can go and build our ai travel guide in order to do that we need to set up one additional service inside of our ibm cloud account the service that we actually need to bring in is the text to speech service so let's go and set that up quickly again all we need to do is capture our api key and our url for that service so before we actually go and set that up let's just set up those two variables so we'll set one up for speech to text api key and speech to text url all right so we've got two new variables so stt api key and stt url let's go and set up the service so in order to do that we're going to be going to cloud.ibm.com then just hit catalog and again we're going to be selecting services and choosing ai machine learning which we've got here then from there rather than choosing language translator this time we're going to be choosing text to speech which is this one here so again you can see it synthesizes natural sounding speech from text so let's choose that and similar to what we did for our language translation service we're going to be choosing the light plan which allows us to convert 10 000 characters per month so let's choose that one and hit create now again as soon as this service has finished creating we're going to be able to extract the api key and the url so let's choose manage and then grab our api key and paste it back into our jupyter notebook and let's grab our url as well so you can just grab the api key in the url just by hitting copy these little copy symbols so that will allow you to copy them so we'll just grab our url and paste that in as well alrighty so we've got our variables now what we want to go and do is authenticate against our speech to text service so this is going to follow a similar process to what we did up here for our language translation service so in order to do that we first need to import our dependencies so that's our text-to-speech class imported so this is basically going to operate in a similar manner to our language translation service sdk that we brought up here now what we're going to do is go through those authentication steps again oh i should actually point out that we're actually using the text to speech server so we've actually called it stt here so let's just update these it should be text to speech text to speech it's just a naming convention it doesn't really matter it's still going to work all right so now that we've changed those let's go and rerun that cell and let's authenticate all right so we've now gone and authenticated so again what we've done is we've created a new instance of our iam authenticator then we've set up our text-to-speech sdk so we've created a new class of the text-to-speech service and passed through our authenticator and then last but not least we've set our service url so this is that url that we just set up here now what we can go and do is perform our ai travel guide function so say for example we actually wanted to convert our english speech so we are syncing to german first and then convert that from text to speech so let's go ahead and do that so the first thing that we've gone and done is created a translation so we've gone and converted we are syncing please send help and we've passed our model id for english to german now what we need to do is extract that piece of text first up all right so we've actually extracted our text now the next step so this is where we actually take that text and convert it to speech so we've now gone and taken our text which we had here and converted its speech let's quickly go through this so i actually covered this in greater detail in another video but we'll quickly run through it again so we've set up a new file called help.mp3 so this is going to be the file that we write out then we've used the text to speech dot synthesize method to go and convert our text to speech so we're also going to be outputting it to audio dash mp3 and we're using a specific voice so whenever we're using the text-to-speech method you've got a whole bunch of supported languages and voices so in this case what we can do is choose the voice that we want so i've chosen bridget so that's a german voice there's also a whole bunch of others as well now the last thing that we've gone and done is we've output our speech to an audio file so if we go into our folder you can see that we've got a file called help so if we go and play that resington peter that's our converted speech so we've now gone and taken english text converted that to german and then converted it to german speech now say for example we wanted to use a different language well all we need to do is change our first up our model id so say for example we wanted to convert to chinese well let's delete de then find our chinese language model so you can see here that we've got chinese simplified and chinese traditional so we'll grab simplified then we just need to paste that there so you can see now that rather than converting from english to german we've now gone and converted from english to chinese and we've got our chinese translation now if we wanted to go and convert this speech again all we need to do is change our voice model so if we go to our voice model there should be a chinese voice model you can see we've got a mandarin one then let's grab one of these so say for example we want a leonard's voice we can grab that language model and change our voice model here and now if we scroll over back into our folder we should have a language translation that rather than being from english to german is now from english to chinese women and there you go so we've covered quite a fair bit in this video so we've authenticated against our service we've also translated our text to speech and use a bunch of different language models so we did english to german here and we also did english to chinese down here we also used the identify function to allow us to identify different languages in text and then last but not least we created an ai travel guide so we first up converted our text in one language to text in a different language and then we used that translated text to convert it to speech to allow us to bridge with different cultures so 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 so you get notified of any future videos if you've got any problems at all be sure to drop a mention in the comments below and i'll get right back to asap thanks again for tuning in peace [Music]

Original Description

Language barriers are a thing of the past right? Ahhh, not quite! Being able to work with text in different languages helps boost access to information for all, but sometimes working with different languages can be a pain. But it doesn't need to be. You can begin to translate and identify different languages in under 10 minutes. In this video you'll learn how to do just that! In this video you'll learn how to: 1. Translate text to other languages 2. Detect different languages from a single line of text and 3. Build a AI Travel Assistant to convert text to speech in another language! Github Repo for the Project: https://github.com/nicknochnack/LanguageTranslationandIdentification Want to learn more about it all: Translation Language Codes: https://cloud.ibm.com/docs/language-translator?topic=language-translator-translation-models Voice Models: https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices 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 · 53 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
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
54 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 use IBM Watson Language Translator with Python to translate text from one language to another, identify languages from a piece of text, and build an AI-powered travel assistant. It demonstrates the use of Watson Language Translator service to convert text to speech and showcases the creation of an AI travel guide by translating text and converting to speech.

Key Takeaways
  1. Install IBM Watson dependency using pip
  2. Authenticate with Watson Language Translation service
  3. Set up Watson Language Translation service in Cloud.ibm
  4. Create API key and URL for Watson Language Translation service
  5. Copy API key and URL into Jupyter Notebook
  6. Import text translation service and authenticators
  7. Set up language translator instance
  8. Authenticate against language translation service
  9. Translate text from English to German
  10. Access translation object to extract translated text
💡 The video demonstrates how to use IBM Watson Language Translator with Python to build an AI-powered travel assistant, showcasing the potential of AI in language translation and identification.

Related Reads

📰
Why AI Coding Widens the Senior–Junior Developer Gap
AI coding can exacerbate the senior-junior developer gap by producing code that looks polished but lacks underlying quality, making it essential for senior developers to review and mentor junior developers
Dev.to AI
📰
AI Code Security Audit for Startups: What to Check Before Deploying
Learn to secure your startup's AI-generated code with a structured security audit to prevent invisible risks and technical debt
Dev.to AI
📰
We Let AI Write a Third of Our Code. Here's the Review Process That Kept Us Sane.
Learn how to effectively review AI-generated code with a structured process, ensuring quality and sanity in AI-assisted development
Dev.to · Marketing wizr
📰
AI in Software Testing
Learn how AI is revolutionizing software testing and why it matters for efficient development
Dev.to · Thomas Silva
Up next
Azure Security Priorities for 2026: Identity, Governance, AI Security & Zero Trust
Valto Microsoft Specialists
Watch →