A simple python script to download audio and its subtitles from Youtube, then use google speech to text api to recognizi this audio.
python 3.6
os: Linux
There are only little steps to implement the function we want.
-
Run the following line in the command line
export GOOGLE_APPLICATION_CREDENTIALS=[path]
The
pathis the local file address you putservice-account-file.json. -
Change the
uriin themain.pyuri = 'https://www.youtube.com/watch?v=LspIeUElIFA'
Here, you can put any Youtube video uri.
-
After running
main.py, you will get a new dir, which containsaudio.flac,google_result_audio.txt,subtitles.vtt. Then, you can compare the difference between the video subtitles and the text recognized by google speech to text api.
You can have a quick look at the audio.flac, google_result_audio.txt, subtitles.vtt here.
https://www.youtube.com/watch?v=LspIeUElIFA
https://www.youtube.com/watch?v=bR1oIe6m-Ds
The duration time of video should not be too long, because it will take more time for google api to recognize the audio.