convert video to text python

Solutions on MaxInterview for convert video to text python by the best coders in the world

showing results for - "convert video to text python"
Claudio
23 Oct 2017
1import urllib2
2import speech_recognition as sr
3import subprocess
4import os
5
6url = 'https://cdn.fbsbx.com/v/t59.3654-21/15720510_10211855778255994_5430581267814940672_n.mp4/audioclip-1484407992000-3392.mp4?oh=a78286aa96c9dea29e5d07854194801c&oe=587C3833'
7mp4file = urllib2.urlopen(url)
8
9with open("test.mp4", "wb") as handle:
10    handle.write(mp4file.read())
11
12cmdline = ['avconv',
13           '-i',
14           'test.mp4',
15           '-vn',
16           '-f',
17           'wav',
18           'test.wav']
19subprocess.call(cmdline)
20
21r = sr.Recognizer()
22with sr.AudioFile('test.wav') as source:
23    audio = r.record(source)
24
25command = r.recognize_google(audio)
26print command
27
28os.remove("test.mp4")
29os.remove("test.wav")
30