Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
90ae19a4
Commit
90ae19a4
authored
Nov 14, 2022
by
De Silva K.C.C.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
video to audio implementation
parent
8cfd2b2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
Indexing/audio_gen.py
Indexing/audio_gen.py
+50
-0
No files found.
Indexing/audio_gen.py
0 → 100644
View file @
90ae19a4
import
moviepy.editor
as
mp
from
moviepy.video.io.ffmpeg_tools
import
ffmpeg_extract_subclip
from
moviepy.editor
import
VideoFileClip
import
os
import
text_gen
def
convert_video_to_audio
(
filename
):
clip
=
mp
.
VideoFileClip
(
r""
+
filename
)
audio_file_name
=
str
(
filename
)
.
split
(
'/'
)[
-
1
]
.
replace
(
'.mp4'
,
'.wav'
)
clip
.
audio
.
write_audiofile
(
r"audio_input/"
+
audio_file_name
)
return
text_gen
.
convert_audio_to_text
(
"audio_input/"
+
audio_file_name
)
def
split_video_file
(
filename
):
return_list
=
[]
all_text
=
''
required_video_file
=
filename
files
=
os
.
listdir
(
'video_input'
)
for
filename
in
files
:
os
.
remove
(
'video_input/'
+
filename
)
total_length
=
VideoFileClip
(
required_video_file
)
.
duration
# print(total_length)
no_of_slices
=
int
(
total_length
/
240
)
+
1
time_grid
=
[]
for
i
in
range
(
0
,
no_of_slices
):
time_grid
.
append
(
i
*
240
)
for
i
in
range
(
no_of_slices
):
if
i
==
len
(
time_grid
)
-
1
:
# ffmpeg_extract_subclip(required_video_file, time_grid[i], total_length - time_grid[i],
# targetname='videos/' + str(i) + ".mp4")
pass
else
:
ffmpeg_extract_subclip
(
required_video_file
,
time_grid
[
i
],
time_grid
[
i
+
1
],
targetname
=
'video_input/'
+
str
(
i
)
+
".mp4"
)
text
=
convert_video_to_audio
(
'video_input/'
+
str
(
i
)
+
".mp4"
)
all_text
+=
text
+
' '
return_list
.
append
([
i
,
text
])
return
return_list
,
all_text
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment