Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alessio Brutti
vggvox_features
Commits
fc583924
Commit
fc583924
authored
Sep 07, 2020
by
Alessio Brutti
Browse files
second commit, minor fixings
parent
20f3f3d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/extract_features.py
View file @
fc583924
...
...
@@ -34,22 +34,23 @@ model.summary()
buckets
=
utils
.
build_buckets
(
MAX_SEC
,
BUCKET_STEP
,
FRAME_STEP
)
for
foldername
in
sorted
(
glob
.
glob
(
args
.
input_dir
+
'/*
'
)):
print
(
foldername
)
for
foldername
in
sorted
(
glob
.
glob
(
args
.
input_dir
+
'/*
*'
,
recursive
=
True
)):
#session_name=foldername.split('/')[-1]
#print(session_name)
#embs=[]
#for audio_file in sorted(glob.glob(foldername+'/*/*.flac')): ## parametrizzare il tipo di file (oppure cercare semplicemente tutti i fiels
audio_file
=
foldername
###This is so fucked up... I need to fix
print
(
'Extracting features from file %s'
%
audio_file
)
signal
=
utils
.
get_fft_spectrum
(
audio_file
,
buckets
,
SAMPLE_RATE
,
NUM_FFT
,
FRAME_LEN
,
FRAME_STEP
,
PREEMPHASIS_ALPHA
)
#embs.append((audio_file.split('.')[0],np.squeeze(model.predict(signal.reshape(1,*signal.shape,1)))))
embs
=
np
.
squeeze
(
model
.
predict
(
signal
.
reshape
(
1
,
*
signal
.
shape
,
1
)))
print
(
embs
.
shape
)
print
(
'Dumping vggvox embeddings'
)
if
os
.
path
.
isfile
(
foldername
)
and
foldername
.
lower
().
endswith
((
'.flac'
,
'.wav'
)):
audio_file
=
foldername
###This is so fucked up... I need to fix
#print(audio_file)
#print('Extracting features from file %s'%audio_file)
signal
=
utils
.
get_fft_spectrum
(
audio_file
,
buckets
,
SAMPLE_RATE
,
NUM_FFT
,
FRAME_LEN
,
FRAME_STEP
,
PREEMPHASIS_ALPHA
)
embs
=
np
.
squeeze
(
model
.
predict
(
signal
.
reshape
(
1
,
*
signal
.
shape
,
1
)))
#print(embs.shape)
#print('Dumping vggvox embeddings')
fdump
=
open
(
args
.
output_dir
+
'/'
+
audio_file
.
split
(
'/'
)[
-
1
].
split
(
'.'
)[
0
]
+
'.pkl'
,
'wb'
)
pkl
.
dump
(
embs
,
fdump
,
protocol
=
pkl
.
HIGHEST_PROTOCOL
)
fdump
.
close
()
fdump
=
open
(
args
.
output_dir
+
'/'
+
audio_file
.
split
(
'/'
)[
-
1
].
split
(
'.'
)[
0
]
+
'.pkl'
,
'wb'
)
pkl
.
dump
(
embs
,
fdump
,
protocol
=
pkl
.
HIGHEST_PROTOCOL
)
fdump
.
close
()
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