Skip to content

Commit

Permalink
add h5py
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisbcook committed Jun 16, 2017
1 parent 0594533 commit 0f57282
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
h5py==2.7.0
ipykernel==4.6.1
jupyter==1.0.0
keras==2.0.5
Expand Down
31 changes: 13 additions & 18 deletions vui_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"scrolled": false
},
"outputs": [],
Expand Down Expand Up @@ -200,9 +199,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"#####################################################################\n",
Expand Down Expand Up @@ -638,9 +635,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"# specify the model\n",
Expand Down Expand Up @@ -690,15 +685,14 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from data_generator import AudioGenerator\n",
"from keras import backend as K\n",
"from utils import int_sequence_to_text\n",
"from IPython.display import Audio\n",
"\n",
"def get_predictions(index, partition, input_to_softmax, model_path):\n",
" \"\"\" Print a model's decoded predictions\n",
Expand All @@ -716,10 +710,12 @@
" # obtain the true transcription and the audio features \n",
" if partition == 'validation':\n",
" transcr = data_gen.valid_texts[index]\n",
" data_point = data_gen.normalize(data_gen.featurize(data_gen.valid_audio_paths[index]))\n",
" audio_path = data_gen.valid_audio_paths[index]\n",
" data_point = data_gen.normalize(data_gen.featurize(audio_path))\n",
" elif partition == 'train':\n",
" transcr = data_gen.train_texts[index]\n",
" data_point = data_gen.normalize(data_gen.featurize(data_gen.train_audio_paths[index]))\n",
" audio_path = data_gen.train_audio_paths[index]\n",
" data_point = data_gen.normalize(data_gen.featurize(audio_path))\n",
" else:\n",
" raise Exception('Invalid partition! Must be \"train\" or \"validation\"')\n",
" \n",
Expand All @@ -730,8 +726,9 @@
" pred_ints = (K.eval(K.ctc_decode(\n",
" prediction, output_length)[0][0])+1).flatten().tolist()\n",
" \n",
" # display the true and predicted transcriptions\n",
" # play the audio file, and display the true and predicted transcriptions\n",
" print('-'*80)\n",
" Audio(audio_path)\n",
" print('True transcription:\\n' + '\\n' + transcr)\n",
" print('-'*80)\n",
" print('Predicted transcription:\\n' + '\\n' + ''.join(int_sequence_to_text(pred_ints)))\n",
Expand All @@ -748,15 +745,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"get_predictions(index=0, \n",
" partition='train',\n",
" input_to_softmax=final_model(), \n",
" model_path='results/model_end.h5')"
" model_path='model_end.h5')"
]
},
{
Expand All @@ -777,7 +772,7 @@
"get_predictions(index=0, \n",
" partition='validation',\n",
" input_to_softmax=final_model(), \n",
" model_path='results/model_end.h5')"
" model_path='model_end.h5')"
]
},
{
Expand Down

0 comments on commit 0f57282

Please sign in to comment.