Skip to content

Commit

Permalink
Added audio analysis code into preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
AnanthVivekanand committed Oct 27, 2020
1 parent 8e0819a commit c135a37
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions audio_preprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,37 @@
"import librosa\n",
"import librosa.display"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import struct\n",
"\n",
"class WavFileHelper():\n",
" \n",
" def read_file_properties(self, filename):\n",
"\n",
" wave_file = open(filename,\"rb\")\n",
" \n",
" riff = wave_file.read(12)\n",
" fmt = wave_file.read(36)\n",
" \n",
" num_channels_string = fmt[10:12]\n",
" num_channels = struct.unpack('<H', num_channels_string)[0]\n",
"\n",
" sample_rate_string = fmt[12:16]\n",
" sample_rate = struct.unpack(\"<I\",sample_rate_string)[0]\n",
" \n",
" bit_depth_string = fmt[22:24]\n",
" bit_depth = struct.unpack(\"<H\",bit_depth_string)[0]\n",
"\n",
" return (num_channels, sample_rate, bit_depth)\n",
"\n",
"wavfilehelper = WavFileHelper()"
]
}
],
"metadata": {
Expand Down

0 comments on commit c135a37

Please sign in to comment.