Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
Vocal Repertoire Embedder
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
Vocal Repertoire Embedder
Commits
85b04279
Commit
85b04279
authored
2 years ago
by
Paul Best
Browse files
Options
Downloads
Patches
Plain Diff
run_baseline ok
parent
7518ad5a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
run_baseline.py
+26
-10
26 additions, 10 deletions
run_baseline.py
with
26 additions
and
10 deletions
run_baseline.py
100644 → 100755
+
26
−
10
View file @
85b04279
from
tqdm
import
tqdm
from
soundsig.sound
import
Bio
s
ound
import
p_
tqdm
from
soundsig.sound
import
Bio
S
ound
import
soundfile
as
sf
from
scipy.signal
import
resample
import
argparse
import
pandas
as
pd
import
pandas
as
pd
,
numpy
as
np
import
models
parser
=
argparse
.
ArgumentParser
()
...
...
@@ -15,22 +16,37 @@ def norm(arr):
return
(
arr
-
np
.
mean
(
arr
)
)
/
np
.
std
(
arr
)
meta
=
models
.
meta
[
args
.
specie
]
feats
=
[
'
fund
'
,
'
cvfund
'
,
'
maxfund
'
,
'
minfund
'
,
'
meansal
'
,
'
meanspect
'
,
'
stdspect
'
,
'
skewspect
'
,
\
'
kurtosisspect
'
,
'
entropyspect
'
,
'
q1
'
,
'
q2
'
,
'
q3
'
,
'
meantime
'
,
'
stdtime
'
,
'
skewtime
'
,
'
kurtosistime
'
,
'
entropytime
'
]
for
idx
,
row
in
tqdm
(
df
.
iterrows
(),
total
=
len
(
df
)):
info
=
sf
.
info
(
self
.
audiopath
+
row
.
fn
)
def
process
(
idx
):
row
=
df
.
loc
[
idx
]
info
=
sf
.
info
(
f
'
{
args
.
specie
}
/audio/
{
row
.
fn
}
'
)
dur
,
fs
=
info
.
duration
,
info
.
samplerate
start
=
int
(
np
.
clip
(
row
.
pos
-
meta
[
'
sampleDur
'
]
/
2
,
0
,
max
(
0
,
dur
-
meta
[
'
sampleDur
'
]))
*
fs
)
sig
,
fs
=
sf
.
read
(
self
.
audiopath
+
row
.
fn
,
start
=
start
,
stop
=
start
+
int
(
meta
[
'
sampleDur
'
]
*
fs
))
sig
,
fs
=
sf
.
read
(
f
'
{
args
.
specie
}
/audio/
{
row
.
fn
}
'
,
start
=
start
,
stop
=
start
+
int
(
meta
[
'
sampleDur
'
]
*
fs
))
if
sig
.
ndim
==
2
:
sig
=
sig
[:,
0
]
if
len
(
sig
)
<
meta
[
'
sampleDur
'
]
*
fs
:
sig
=
np
.
concatenate
([
sig
,
np
.
zeros
(
int
(
self
.
sampleDur
*
fs
)
-
len
(
sig
))])
if
fs
!=
meta
[
'
sr
'
]:
sig
=
resample
(
sig
,
int
(
len
(
sig
)
/
fs
*
meta
[
'
sr
'
]))
sound
=
BioSound
(
soundWave
=
norm
(
sig
),
fs
=
fs
)
sound
.
spectroCalc
(
max_freq
=
meta
[
'
sr
'
]
//
2
)
sound
.
rms
=
myBioS
ound
.
sound
.
std
()
sound
.
rms
=
s
ound
.
sound
.
std
()
sound
.
ampenv
(
cutoff_freq
=
20
,
amp_sample_rate
=
1000
)
sound
.
spectrum
(
f_high
=
10000
)
sound
.
fundest
(
maxFund
=
15
00
,
minFund
=
3
00
,
lowFc
=
200
,
highFc
=
6000
,
sound
.
spectrum
(
f_high
=
meta
[
'
sr
'
]
//
2
-
1
)
sound
.
fundest
(
maxFund
=
60
00
,
minFund
=
2
00
,
lowFc
=
200
,
highFc
=
6000
,
minSaliency
=
0.5
,
debugFig
=
0
,
minFormantFreq
=
500
,
maxFormantBW
=
500
,
windowFormant
=
0.1
,
method
=
'
Stack
'
)
\ No newline at end of file
method
=
'
Stack
'
)
return
[
sound
.
__dict__
[
f
]
for
f
in
feats
]
res
=
p_tqdm
.
p_map
(
process
,
df
.
index
[:
10
])
for
i
,
mr
in
zip
(
df
.
index
[:
10
],
res
):
for
f
,
r
in
zip
(
feats
,
mr
):
df
.
loc
[
i
,
f
]
=
r
df
.
to_csv
(
f
'
{
args
.
specie
}
/
{
args
.
specie
}
_biosound.csv
'
,
index
=
False
)
\ No newline at end of file
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