Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wmdigit_video_cut
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
wmdigit_video_cut
Commits
dfc41839
Commit
dfc41839
authored
Nov 09, 2023
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
启动时加载whisper_model
parent
91031c74
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
7 deletions
+13
-7
wmdigit_transcribe.py
app/video_cut/autocut/wmdigit_transcribe.py
+2
-2
load_args.py
app/video_cut/load_args.py
+6
-1
main.py
app/video_cut/main.py
+2
-2
requirements.txt
requirements.txt
+1
-0
start.py
start.py
+2
-2
No files found.
app/video_cut/autocut/wmdigit_transcribe.py
View file @
dfc41839
...
@@ -12,10 +12,10 @@ from .type import WhisperMode, SPEECH_ARRAY_INDEX
...
@@ -12,10 +12,10 @@ from .type import WhisperMode, SPEECH_ARRAY_INDEX
class
Transcribe
:
class
Transcribe
:
def
__init__
(
self
,
args
):
def
__init__
(
self
,
args
,
whisper_model
):
self
.
args
=
args
self
.
args
=
args
self
.
sampling_rate
=
16000
self
.
sampling_rate
=
16000
self
.
whisper_model
=
None
self
.
whisper_model
=
whisper_model
self
.
vad_model
=
None
self
.
vad_model
=
None
self
.
detect_speech
=
None
self
.
detect_speech
=
None
...
...
app/video_cut/load_args.py
View file @
dfc41839
...
@@ -135,5 +135,10 @@ def main_args(logger):
...
@@ -135,5 +135,10 @@ def main_args(logger):
args
.
force
=
True
args
.
force
=
True
args
.
vad
=
"0"
args
.
vad
=
"0"
args
.
whisper_model
=
"large-v2"
args
.
whisper_model
=
"large-v2"
args
.
device
=
"cuda"
return
args
logger
.
info
(
f
'load whisper_model: {args.whisper_model} device: {args.device}'
)
\ No newline at end of file
import
whisper
whisper_model
=
whisper
.
load_model
(
args
.
whisper_model
,
args
.
device
)
return
args
,
whisper_model
\ No newline at end of file
app/video_cut/main.py
View file @
dfc41839
...
@@ -31,7 +31,7 @@ def validate_request():
...
@@ -31,7 +31,7 @@ def validate_request():
# 主线
# 主线
def
video_cut_pipeline
(
logger
,
args
):
def
video_cut_pipeline
(
logger
,
args
,
whisper_model
):
# print(args)
# print(args)
time_record
=
[]
time_record
=
[]
media_file
,
lang
=
validate_request
()
media_file
,
lang
=
validate_request
()
...
@@ -50,7 +50,7 @@ def video_cut_pipeline(logger, args):
...
@@ -50,7 +50,7 @@ def video_cut_pipeline(logger, args):
args
.
inputs
=
[
media_file
]
args
.
inputs
=
[
media_file
]
args
.
lang
=
lang
args
.
lang
=
lang
wmdigit_transcribe
.
Transcribe
(
args
)
.
run
()
wmdigit_transcribe
.
Transcribe
(
args
,
whisper_model
)
.
run
()
time_record
.
append
(
f
"视频生成srt和md。耗时: {time.time() - start_time:.4f} 秒"
)
time_record
.
append
(
f
"视频生成srt和md。耗时: {time.time() - start_time:.4f} 秒"
)
...
...
requirements.txt
View file @
dfc41839
...
@@ -7,6 +7,7 @@ flask_sqlalchemy
...
@@ -7,6 +7,7 @@ flask_sqlalchemy
redis
redis
tqdm
tqdm
oss2
moviepy
==2.0.0.dev2
moviepy
==2.0.0.dev2
edge-tts
edge-tts
openai-whisper
openai-whisper
...
...
start.py
View file @
dfc41839
...
@@ -26,12 +26,12 @@ input_root = os.path.join(root, 'inputs')
...
@@ -26,12 +26,12 @@ input_root = os.path.join(root, 'inputs')
output_root
=
os
.
path
.
join
(
root
,
'outputs'
)
output_root
=
os
.
path
.
join
(
root
,
'outputs'
)
# 预加载模型
# 预加载模型
args
=
main_args
(
logger
)
args
,
whisper_model
=
main_args
(
logger
)
# 对外接口
# 对外接口
@
app
.
route
(
'/wm_video_cut'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/wm_video_cut'
,
methods
=
[
'POST'
])
def
wm_video_cut
():
def
wm_video_cut
():
final_video_url
,
srt_url
=
video_cut_pipeline
(
logger
,
args
)
final_video_url
,
srt_url
=
video_cut_pipeline
(
logger
,
args
,
whisper_model
)
return
jsonify
({
"result"
:
{
"final_video_url"
:
final_video_url
,
"srt_url"
:
srt_url
}})
return
jsonify
({
"result"
:
{
"final_video_url"
:
final_video_url
,
"srt_url"
:
srt_url
}})
...
...
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