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
4465d320
Commit
4465d320
authored
2 years ago
by
Jan Hartig
Browse files
Options
Downloads
Patches
Plain Diff
Display processing time and progress indicator
parent
1c021a2e
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
+15
-2
15 additions, 2 deletions
main.py
with
15 additions
and
2 deletions
main.py
+
15
−
2
View file @
4465d320
from
faster_whisper
import
WhisperModel
from
faster_whisper
import
WhisperModel
from
datetime
import
timedelta
from
datetime
import
timedelta
from
time
import
perf_counter
model_size
=
"
large-v2
"
model_size
=
"
large-v2
"
tStart
=
perf_counter
()
# Run on GPU with FP32
# Run on GPU with FP32
model
=
WhisperModel
(
model_size
,
device
=
"
cuda
"
,
compute_type
=
"
float32
"
)
model
=
WhisperModel
(
model_size
,
device
=
"
cuda
"
,
compute_type
=
"
float32
"
)
print
(
"
Model initialized
"
)
# Run on CPU
# Run on CPU
# model = WhisperModel(model_size, device="cpu", compute_type="float32")
# model = WhisperModel(model_size, device="cpu", compute_type="float32")
...
@@ -14,6 +18,7 @@ segments, info = model.transcribe("/input/audiofile", language="de", beam_size=5
...
@@ -14,6 +18,7 @@ segments, info = model.transcribe("/input/audiofile", language="de", beam_size=5
with
open
(
"
/output/transcript.vtt
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
with
open
(
"
/output/transcript.vtt
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
f
.
write
(
"
WEBVTT
\n\n
NOTE This transcript was automatically generated.
"
)
f
.
write
(
"
WEBVTT
\n\n
NOTE This transcript was automatically generated.
"
)
print
(
"
Processing...
"
,
end
=
""
)
for
segment
in
segments
:
for
segment
in
segments
:
start
=
timedelta
(
seconds
=
segment
.
start
)
start
=
timedelta
(
seconds
=
segment
.
start
)
end
=
timedelta
(
seconds
=
segment
.
end
)
end
=
timedelta
(
seconds
=
segment
.
end
)
...
@@ -21,7 +26,15 @@ with open("/output/transcript.vtt", "w", encoding="utf-8") as f:
...
@@ -21,7 +26,15 @@ with open("/output/transcript.vtt", "w", encoding="utf-8") as f:
entry
=
"
{} --> {}
\n
{}
"
.
format
(
start
,
end
,
text
)
entry
=
"
{} --> {}
\n
{}
"
.
format
(
start
,
end
,
text
)
print
(
entry
)
f
.
write
(
"
\n\n
"
)
f
.
write
(
"
\n\n
"
)
f
.
write
(
entry
)
f
.
write
(
entry
)
progress
=
segment
.
end
/
info
.
duration
print
(
"
{:2.0%}
"
.
format
(
progress
if
progress
<=
1
else
1
),
end
=
"
...
"
)
print
(
"
Done!
"
)
tEnd
=
perf_counter
()
tDelta
=
tEnd
-
tStart
print
(
"
Processing time: {}s
"
.
format
(
timedelta
(
seconds
=
tDelta
)))
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