Skip to content

Commit

Permalink
YAMNet variable sr (#8174)
Browse files Browse the repository at this point in the history
* Modify yamnet_visualization to work for any (?) sampling rate in input wav file.
  • Loading branch information
dpwe committed Feb 22, 2020
1 parent b60dc23 commit 7b1553f
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions research/audioset/yamnet/yamnet_visualization.ipynb
Expand Up @@ -53,6 +53,34 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sample rate = 16000\n"
]
}
],
"source": [
"# Read in the audio.\n",
"# You can get this example waveform via:\n",
"# curl -O https://storage.googleapis.com/audioset/speech_whistling2.wav\n",
"\n",
"wav_file_name = 'speech_whistling2.wav'\n",
"\n",
"wav_data, sr = sf.read(wav_file_name, dtype=np.int16)\n",
"waveform = wav_data / 32768.0\n",
"# The graph is designed for a sampling rate of 16 kHz, but higher rates \n",
"# should work too.\n",
"params.SAMPLE_RATE = sr\n",
"print(\"Sample rate =\", params.SAMPLE_RATE)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -74,21 +102,6 @@
" yamnet.load_weights('yamnet.h5')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Read in the audio.\n",
"# You can get this example waveform via:\n",
"# curl -O https://storage.googleapis.com/audioset/speech_whistling2.wav\n",
"wav_data, sr = sf.read('speech_whistling2.wav', dtype=np.int16)\n",
"waveform = wav_data / 32768.0\n",
"# Sampling rate should be 16000 Hz.\n",
"assert sr == 16000"
]
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down

0 comments on commit 7b1553f

Please sign in to comment.