Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.ap
Commits
0b3d7bfb
Commit
0b3d7bfb
authored
Feb 14, 2014
by
André Anjos
💬
Browse files
Final implementation of Spectrogram class
parent
2965a366
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
0b3d7bfb
...
...
@@ -40,6 +40,7 @@ setup(
[
"xbob/ap/energy.cpp"
,
"xbob/ap/frame_extractor.cpp"
,
"xbob/ap/spectrogram.cpp"
,
"xbob/ap/main.cpp"
,
],
packages
=
packages
,
...
...
xbob/ap/energy.cpp
View file @
0b3d7bfb
...
...
@@ -52,7 +52,7 @@ static int PyBobApEnergy_InitCopy
(
PyBobApEnergyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
/* Parses input arguments in a single shot */
static
const
char
*
const_kwlist
[]
=
{
"
sampling_frequency,
"
,
0
};
static
const
char
*
const_kwlist
[]
=
{
"
other
"
,
0
};
static
char
**
kwlist
=
const_cast
<
char
**>
(
const_kwlist
);
PyObject
*
other
=
0
;
...
...
xbob/ap/frame_extractor.cpp
View file @
0b3d7bfb
...
...
@@ -56,7 +56,7 @@ static int PyBobApFrameExtractor_InitCopy
(
PyBobApFrameExtractorObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
/* Parses input arguments in a single shot */
static
const
char
*
const_kwlist
[]
=
{
"
sampling_frequency,
"
,
0
};
static
const
char
*
const_kwlist
[]
=
{
"
other
"
,
0
};
static
char
**
kwlist
=
const_cast
<
char
**>
(
const_kwlist
);
PyObject
*
other
=
0
;
...
...
xbob/ap/main.cpp
View file @
0b3d7bfb
...
...
@@ -37,6 +37,9 @@ static PyObject* create_module (void) {
PyBobApEnergy_Type
.
tp_base
=
&
PyBobApFrameExtractor_Type
;
if
(
PyType_Ready
(
&
PyBobApEnergy_Type
)
<
0
)
return
0
;
PyBobApSpectrogram_Type
.
tp_base
=
&
PyBobApEnergy_Type
;
if
(
PyType_Ready
(
&
PyBobApSpectrogram_Type
)
<
0
)
return
0
;
# if PY_VERSION_HEX >= 0x03000000
PyObject
*
m
=
PyModule_Create
(
&
module_definition
);
# else
...
...
@@ -55,6 +58,9 @@ static PyObject* create_module (void) {
Py_INCREF
(
&
PyBobApEnergy_Type
);
if
(
PyModule_AddObject
(
m
,
"Energy"
,
(
PyObject
*
)
&
PyBobApEnergy_Type
)
<
0
)
return
0
;
Py_INCREF
(
&
PyBobApSpectrogram_Type
);
if
(
PyModule_AddObject
(
m
,
"Spectrogram"
,
(
PyObject
*
)
&
PyBobApSpectrogram_Type
)
<
0
)
return
0
;
/* imports xbob.blitz C-API + dependencies */
if
(
import_xbob_blitz
()
<
0
)
return
0
;
...
...
xbob/ap/spectrogram.cpp
0 → 100644
View file @
0b3d7bfb
This diff is collapsed.
Click to expand it.
xbob/ap/test_spectrogram.py
View file @
0b3d7bfb
...
...
@@ -6,12 +6,13 @@
import
os
,
sys
import
unittest
import
bob
import
numpy
import
array
import
math
import
time
from
.
import
Spectrogram
#############################################################################
# Tests blitz-based extrapolation implementation with values returned
#############################################################################
...
...
@@ -77,8 +78,10 @@ def hamming_window(vector, hamming_kernel, win_length):
return
vector
def
log_filter_bank
(
x
,
n_filters
,
p_index
,
win_size
):
from
xbob.sp
import
fft
x1
=
numpy
.
array
(
x
,
dtype
=
numpy
.
complex128
)
complex_
=
bob
.
sp
.
fft
(
x1
)
complex_
=
fft
(
x1
)
for
i
in
range
(
0
,
int
(
win_size
/
2
)
+
1
):
re
=
complex_
[
i
].
real
im
=
complex_
[
i
].
imag
...
...
@@ -117,7 +120,7 @@ def spectrogram_computation(obj, rate_wavsample, win_length_ms, win_shift_ms, n_
## Initialisation part ##
#########################
c
=
bob
.
ap
.
Spectrogram
(
rate_wavsample
[
0
],
win_length_ms
,
win_shift_ms
,
n_filters
,
f_min
,
f_max
,
pre_emphasis_coef
)
c
=
Spectrogram
(
rate_wavsample
[
0
],
win_length_ms
,
win_shift_ms
,
n_filters
,
f_min
,
f_max
,
pre_emphasis_coef
)
c
.
mel_scale
=
mel_scale
...
...
@@ -214,7 +217,7 @@ def spectrogram_computation(obj, rate_wavsample, win_length_ms, win_shift_ms, n_
def
spectrogram_comparison_run
(
obj
,
rate_wavsample
,
win_length_ms
,
win_shift_ms
,
n_filters
,
n_ceps
,
dct_norm
,
f_min
,
f_max
,
delta_win
,
pre_emphasis_coef
,
mel_scale
):
c
=
bob
.
ap
.
Spectrogram
(
rate_wavsample
[
0
],
win_length_ms
,
win_shift_ms
,
n_filters
,
f_min
,
f_max
,
pre_emphasis_coef
,
mel_scale
)
c
=
Spectrogram
(
rate_wavsample
[
0
],
win_length_ms
,
win_shift_ms
,
n_filters
,
f_min
,
f_max
,
pre_emphasis_coef
,
mel_scale
)
A
=
c
(
rate_wavsample
[
1
])
B
=
spectrogram_computation
(
obj
,
rate_wavsample
,
win_length_ms
,
win_shift_ms
,
n_filters
,
n_ceps
,
...
...
xbob/ap/types.h
View file @
0b3d7bfb
...
...
@@ -10,6 +10,7 @@
#include
<bob/ap/FrameExtractor.h>
#include
<bob/ap/Energy.h>
#include
<bob/ap/Spectrogram.h>
/**
* Represents either an FrameExtractor
...
...
@@ -31,4 +32,14 @@ typedef struct {
extern
PyTypeObject
PyBobApEnergy_Type
;
//forward declaration
/**
* Represents either the Spectrogram extractor
*/
typedef
struct
{
PyBobApEnergyObject
parent
;
bob
::
ap
::
Spectrogram
*
cxx
;
}
PyBobApSpectrogramObject
;
extern
PyTypeObject
PyBobApSpectrogram_Type
;
//forward declaration
#endif
/* XBOB_AP_TYPES_H */
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment