Voice cloning is a popular deep learning application in the past two years , It allows you to learn the way an object speaks and its tone from a few seconds of audio , And use it to generate new voice .
Let's take a look at the SV2TTS Practice imitating the effect of reading the following sentence :
She is beginning to get many wrinkles around her eyes.
Training set :
clone 、 Imitation effect (She is beginning to get many wrinkles around her eyes.):
The result is right , If you don't know it is Python Generated , I thought it was really a blessing .
Let's teach you how to use Real-Time-Voice-Cloning The project clones the voice and generates the desired statement .
1. Get ready
You can go to Real-Time-Voice-Cloning Project download the code of this project and the model completed by pre training .( Be careful , need Python 3.6 above To run this project ):
https://github.com/CorentinJ/Real-Time-Voice-Cloning
If your network speed is poor , Can't download github Project and its pre training model , Can be in Python Practical treasure Official account back office reply Clone voice Download the complete project code and pre training model .
After downloading the project code , You also need to download two important dependencies :
PyTorch(> = 1.0.1)
https://pytorch.org/get-started/locally/
ffmpeg
https://ffmpeg.org/download.html
among ,PyTorch The official guide to has been written very clearly , You can install it according to your own needs .
ffmpeg We have covered the installation of in detail in this article :Python Multiple music format conversion ( Batch ) Practical course , Here, I will explain the installation guide of each system again :
Mac ( Open the terminal (Terminal), use homebrew install ):
brew install ffmpeg --with-libvorbis --with-sdl2 --with-theora
Linux:
apt-get install ffmpeg libavcodec-extra
Windows:
1. Go to the following link , Click on windows The corresponding icon , Enter the download interface and click download Download button :
http://ffmpeg.org/download.html#build-windows
2. Unzip download okay zip File to specified directory
3. Put the extracted files in the directory bin Catalog ( contain ffmpeg.exe ) Added to the path In the environment variables
After the installation of the above two important dependencies , At terminal 、 Enter the project directory from the command line , install Python rely on :
pip install -r requirements.txt
This command will install all requirements.txt All dependencies in . After completing the above dependent installation , We can go on to the next step .
2. Download pre training model ( Optional )
If you use the project documents provided by us , You don't have to do this again , Because the pre training models have been put in .
If you of no avail Python The project code provided by the practical dictionary , You also need to download the pre training model :https://github.com/CorentinJ/Real-Time-Voice-Cloning/wiki/Pretrained-models
Unzip after download pretrained.zip Put the corresponding models into the corresponding positions of the project :
encoder\saved_models\pretrained.pt
synthesizer\saved_models\pretrained\pretrained.pt
vocoder\saved_models\pretrained\pretrained.pt
3. Try cloning voice
Pick any voice of the person you want to clone , Probably 30 About seconds , Put it in the project folder . Then run the command in this folder :
python demo_cli.py
If everything goes well , It will appear allowing you to select the training voice file :
At this point, enter a speech you have prepared , Wait for it to finish training , It will let you type the text you want to imitate :
Like in the picture above , I entered :
She is beginning to get many wrinkles around her eyes.
The cloning result will be read out automatically after the program is generated , If you don't hear the cloning results , No problem , The program will save it in the current folder , Name it demo_output_xx.wav.
Double click to open this file , It is the result of voice cloning generated by it , Listen to it , Is it the effect you want ?
If you don't achieve your desired results , Please check the training set for any noise 、 Is it long enough 、 Is there anyone else involved , These factors may lead to unsatisfactory cloning effect .
This is the end of our article , If you like today's Python Practical course , Stay tuned Python Practical treasure .
Any questions , You can reply in official account. : Add group , Answer accordingly Red letter verification information , Enter the mutual aid group and ask .
Originality is not easy. , I hope you can praise me and support me to continue to create , thank you !
Click below to read the original text for a better reading experience
Python Practical treasure (pythondict.com)
It's not just a treasure book
Welcome to the official account :Python Practical treasure