added example notebooks how to extract ENF signal

This commit is contained in:
Radek Ludačka
2021-08-14 21:08:44 +02:00
parent 54fc413b49
commit e051171e99
2 changed files with 428 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,307 @@
{
"cells": [
{
"cell_type": "raw",
"id": "gross-fever",
"metadata": {},
"source": [
"Notebook extracts ENF signal by pyenf_extraction application\n",
"Uses reference (002_ref.wav) and original (002.wav) signal"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "complete-exchange",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"!wget https://github.com/ghuawhu/ENF-WHU-Dataset/blob/master/ENF-WHU-Dataset/H1/002.wav?raw=true\n",
"!wget https://github.com/ghuawhu/ENF-WHU-Dataset/blob/master/ENF-WHU-Dataset/H1_ref/002_ref.wav?raw=true\n",
"!git clone https://github.com/deerajnagothu/pyenf_extraction"
]
},
{
"cell_type": "raw",
"id": "fixed-aging",
"metadata": {},
"source": [
"pip install scipy==1.1.0\n",
"pip install numpy==1.21.0\n",
"pip install matplotlib==3.4.2\n",
"pip install librosa==0.8.1"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "premier-minimum",
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "regular-boundary",
"metadata": {},
"outputs": [],
"source": [
"sys.path.append('./pyenf_extraction/')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "remarkable-ready",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"9\n",
"10\n",
"11\n",
"12\n",
"13\n",
"14\n",
"15\n",
"16\n",
"17\n",
"18\n",
"19\n",
"20\n",
"21\n",
"22\n",
"23\n",
"24\n",
"25\n",
"26\n",
"27\n",
"28\n",
"29\n",
"30\n",
"31\n",
"32\n",
"33\n",
"34\n",
"35\n",
"36\n",
"37\n",
"38\n",
"39\n",
"40\n",
"41\n",
"42\n",
"43\n",
"44\n",
"45\n",
"46\n",
"47\n",
"48\n",
"49\n",
"50\n",
"51\n",
"52\n",
"53\n",
"54\n",
"55\n",
"56\n",
"57\n",
"58\n",
"59\n",
"60\n",
"61\n",
"62\n",
"63\n",
"64\n",
"65\n",
"66\n",
"67\n",
"68\n",
"69\n",
"70\n",
"71\n",
"72\n",
"73\n",
"74\n",
"75\n",
"76\n",
"77\n",
"78\n",
"79\n",
"80\n",
"81\n",
"82\n",
"83\n",
"84\n",
"85\n",
"86\n",
"87\n",
"88\n",
"89\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/radekludacka/miniconda3/envs/enf/lib/python3.7/site-packages/numpy/core/fromnumeric.py:1970: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.\n",
" result = asarray(a).shape\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"9\n",
"10\n",
"11\n",
"12\n",
"13\n",
"14\n",
"15\n",
"16\n",
"17\n",
"18\n",
"19\n",
"20\n",
"21\n",
"22\n",
"23\n",
"24\n",
"25\n",
"26\n",
"27\n",
"28\n",
"29\n",
"30\n",
"31\n",
"32\n",
"33\n",
"34\n",
"35\n",
"36\n",
"37\n",
"38\n",
"39\n",
"40\n",
"41\n",
"42\n",
"43\n",
"44\n",
"45\n",
"46\n",
"47\n",
"48\n",
"49\n",
"50\n",
"51\n",
"52\n",
"53\n",
"54\n",
"55\n",
"56\n",
"57\n",
"58\n",
"59\n",
"60\n",
"61\n",
"62\n",
"63\n",
"64\n",
"65\n",
"66\n",
"67\n",
"68\n",
"69\n",
"70\n",
"71\n",
"72\n",
"73\n",
"74\n",
"75\n",
"76\n",
"77\n",
"78\n",
"79\n",
"80\n",
"81\n",
"82\n",
"83\n",
"84\n",
"85\n",
"86\n",
"87\n",
"88\n",
"89\n"
]
}
],
"source": [
"audio = extract_enf_signal('002.wav?raw=true')\n",
"audio_reference = extract_enf_signal('002_ref.wav?raw=true')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "cutting-click",
"metadata": {},
"outputs": [],
"source": [
"np.save('audio.npy', audio)\n",
"np.save('audio_reference.npy', audio_reference)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Conda Python 3.7 (pyenf)",
"language": "python",
"name": "pyenf"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}