Hello everyone, today we are going to build an interesting application in Python that translates the audio language from YouTube into another language.
This interesting tool may be useful, for example, if you want to see any video from YouTube that you cannot understand and you can translate the video into your favorite language. Moreover can be helpful to people who have visual problems but can listen as well.
For example, if you have this video in English,
and you want to translate for example to Spanish
or even into an amazing Japanese language.
The structure of the program consists of taking the subscripts of YouTube and translating them, if they do not exist, then the audio is extracted, and is applied the technique of speech recognition and then applied the technique of text to speech then it is replaced the audio-video with the translated audio.
Notice that this program is not designed to translate musical videos or videos larger than 10 minutes. Because there are limits to the APIs used in this program. Moreover, the quality of the audio should be good.
Well, it is time to explain how to use this program, first of all, we need to create our environment.
First, you need to install anaconda at this link
additionally, we need Git, you can download it here.
You can create an environment called youtube-translator, but you can put the name that you like.
conda create -n youtube-translator python==3.8
If you are running anaconda for the first time, you should init conda with the shell that you want to work, in this case, I choose the cmd.exe
conda init cmd.exe
and then close and open the terminal
conda activate youtube-translator
if you want to use the notebook to run this app type the following commands:
conda install ipykernel
python -m ipykernel install --user --name youtube-translator --display-name "Python (Youtube)"
For this project, we need to install the following repository
then we enter the directory
then you enter the folder that has been created
and for today, we are going to run a simple WebApp so go to the folder Gradio
and then we install all the requirements by typing
pip install -r requirements.txt
once was installed then you are ready to execute the app.
To execute the app just type
and then you will see
then copy the local URL and open your favorite web browser and paste it, or just click http://127.0.0.1:7860/ and it will open something like
Then just for example click over the first example and click submit, you wait about a minute and then play.
You can choose the initial language that is the source originally and the final language is the language that you want.
The previous English video also can be translated into German
and even Italian
For more videos, you can visit a live version of this program at HuggingFace here
You can see also the original version of this post here
For more posts like this visit https://ruslanmv.com/
Congratulations! You have played with me in creating amazing videos from YouTube with Python.