Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
d299118e
Unverified
Commit
d299118e
authored
Nov 20, 2018
by
Manoj Plakal
Committed by
GitHub
Nov 20, 2018
Browse files
Merge pull request #5722 from SNeugber/master
Switching to more robust pysoundfile for reading wav files
parents
5b8e8cdf
de51e746
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
research/audioset/README.md
research/audioset/README.md
+4
-3
research/audioset/vggish_input.py
research/audioset/vggish_input.py
+3
-2
No files found.
research/audioset/README.md
View file @
d299118e
...
@@ -49,14 +49,15 @@ VGGish depends on the following Python packages:
...
@@ -49,14 +49,15 @@ VGGish depends on the following Python packages:
*
[
`resampy`
](
http://resampy.readthedocs.io/en/latest/
)
*
[
`resampy`
](
http://resampy.readthedocs.io/en/latest/
)
*
[
`tensorflow`
](
http://www.tensorflow.org/
)
*
[
`tensorflow`
](
http://www.tensorflow.org/
)
*
[
`six`
](
https://pythonhosted.org/six/
)
*
[
`six`
](
https://pythonhosted.org/six/
)
*
[
`pysoundfile`
](
https://pysoundfile.readthedocs.io/
)
These are all easily installable via, e.g.,
`pip install numpy`
(as in the
These are all easily installable via, e.g.,
`pip install numpy`
(as in the
example command sequence below).
example command sequence below).
Any reasonably recent version of these packages should work. TensorFlow should
Any reasonably recent version of these packages should work. TensorFlow should
be at least version 1.0. We have tested
with Python 2.7.6 and 3.4.3 on
an
be at least version 1.0. We have tested
that everything works on Ubuntu
an
d
Ubuntu-like system with
Num
P
y v1.1
3.1
, SciPy v
0.19.1
, resampy v0.
1.5, TensorFlow
Windows 10 with Python 3.6.6,
Num
p
y v1.1
5.4
, SciPy v
1.1.0
, resampy v0.
2.1,
v1.2.1, and Six v1.10
.0.
TensorFlow v1.3.0, Six v1.11.0 and PySoundFile 0.9
.0.
VGGish also requires downloading two data files:
VGGish also requires downloading two data files:
...
...
research/audioset/vggish_input.py
View file @
d299118e
...
@@ -17,11 +17,12 @@
...
@@ -17,11 +17,12 @@
import
numpy
as
np
import
numpy
as
np
import
resampy
import
resampy
from
scipy.io
import
wavfile
import
mel_features
import
mel_features
import
vggish_params
import
vggish_params
import
soundfile
as
sf
def
waveform_to_examples
(
data
,
sample_rate
):
def
waveform_to_examples
(
data
,
sample_rate
):
"""Converts audio waveform into an array of examples for VGGish.
"""Converts audio waveform into an array of examples for VGGish.
...
@@ -80,7 +81,7 @@ def wavfile_to_examples(wav_file):
...
@@ -80,7 +81,7 @@ def wavfile_to_examples(wav_file):
Returns:
Returns:
See waveform_to_examples.
See waveform_to_examples.
"""
"""
sr
,
wav_data
=
wavfile
.
read
(
wav_file
)
wav_data
,
sr
=
sf
.
read
(
wav_file
,
dtype
=
'int16'
)
assert
wav_data
.
dtype
==
np
.
int16
,
'Bad sample type: %r'
%
wav_data
.
dtype
assert
wav_data
.
dtype
==
np
.
int16
,
'Bad sample type: %r'
%
wav_data
.
dtype
samples
=
wav_data
/
32768.0
# Convert to [-1.0, +1.0]
samples
=
wav_data
/
32768.0
# Convert to [-1.0, +1.0]
return
waveform_to_examples
(
samples
,
sr
)
return
waveform_to_examples
(
samples
,
sr
)
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