Extract Text From Videos using Python Advance Project 2024

 In machine learning, speech recognition is an interesting task that allows you to recognize text behind sound. We can also extract text from video using voice recognition. In this article, I will guide you on how to extract text from videos using Python.

Extract text from videos using Python

In this section, I'll walk you through how to extract text from a video using Python. The first step is to download the video. After downloading the videos, you need to install two Python libraries:


SpeechRecognition: pip install SpeechRecognition

moviepy: pip install moviepy

After installing the above two Python libraries, you can start coding. Here is the complete Python program to convert video to text:

import speech_recognition as sr

import moviepy.editor as mp

from import ffmpeg_extract_subclip


num_seconds_video= 52*60

print("The video is {} seconds".format(num_seconds_video))




for i in range(len(l)-1):

ffmpeg_extract_subclip("videorl.mp4", l[i]-2*(l[i]!=0), l[i+1], targetname="chunks/cut{}.mp4".format(i+1))

clip = mp.VideoFileClip(r"chunks/cut{}.mp4".format(i+1))"converted/converted{}.wav".format(i+1))

r = sr.Recognizer()

audio = sr.AudioFile("converted/converted{}.wav".format(i+1))

with audio as source:


audio_file = r.record(source)

result = r.recognize_google(audio_file)



Post a Comment