Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tff2020
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
Container registry
Model registry
Operate
Environments
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
skmad-suite
tff2020
Commits
fb836296
Commit
fb836296
authored
5 years ago
by
valentin.emiya
Browse files
Options
Downloads
Patches
Plain Diff
update CI
parent
d2ce9b95
No related branches found
No related tags found
No related merge requests found
Pipeline
#5112
failed
5 years ago
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+4
-2
4 additions, 2 deletions
.gitlab-ci.yml
python/requirements/defaults.txt
+1
-1
1 addition, 1 deletion
python/requirements/defaults.txt
python/tffpy/utils.py
+159
-1
159 additions, 1 deletion
python/tffpy/utils.py
with
164 additions
and
4 deletions
.gitlab-ci.yml
+
4
−
2
View file @
fb836296
...
...
@@ -6,7 +6,8 @@ tests:
script
:
-
cd python
-
pip3 install --no-deps ltfatpy madarrays yafe skpomade pandas
-
pip3 install scipy -U
-
pip3 install scipy=1.4.1 -U
-
pip3 install matplotlib=3.1.2 -U
-
pip3 install --no-deps .
-
python3 tffpy/tests/ci_config.py
-
pytest-3
...
...
@@ -21,7 +22,8 @@ pages:
script
:
-
cd python
-
pip3 install --no-deps ltfatpy madarrays yafe skpomade pandas
-
pip3 install scipy -U
-
pip3 install scipy=1.4.1 -U
-
pip3 install matplotlib=3.1.2 -U
-
pip3 install --no-deps .
-
python3 setup.py build_sphinx
-
python3 tffpy/tests/ci_config.py
...
...
This diff is collapsed.
Click to expand it.
python/requirements/defaults.txt
+
1
−
1
View file @
fb836296
...
...
@@ -2,7 +2,7 @@
numpy>=1.13
scipy>=1.4.1
matplotlib
matplotlib
>=3.1.2
pandas
xarray
ltfatpy
...
...
This diff is collapsed.
Click to expand it.
python/tffpy/utils.py
+
159
−
1
View file @
fb836296
...
...
@@ -13,11 +13,36 @@ from ltfatpy import plotdgtreal, dgtreal, idgtreal
def
plot_mask
(
mask
,
hop
,
n_bins
,
fs
):
"""
Plot time-frequency mask
Parameters
----------
mask : nd-array
Time-frequency mask
hop : int
Hop size
n_bins : int
Number of frequency bins
fs : int
Sampling frequency
"""
plotdgtreal
(
coef
=
mask
.
astype
(
float
),
a
=
hop
,
M
=
n_bins
,
fs
=
fs
,
normalization
=
'
lin
'
)
def
plot_win
(
win
,
fs
,
label
=
None
):
"""
Plot window
Parameters
----------
win : nd-array
Window array
fs : int
Sampling frequency
label : str or None
If not None, label to be assigned to the curve.
"""
x_range
=
np
.
fft
.
fftshift
(
np
.
arange
(
win
.
size
)
/
fs
)
x_range
[
x_range
>
x_range
[
-
1
]]
-=
x_range
.
size
/
fs
if
label
is
None
:
...
...
@@ -30,51 +55,177 @@ def plot_win(win, fs, label=None):
def
plot_spectrogram
(
x
,
dgt_params
,
fs
,
dynrange
=
100
,
clim
=
None
):
"""
Plot spectrogram of a signal
Parameters
----------
x : nd-array
Signal
dgt_params : dict
DGT parameters (see `tffpy.tf_tools.get_dgt_params`)
fs : int
Sampling frequency
dynrange : float
Dynamic range to be displayed.
clim : sequence
Min and max values for the colorbar. If both `clim` and `dynrange` are
specified, then clim takes precedence.
"""
tf_mat
=
dgt
(
x
,
dgt_params
=
dgt_params
)
plotdgtreal
(
coef
=
tf_mat
,
a
=
dgt_params
[
'
hop
'
],
M
=
dgt_params
[
'
n_bins
'
],
fs
=
fs
,
dynrange
=
dynrange
,
clim
=
clim
)
def
db
(
x
):
"""
Linear to decibel (dB) conversion
Parameters
----------
x : scalar or nd-array
Values to be converted
Returns
-------
scalar or nd-array
Conversion of input `x` in dB.
"""
return
20
*
np
.
log10
(
np
.
abs
(
x
))
def
sdr
(
x_ref
,
x_est
):
"""
Signal to distortion ratio
Parameters
----------
x_ref : nd-array
Reference signal
x_est : nd-array
Estimation of the reference signal
Returns
-------
float
"""
return
snr
(
x_signal
=
x_ref
,
x_noise
=
x_est
-
x_ref
)
def
snr
(
x_signal
,
x_noise
):
"""
Signal to noise ratio
Parameters
----------
x_signal : nd-array
Signal of interest
x_noise : nd-array
Noise signal
Returns
-------
float
"""
return
db
(
np
.
linalg
.
norm
(
x_signal
))
-
db
(
np
.
linalg
.
norm
(
x_noise
))
def
is_div_spectrum
(
x_ref
,
x_est
):
"""
Itakura-Saito divergence computed via discrete Fourier transform
Parameters
----------
x_ref : nd-array
Reference signal
x_est : nd-array
Estimation of the reference signal
Returns
-------
float
"""
return
is_div
(
x_ref
=
np
.
abs
(
np
.
fft
.
fft
(
x_ref
)),
x_est
=
np
.
abs
(
np
.
fft
.
fft
(
x_est
)))
def
is_div
(
x_ref
,
x_est
):
"""
Itakura-Saito divergence
Parameters
----------
x_ref : nd-array
Reference array
x_est : nd-array
Estimation of the reference array
Returns
-------
float
"""
x_ratio
=
x_ref
/
x_est
return
np
.
sum
(
x_ratio
-
np
.
log
(
x_ratio
))
-
np
.
size
(
x_ratio
)
def
dgt
(
sig
,
dgt_params
):
"""
Discrete Gabor transform of a signal
Parameters
----------
sig : nd-array
Input signal
dgt_params : dict
DGT parameters (see `tffpy.tf_tools.get_dgt_params`)
Returns
-------
nd-array
DGT coefficients
"""
return
dgtreal
(
f
=
sig
,
g
=
dgt_params
[
'
win
'
],
a
=
dgt_params
[
'
hop
'
],
M
=
dgt_params
[
'
n_bins
'
],
L
=
sig
.
shape
[
0
],
pt
=
dgt_params
[
'
phase_conv
'
])[
0
]
def
idgt
(
tf_mat
,
dgt_params
,
sig_len
):
"""
Inverse discrete Gabor transform
Parameters
----------
tf_mat : nd-array
DGT coefficients
dgt_params : dict
DGT parameters (see `tffpy.tf_tools.get_dgt_params`)
sig_len : int
Signal length
Returns
-------
nd-array
Reconstructed signal
"""
return
idgtreal
(
coef
=
tf_mat
,
g
=
dgt_params
[
'
win
'
],
a
=
dgt_params
[
'
hop
'
],
M
=
dgt_params
[
'
n_bins
'
],
Ls
=
sig_len
,
pt
=
dgt_params
[
'
phase_conv
'
])[
0
]
def
get_config_file
():
"""
User configuration file
Returns
-------
Path
"""
return
Path
(
os
.
path
.
expanduser
(
'
~
'
))
/
'
.config
'
/
'
tffpy.conf
'
def
generate_config
():
"""
Generate an empty configuration file.
"""
Generate an empty configuration file.
"""
config
=
ConfigParser
(
allow_no_value
=
True
)
...
...
@@ -90,6 +241,13 @@ def generate_config():
def
get_data_path
():
"""
Read data folder from user configuration file.
Returns
-------
Path
"""
config_file
=
get_config_file
()
if
not
config_file
.
exists
():
raise
Exception
(
'
Configuration file does not exists. To create it,
'
...
...
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