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
8ea22d82
Commit
8ea22d82
authored
2 years ago
by
Jan Hartig
Browse files
Options
Downloads
Patches
Plain Diff
Add progress bar and report overall processing time.
parent
4465d320
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
main.py
+21
-14
21 additions, 14 deletions
main.py
with
22 additions
and
15 deletions
Dockerfile
+
1
−
1
View file @
8ea22d82
FROM
ghcr.io/opennmt/ctranslate2:latest-ubuntu20.04-cuda11.2
# install faster-whisper
RUN
python3
-m
pip
--no-cache-dir
install
faster-whisper
RUN
python3
-m
pip
--no-cache-dir
install
faster-whisper
tqdm
# preload model
RUN
python3
-c
"import faster_whisper; faster_whisper.download_model('large-v2')"
...
...
This diff is collapsed.
Click to expand it.
main.py
+
21
−
14
View file @
8ea22d82
from
faster_whisper
import
WhisperModel
from
datetime
import
timedelta
from
time
import
perf_counter
from
tqdm
import
tqdm
model_size
=
"
large-v2
"
...
...
@@ -18,23 +18,30 @@ segments, info = model.transcribe("/input/audiofile", language="de", beam_size=5
with
open
(
"
/output/transcript.vtt
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
f
.
write
(
"
WEBVTT
\n\n
NOTE This transcript was automatically generated.
"
)
print
(
"
Processing...
"
,
end
=
""
)
for
segment
in
segments
:
start
=
timedelta
(
seconds
=
segment
.
start
)
end
=
timedelta
(
seconds
=
segment
.
end
)
text
=
segment
.
text
[
1
:]
print
(
"
Start processing...
"
)
with
tqdm
(
total
=
info
.
duration
,
leave
=
False
)
as
pbar
:
previousEnd
=
0
for
segment
in
segments
:
# calculate cue times
startM
,
startS
=
divmod
(
segment
.
start
,
60
)
startH
,
startM
=
divmod
(
startM
,
60
)
entry
=
"
{} --> {}
\n
{}
"
.
format
(
start
,
end
,
text
)
endM
,
endS
=
divmod
(
segment
.
end
,
60
)
endH
,
endM
=
divmod
(
endM
,
60
)
f
.
write
(
"
\n\n
"
)
f
.
write
(
entry
)
# 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
(
segment
.
text
[
1
:])
progress
=
segment
.
end
/
info
.
duration
print
(
"
{:2.0%}
"
.
format
(
progress
if
progress
<=
1
else
1
),
end
=
"
...
"
)
# update progressbar
pbar
.
update
(
segment
.
end
-
previousEnd
)
previousEnd
=
segment
.
end
print
(
"
Done!
"
)
t
End
=
perf_counter
()
tDelta
=
tEnd
-
tStart
t
Delta
=
perf_counter
()
-
tStart
tDelta
M
,
tDeltaS
=
divmod
(
tDelta
,
60
)
print
(
"
Processing time: {}s
"
.
format
(
timedelta
(
seconds
=
tDelta
)))
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
))
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