Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Hertz-Lab
Research
Intelligent Museum
Python Audio Recorder
Commits
da3f2b4c
Commit
da3f2b4c
authored
Oct 20, 2021
by
pbethge
Browse files
add time measurement
parent
ca98b8e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/vad_and_speechbrain_lid/main.py
View file @
da3f2b4c
...
...
@@ -53,16 +53,28 @@ def processAudio(config, q):
data_tensor
=
torch
.
tensor
(
data
,
dtype
=
float
)
data_tensor
=
torch
.
unsqueeze
(
data_tensor
,
0
)
start
=
time
.
time
()
out
=
model
.
classify_batch
(
data_tensor
)
language
=
out
[
3
][
0
]
print
(
language
)
endtime_batch
=
time
.
time
()
-
start
# classification from file is also possible
# results = model.classify_file("test.wav")
# if out[index] >= lid_threshold:
# print(classes[index])
fname
=
str
(
time
.
ctime
(
time
.
time
()))
+
"_"
+
language
+
'.wav'
wav
.
write
(
fname
,
SAMPLE_RATE
,
np
.
asarray
(
data
))
if
torch
.
cuda
.
is_available
():
print
(
"GPU runtime from batch: "
+
str
(
endtime_batch
))
else
:
print
(
"CPU runtime from batch: "
+
str
(
endtime_batch
))
print
(
language
)
except
Exception
as
e
:
print
(
"Ooopsi: "
,
e
)
q
.
task_done
()
...
...
Write
Preview
Supports
Markdown
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