PRIYANKA VERGADIA: Hey, everyone.
How are you?
Are you excited about this episode?
[MUSIC PLAYING]
Welcome to AI Adventures, where we explore the art, science,
and tools of machine learning.
I am Priyanka Vergadia and in this episode,
I'm going to show you a tool that
enables you to automatically translate your video and audio
content to text in real time.
World has become rather small with technology.
We are all customers of services that are made
in another part of the world.
So we experience situations where the audio or video
is in a language that we don't speak,
and as a developer of such global apps,
we clearly need to overcome the language barrier,
and it's not as simple as it seems.
But what's so complicated about it?
It's the data and the files, because they are not
in the form of text.
We have to first convert original data into text
by using speech to text to get a transcription.
Then we need to feed those transcriptions
into the Translation API to get the translated text.
These are a lot of steps, which cause a lot of friction
and add latency along the way.
And it is much harder to get a good quality translation
because you might lose context while splitting sentences.
So you eventually make a trade off
between quality, speed, and ease of deployment.
That's where Media Translation API comes in.
It simplifies this process by abstracting away
the transcription and translation behind a single API
call, allowing you to get real-time translation
from video and audio data with high translation accuracy.
There are a large number of use cases for this.
You can enable real-time engagement for users
by streaming translations from a microphone
or pre-recorded audio file.
You can power an interactive experience
on your platform with video chat with translated captions
or add subtitles to your videos real time as they are played.
Now let's see how it works.
I'm going to say a few things here
and we will see how Media Translation API translates
the microphone input into text.
"New Delhi is the capital of India.
Washington DC is the capital of the United States."
Here we see that the API is trying
to understand the input from the microphone
and giving us the partial and the final translation
in real time.
Now how did I set this up?
Let me show you.
In our project, we enable Media Translation API
and get the service account and key for authentication.
Get the Python code sample from GitHub, and in the Media
Translation folder, we see the files translate from file
and translate from mic.
First, we create a Python virtual environment
and install our dependencies from requirements.text.
Now if we examine or translate from mic file,
we see that we are creating a client for the Media
Translation API service.
This client includes the audio encoding, the language
we will speak into the microphone,
and the language we want our translations to be in.
Then with that client, we stream the audio from our microphone
up to the Cloud and start listening to the responses
from the service, and as we listen,
we are printing those responses as an output.
This is also where you would incorporate this output
into your application.
Now, while we are here, let's change our source language
to Hindi and target language to English, and try this again.
Now let's say.
[SPEAKING HINDI]
And it rightly says, "Hi, how are you today?
Weather is very nice today.
We should go out for a walk."
Decent, right?
In this episode, we learned how Media Translation API delivers
high quality real-time speech translation to our applications
directly from our microphone.
You can even provide an input audio file and achieve
a similar output.
There's a sample in the same folder.
Try it out yourself and let me know how
it goes in the comments below.
[SPEAKING HINDI] like or subscribe [SPEAKING HINDI]..