Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
whisper-webvtt-transcriber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Jan Hartig
whisper-webvtt-transcriber
Commits
180c5dbc
Commit
180c5dbc
authored
1 year ago
by
Jan Hartig
Browse files
Options
Downloads
Patches
Plain Diff
Use language from "/input/video_language.txt"
parent
6b9f1ab2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+20
-6
20 additions, 6 deletions
main.py
with
20 additions
and
6 deletions
main.py
+
20
−
6
View file @
180c5dbc
...
...
@@ -29,13 +29,19 @@ print("Using {} {} capable GPUs".format(len(capableGPUs), compute_type))
tStart
=
perf_counter
()
# Run on GPU with FP32
model
=
WhisperModel
(
model_size
,
device
=
"
cuda
"
,
device_index
=
capableGPUs
,
compute_type
=
"
float32
"
,
local_files_only
=
True
)
model
=
WhisperModel
(
model_size
,
device
=
"
cuda
"
,
device_index
=
capableGPUs
,
compute_type
=
"
float32
"
,
local_files_only
=
True
,
)
print
(
"
Model initialized
"
)
# Run on CPU
# model = WhisperModel(model_size, device="cpu", compute_type="float32"
)
with
open
(
"
/input/video_language.txt
"
)
as
f
:
language
=
f
.
read
(
)
segments
,
info
=
model
.
transcribe
(
"
/input/audio
file
"
,
language
=
"
de
"
,
beam_size
=
5
)
segments
,
info
=
model
.
transcribe
(
"
/input/audio
.mkv
"
,
language
=
language
,
beam_size
=
5
)
with
open
(
"
/output/subtitles.vtt
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
f
.
write
(
"
WEBVTT
\n\n
NOTE This transcript was automatically generated.
"
)
...
...
@@ -52,7 +58,11 @@ with open("/output/subtitles.vtt", "w", encoding="utf-8") as f:
endH
,
endM
=
divmod
(
endM
,
60
)
# write cue & text
f
.
write
(
"
\n\n
{:02.0f}:{:02.0f}:{:06.3f} --> {:02.0f}:{:02.0f}:{:06.3f}
\n
"
.
format
(
startH
,
startM
,
startS
,
endH
,
endM
,
endS
))
f
.
write
(
"
\n\n
{:02.0f}:{:02.0f}:{:06.3f} --> {:02.0f}:{:02.0f}:{:06.3f}
\n
"
.
format
(
startH
,
startM
,
startS
,
endH
,
endM
,
endS
)
)
f
.
write
(
segment
.
text
[
1
:])
# update progressbar
...
...
@@ -66,4 +76,8 @@ tDeltaM, tDeltaS = divmod(tDelta, 60)
durationM
,
durationS
=
divmod
(
info
.
duration
,
60
)
print
(
"
Processed {:02.0f}m {:02.0f}s audio in {:02.0f}m {:02.0f}s
"
.
format
(
durationM
,
durationS
,
tDeltaM
,
tDeltaS
))
print
(
"
Processed {:02.0f}m {:02.0f}s audio in {:02.0f}m {:02.0f}s
"
.
format
(
durationM
,
durationS
,
tDeltaM
,
tDeltaS
)
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment