Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert video to text python

import urllib2
import speech_recognition as sr
import subprocess
import os

url = 'https://cdn.fbsbx.com/v/t59.3654-21/15720510_10211855778255994_5430581267814940672_n.mp4/audioclip-1484407992000-3392.mp4?oh=a78286aa96c9dea29e5d07854194801c&oe=587C3833'
mp4file = urllib2.urlopen(url)

with open("test.mp4", "wb") as handle:
    handle.write(mp4file.read())

cmdline = ['avconv',
           '-i',
           'test.mp4',
           '-vn',
           '-f',
           'wav',
           'test.wav']
subprocess.call(cmdline)

r = sr.Recognizer()
with sr.AudioFile('test.wav') as source:
    audio = r.record(source)

command = r.recognize_google(audio)
print command

os.remove("test.mp4")
os.remove("test.wav")
Comment

Video to text convertor in python

# Python code to convert video to audio
import moviepy.editor as mp
  
# Insert Local Video File Path 
clip = mp.VideoFileClip(r"Video File")
  
# Insert Local Audio File Path
clip.audio.write_audiofile(r"Audio File")
Comment

PREVIOUS NEXT
Code Example
Python :: python tempfile 
Python :: read pdf py 
Python :: python create virtualenv 
Python :: python find first duplicate numbers 
Python :: extract filename from path in python 
Python :: python current working directory 
Python :: python delete file with extension 
Python :: python flask mail 
Python :: datetime year python 
Python :: python tkinter askopenfile 
Python :: numpy get index of n largest values 
Python :: append file to list python 
Python :: compute eigenvalue python 
Python :: hello world py 
Python :: python ignore unicodedecodeerror 
Python :: json.dumps no spaces 
Python :: append method linked list python 
Python :: pd get non-numeric columns 
Python :: python get current time 
Python :: boto3 upload file to s3 
Python :: python hello world web application 
Python :: python zip extract directory 
Python :: how to get location using python 
Python :: python datetime no milliseconds 
Python :: python csv dict reader 
Python :: write text in list to text file python 
Python :: scapy python import 
Python :: replace newline character in python 
Python :: multiple line input python 
Python :: python falsy values 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =