-
Notifications
You must be signed in to change notification settings - Fork 0
/
vts.py
49 lines (37 loc) · 1.13 KB
/
vts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""Command line tool for video to speech conversion.
Authors:
Yu Bai [[email protected]]
"""
import argparse
# import path
from moviepy.editor import *
def videoToSpeech(source, target):
"""提取视频的音频文件
参数
----------
source : str
源文件地址
target : str
目标文件输出地址
"""
video = VideoFileClip(source)
audio = video.audio
audio.write_audiofile(target)
return
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Video to speech')
parser.add_argument('--video_address',
type=str,
action='store',
# default='test.mp4',
help='video to be converted(mp4)')
parser.add_argument('--target_address',
type=str,
action='store',
# default='target.wav',
help='target address')
args = parser.parse_args()
videoToSpeech(args.video_address, target=args.target_address)
print("Convert finished!")