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
17ab6fbf
Commit
17ab6fbf
authored
Nov 09, 2023
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正模型加载,增加环境判断
parent
b27d52ec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
wmdigit_transcribe.py
app/video_cut/autocut/wmdigit_transcribe.py
+2
-2
load_args.py
app/video_cut/load_args.py
+10
-10
main.py
app/video_cut/main.py
+2
-2
start.py
start.py
+2
-2
No files found.
app/video_cut/autocut/wmdigit_transcribe.py
View file @
17ab6fbf
...
...
@@ -12,10 +12,10 @@ from .type import WhisperMode, SPEECH_ARRAY_INDEX
class
Transcribe
:
def
__init__
(
self
,
args
):
def
__init__
(
self
,
args
,
whispermodel
):
self
.
args
=
args
self
.
sampling_rate
=
16000
self
.
whisper_model
=
None
self
.
whisper_model
=
whispermodel
self
.
vad_model
=
None
self
.
detect_speech
=
None
...
...
app/video_cut/load_args.py
View file @
17ab6fbf
import
argparse
import
logging
import
os
from
app.video_cut.autocut
import
utils
from
app.video_cut.autocut
import
whisper_model
from
app.video_cut.autocut.type
import
WhisperMode
,
WhisperModel
def
main_args
(
logger
):
def
main_args
(
logger
,
debug
):
logger
.
info
(
'load augument'
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"--inputs"
,
type
=
str
,
help
=
"Inputs filenames/folders"
)
...
...
@@ -134,12 +132,14 @@ def main_args(logger):
args
.
wmdigit
=
True
args
.
force
=
True
args
.
vad
=
"0"
args
.
whisper_model
=
"large-v2"
args
.
device
=
"cuda"
logger
.
info
(
f
'load whisper_model: {args.whisper_model} device: {args.device}'
)
import
whisper
whisper_model
=
whisper
.
load_model
(
args
.
whisper_model
,
args
.
device
)
if
not
debug
:
args
.
whisper_model
=
"large-v2"
args
.
device
=
"cuda"
logger
.
info
(
f
'load whisper_model: {args.whisper_model}, device: {args.device}'
)
whispermodel
=
whisper_model
.
WhisperModel
(
16000
)
whispermodel
.
load
(
args
.
whisper_model
,
args
.
device
)
logger
.
info
(
f
'done.'
)
return
args
,
whisper_model
\ No newline at end of file
return
args
,
whispermodel
\ No newline at end of file
app/video_cut/main.py
View file @
17ab6fbf
...
...
@@ -31,7 +31,7 @@ def validate_request():
# 主线
def
video_cut_pipeline
(
logger
,
args
,
whisper
_
model
):
def
video_cut_pipeline
(
logger
,
args
,
whispermodel
):
# print(args)
time_record
=
[]
media_file
,
lang
=
validate_request
()
...
...
@@ -50,7 +50,7 @@ def video_cut_pipeline(logger, args, whisper_model):
args
.
inputs
=
[
media_file
]
args
.
lang
=
lang
wmdigit_transcribe
.
Transcribe
(
args
,
whisper
_
model
)
.
run
()
wmdigit_transcribe
.
Transcribe
(
args
,
whispermodel
)
.
run
()
time_record
.
append
(
f
"视频生成srt和md。耗时: {time.time() - start_time:.4f} 秒"
)
...
...
start.py
View file @
17ab6fbf
...
...
@@ -26,12 +26,12 @@ input_root = os.path.join(root, 'inputs')
output_root
=
os
.
path
.
join
(
root
,
'outputs'
)
# 预加载模型
args
,
whisper
_model
=
main_args
(
logger
)
args
,
whisper
model
=
main_args
(
logger
,
app
.
config
[
'DEBUG'
]
)
# 对外接口
@
app
.
route
(
'/wm_video_cut'
,
methods
=
[
'POST'
])
def
wm_video_cut
():
final_video_url
,
srt_url
=
video_cut_pipeline
(
logger
,
args
,
whisper
_
model
)
final_video_url
,
srt_url
=
video_cut_pipeline
(
logger
,
args
,
whispermodel
)
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