Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyAVA
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
DOLPHINFREE experiments
PyAVA
Commits
5db537c4
Commit
5db537c4
authored
2 years ago
by
Loic-Lenof
Browse files
Options
Downloads
Patches
Plain Diff
bug fixing
+ improved wave_to_spectrogram + fixed entry fields not updating at file change
parent
60f5ae3a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
functions.py
+10
-7
10 additions, 7 deletions
functions.py
interface.py
+1
-2
1 addition, 2 deletions
interface.py
with
11 additions
and
9 deletions
functions.py
+
10
−
7
View file @
5db537c4
...
...
@@ -59,7 +59,7 @@ def load_waveform(wavefile_name, sr_resample):
return
wavefile_dec
def
wave_to_spectrogram
(
waveform
,
SR
,
n_fft
,
w_size
,
clip
,
as_pcen
=
False
):
def
wave_to_spectrogram
(
waveform
,
SR
,
n_fft
,
w_size
,
clip
,
as_pcen
=
False
,
top_db
=
160
):
"""
A function that transforms any given waveform to a spectrogram.
...
...
@@ -83,6 +83,9 @@ def wave_to_spectrogram(waveform, SR, n_fft, w_size, clip, as_pcen=False):
Whether the returned image should be a PCEN or not.
Aka : spectrogram with enhanced contrast.
Default is False.
top_db : float, optional.
Thresholds the output at top_db for amplitude_to_db function.
Default is 80.
Returns
-------
...
...
@@ -91,21 +94,21 @@ def wave_to_spectrogram(waveform, SR, n_fft, w_size, clip, as_pcen=False):
audio_length : float
Duration of the audio in seconds.
"""
base
=
np
.
abs
(
stft
(
spectrum
=
np
.
abs
(
stft
(
waveform
,
n_fft
=
n_fft
,
hop_length
=
w_size
))
spectro_pcen
=
pcen
(
base
*
(
2
**
31
),
bias
=
10
)
spectro_og
=
amplitude_to_db
(
base
)
if
as_pcen
:
spectro_pcen
=
pcen
(
spectrum
*
(
2
**
31
),
bias
=
10
)
spectro_og
=
amplitude_to_db
(
spectrum
,
top_db
=
top_db
)
spectro_og
=
spectro_og
-
(
np
.
max
(
spectro_og
))
spectro_og
[
spectro_og
<
clip
]
=
np
.
nan
if
as_pcen
:
spectro_pcen
[
np
.
isnan
(
spectro_og
)]
=
np
.
nan
spectro_pcen
[
spectro_og
<
clip
]
=
np
.
min
(
spectro_pcen
)
spectro
=
spectro_pcen
else
:
spectro_og
[
spectro_og
<
clip
]
=
clip
spectro
=
spectro_og
audio_length
=
len
(
waveform
)
/
SR
...
...
This diff is collapsed.
Click to expand it.
interface.py
+
1
−
2
View file @
5db537c4
...
...
@@ -559,6 +559,7 @@ class App(object):
self
.
canvas
.
get_tk_widget
().
destroy
()
# load new data
self
.
setup
()
self
.
load_audio
()
self
.
create_canvas
()
self
.
NAME0
=
0
...
...
@@ -581,8 +582,6 @@ class App(object):
def
setup
(
self
):
"""
A function to create variables based on default values
This is a security to avoid mixing default values with new values
during use... But it could be removed.
"""
self
.
NFFT
=
self
.
_default_nfft
self
.
HOP_LENGTH
=
self
.
_default_hop_length
...
...
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