Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ambuj Mehrish
sidekit
Commits
bd10b37c
Commit
bd10b37c
authored
May 13, 2019
by
Anthony Larcher
Browse files
modif io
parent
ee06b1e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/io.py
View file @
bd10b37c
...
...
@@ -431,7 +431,14 @@ def read_audio(input_file_name, framerate=None):
if
ext
.
lower
()
==
'.sph'
:
sig
,
read_framerate
,
sampwidth
=
read_sph
(
input_file_name
,
'p'
)
elif
ext
.
lower
()
==
'.wav'
or
ext
.
lower
()
==
'.wave'
:
sig
,
read_framerate
,
sampwidth
=
read_wav
(
input_file_name
)
try
:
sig
,
read_framerate
,
sampwidth
=
read_wav
(
input_file_name
)
except
:
import
pydub
audio
=
pydub
.
AudioSegment
.
from_wav
(
input_file_name
)
read_framerate
=
audio
.
frame_rate
sampwidth
=
audio
.
sample_width
sig
=
numpy
.
array
(
audio
.
split_to_mono
()[
0
].
get_array_of_samples
())
elif
ext
.
lower
()
==
'.pcm'
or
ext
.
lower
()
==
'.raw'
:
sig
,
read_framerate
,
sampwidth
=
read_pcm
(
input_file_name
)
read_framerate
=
framerate
...
...
@@ -444,7 +451,7 @@ def read_audio(input_file_name, framerate=None):
if
framerate
>
read_framerate
:
print
(
"Warning in read_audio, up-sampling function is not implemented yet!"
)
elif
read_framerate
%
float
(
framerate
)
==
0
and
not
framerate
==
read_framerate
:
print
(
"downsample
"
)
print
(
"downsample
{}"
.
format
(
input_file_name
)
)
sig
=
scipy
.
signal
.
decimate
(
sig
,
int
(
read_framerate
/
float
(
framerate
)),
n
=
None
,
ftype
=
'iir'
,
axis
=
0
)
return
sig
.
astype
(
numpy
.
float32
),
framerate
...
...
sidekit_io.py
View file @
bd10b37c
...
...
@@ -203,7 +203,9 @@ def write_dict_hdf5(data, output_filename):
with
h5py
.
File
(
output_filename
,
"w"
)
as
f
:
for
key
in
data
:
value
=
data
[
key
]
if
isinstance
(
value
,
numpy
.
ndarray
)
or
isinstance
(
value
,
list
):
if
value
is
None
:
pass
elif
isinstance
(
value
,
numpy
.
ndarray
)
or
isinstance
(
value
,
list
):
f
.
create_dataset
(
key
,
data
=
value
,
compression
=
"gzip"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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