- [Paul] Next up, we're going to test drive the app
and to do that, we're going to use the ipython command
to run the script, which you'll find here
in the ch13 folder that goes along
with this particular lesson.
SimpleLanguageTranslator.py is the source code file
that we'll be walking our way through in subsequent videos.
Now, when you run this, it is possible
that the pydub playback module that we use in this app
could issue some warnings on your system.
It depends on whether or not
something called ffmpeg is installed.
The warnings that you get are actually
for features that we don't use in that module
so you can ignore the warnings,
or if you would prefer not to get the warnings at all,
you can simply go to this URL
and install ffmpeg on your system,
and they provide versions for Windows, Mac OS
and Linux as well.
Because I don't speak Spanish,
one of the things that I did
was to create a video that shows the app executing
so that I can point things out to you as we go along
and so that you get a smooth experience as well,
but let me just jump for a moment out to my terminal window
and you can see here I'm in the Ch13 folder.
Here is the .py file that we're going to execute
and separately, I also created a Jupiter notebook version
of this example as well.
Now because I don't speak Spanish,
this wav file here actually contains a Spanish response,
so what I'm going to do when I run this,
and you'll see this in the video that I'm going to play
as part of this in a moment
is I'm going to ask the English question,
where is the closest bathroom?
And the spoken response was actually created
using the IBM Watson Services.
What I did is I created the response
that I wanted in English,
I ran it through the translator
and then I got the Spanish text,
and I ran that through the Text to Speech service
to create this SpokenResponse.wav file
which you can play back at a loud volume
so that your mic on your computer can pick it up
and that can then be translated back into English,
so transcribe from Spanish to text
and then translate the text to English
and then is spoken as English as well.
Again, if I want to run this from the command line,
I would go ahead
and type ipython
SimpleLanguageTranslator.py
and when I press enter, it's then going to prompt me
to press the Enter key so that I can now speak to the app.
At this point, what I'm going to do
is play the video version of this
and I'm going to pause the video at several different points
so that I can talk about what's going on
in each part of the app.
At this point, let me switch over to a media player
where I've already loaded the video
that I'm going to show you.
Now, for convenience, when I ran this app on my screen
I had my command line over here on the left
where I executed the ipython command to launch the app
and over here on the right I had a web browser open
where I dragged and dropped the SpokenResponse.wav file
onto the web browser, and here in Google Chrome,
it gave me a media player that I could use
to conveniently play the Spanish response
that I'm going to demonstrate for you in just a moment.
Basically in step one of this app,
it prompts you to press Enter,
then ask your question in English
and as part of step one,
it is going to record five seconds of audio
and we did that for simplicity.
It is possible to write code, for instance,
that would start recording when it hears somebody speak
and then terminate the recording
after a delay of some amount of time
where we don't hear, or where the app rather
doesn't hear any audio,
but that involves a lot more code
and for that reason we just decided for simplicity
to do five seconds of audio in this demonstration.
Let me go ahead and play the video through step one,
then I'll pause it and continue the discussion.
- [English Male Recording] Where is the nearest bathroom?
- [Paul] Okay, so let's stop there for a moment.
At this point, we've recorded five seconds of audio.
When it displays recording complete,
it is now getting ready for step two here
where it is sending the audio file itself,
which we saved onto our machine locally
and in fact, you'll see these files show up
in the ch13 folder where you're executing the script from.
It takes the recorded English audio
and it sends it off to Watson's Speech to Text service
for transcription into English.
Then, in step three, it receives back the Spanish,
I'm sorry, in step three it runs the English text
through the language translator service
to get the Spanish text back.
Then in step four, it uses Watson's Text to Speech service
to convert that into a Spanish audio file
and in step five, it plays the Spanish audio file.
So I'm going to play the video now
through those separate steps.
- [Spanish Recording] (replies in Spanish)
- [Paul] Okay, let's stop there for a moment.
As you can see, we got back the English transcription,
where is the nearest bathroom?
We took the English transcription,
sent it through the language translator
which gave me the Spanish representation of that question
and then separately, we took the Spanish text,
ran it through the Text to Speech service
and you heard the spoken response,
which by the way, is also a wav file now
that's stored locally in the ch13 folder.
At this point, we finish the first five steps
and you can see it's now prompting for us to press enter
and speak the Spanish answer.
So this is where the audio file,
over on the right hand side here, comes in.
When I ran this demo, I pressed Enter
and then I immediately pressed play on this spoken response
and I had the volume on my computer up loud enough
that my microphone could pick up the audio
that was coming through,
and that audio in a five step process, once again,
we're going to speak the Spanish audio
and if you speak Spanish, you can just speak directly
rather than using my file.
We're gonna speak the Spanish audio,
we're gonna take the Spanish audio
and transcribe it into Spanish text,
we're going to take the Spanish text
and translate it into English text
and then we're going to take the English text
and turn it into speech once again and play that back.
So here's the remainder of the app in action.
- [Spanish Recording] (speaks in Spanish)
- [English Female Recording] The nearest bathroom
is in the restaurant.
- [Paul] And at that point, the app is complete
and it looks like I finished recording the video
before we actually saw the command prompt come back to us,
but you get the basic idea.
So we have basically 10 steps
that we're going to go through in the code,
and you'll see we have a main function
in this example where we list out those 10 steps
that I just walked you through,
and inside of those 10 steps are going to be
several calls off to the Watson web services
to perform the tasks that we specified in here.
Now, there is some additional code
in the example that we'll go through as well,
which is the code for the recording
and playback of the audio files.
That is separate from the IBM Watson tools
and that's actually more of the code than anything else
inside of this particular example.