Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
f0_estimation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
f0_estimation
Commits
ad9b7cca
Commit
ad9b7cca
authored
Feb 9, 2024
by
Paul Best
Browse files
Options
Downloads
Patches
Plain Diff
clip spectrum when substracting noise in saliency computation
parent
a00e3ff3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
compute_salience_SHR.py
+5
-5
5 additions, 5 deletions
compute_salience_SHR.py
with
5 additions
and
5 deletions
compute_salience_SHR.py
+
5
−
5
View file @
ad9b7cca
...
@@ -6,13 +6,13 @@ import librosa
...
@@ -6,13 +6,13 @@ import librosa
np
.
seterr
(
divide
=
'
ignore
'
)
np
.
seterr
(
divide
=
'
ignore
'
)
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
specie
'
,
type
=
str
,
help
=
"
Species to treat specifically
"
,
default
=
None
)
parser
.
add_argument
(
'
specie
'
,
type
=
str
,
help
=
"
Species to treat specifically
"
,
default
=
'
all
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
for
specie
in
species
if
args
.
specie
is
None
else
[
args
.
specie
]:
for
specie
in
species
if
args
.
specie
==
'
all
'
else
[
args
.
specie
]:
wavpath
,
FS
,
nfft
,
downsample
=
species
[
specie
].
values
()
wavpath
,
FS
,
nfft
,
downsample
,
step
=
species
[
specie
].
values
()
Hz2bin
=
lambda
f
:
np
.
floor
(
f
/
FS
*
nfft
).
astype
(
int
)
# f in _preds.csv are already downsamples
Hz2bin
=
lambda
f
:
np
.
floor
(
f
/
FS
*
nfft
).
astype
(
int
)
# f in _preds.csv are already downsamples
dt
=
nfft
/
8
# winsize / 8
dt
=
nfft
*
step
hann
=
np
.
hanning
(
nfft
)
hann
=
np
.
hanning
(
nfft
)
get_spectrum
=
lambda
x
:
10
*
np
.
log10
(
np
.
abs
(
np
.
fft
.
rfft
(
hann
*
x
))
**
2
/
(
nfft
/
FS
*
1.5
)
+
1
)
+
1e-10
# density scaling, log1p
get_spectrum
=
lambda
x
:
10
*
np
.
log10
(
np
.
abs
(
np
.
fft
.
rfft
(
hann
*
x
))
**
2
/
(
nfft
/
FS
*
1.5
)
+
1
)
+
1e-10
# density scaling, log1p
...
@@ -35,7 +35,7 @@ for specie in species if args.specie is None else [args.specie]:
...
@@ -35,7 +35,7 @@ for specie in species if args.specie is None else [args.specie]:
if
FS
*
r
.
time
<
nfft
//
2
or
FS
*
r
.
time
>
len
(
sig
)
-
nfft
//
2
or
(
sig
[
int
(
FS
*
r
.
time
)
-
nfft
//
2
:
int
(
FS
*
r
.
time
)
+
nfft
//
2
]
==
0
).
all
():
if
FS
*
r
.
time
<
nfft
//
2
or
FS
*
r
.
time
>
len
(
sig
)
-
nfft
//
2
or
(
sig
[
int
(
FS
*
r
.
time
)
-
nfft
//
2
:
int
(
FS
*
r
.
time
)
+
nfft
//
2
]
==
0
).
all
():
continue
continue
spec
=
get_spectrum
(
sig
[
int
(
FS
*
r
.
time
)
-
nfft
//
2
:
int
(
FS
*
r
.
time
)
+
nfft
//
2
])
spec
=
get_spectrum
(
sig
[
int
(
FS
*
r
.
time
)
-
nfft
//
2
:
int
(
FS
*
r
.
time
)
+
nfft
//
2
])
spec
-
=
n
oise
spec
=
n
p
.
clip
(
spec
-
noise
,
0
,
10
)
f0
=
r
.
annot
f0
=
r
.
annot
df
.
loc
[
i
,
'
salience
'
]
=
sum
(
spec
[
Hz2bin
(
f0
*
2
**
(
-
1
/
12
)):
Hz2bin
(
f0
*
2
**
(
1
/
12
))
+
1
])
/
sum
(
spec
[
Hz2bin
(
f0
*
2
**
(
-
6
/
12
)):
Hz2bin
(
f0
*
2
**
(
6
/
12
))
+
1
])
df
.
loc
[
i
,
'
salience
'
]
=
sum
(
spec
[
Hz2bin
(
f0
*
2
**
(
-
1
/
12
)):
Hz2bin
(
f0
*
2
**
(
1
/
12
))
+
1
])
/
sum
(
spec
[
Hz2bin
(
f0
*
2
**
(
-
6
/
12
)):
Hz2bin
(
f0
*
2
**
(
6
/
12
))
+
1
])
...
...
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