From 59d549f234e8cb1a831a23eeb218342b75d87347 Mon Sep 17 00:00:00 2001 From: Martin Andrews Date: Tue, 13 Feb 2018 23:00:25 +0800 Subject: [PATCH] txt file optionally loaded into text box --- .../8-Speech/SpeechAnalysis_Annotation.ipynb | 54 +++++++++++++++---- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/notebooks/2-CNN/8-Speech/SpeechAnalysis_Annotation.ipynb b/notebooks/2-CNN/8-Speech/SpeechAnalysis_Annotation.ipynb index c06f042..782d45b 100644 --- a/notebooks/2-CNN/8-Speech/SpeechAnalysis_Annotation.ipynb +++ b/notebooks/2-CNN/8-Speech/SpeechAnalysis_Annotation.ipynb @@ -63,6 +63,13 @@ "_sample_rate" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -94,8 +101,8 @@ " )\n", " return '#'+hsh\n", "\n", - "html_id=play_audio_samples(audio_samples)\n", - "html_id" + "audio_id=play_audio_samples(audio_samples)\n", + "audio_id" ] }, { @@ -106,7 +113,7 @@ "source": [ "# https://www.sitepoint.com/community/t/multiple-clickable-audio-timestamps/273260/9\n", "\n", - "HTML(\"\"\"\"\"\") #.format(id=html_id)" + "\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "txt_filename = audio_filename.replace('.mp3', '.txt')\n", + "txt_for_audio = ''\n", + "try:\n", + " with open(txt_filename, 'rt') as f:\n", + " txt_for_audio=f.read()\n", + " print(\"%s loaded\" % txt_filename)\n", + "except:\n", + " print(\"%s : File not found\" % txt_filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "notebook_html(\"\"\"\n", + "\n", + "\"\"\".format(id=audio_id+'_tb', content=txt_for_audio))" ] }, { @@ -130,10 +161,11 @@ "metadata": {}, "outputs": [], "source": [ - "HTML(\"\"\"\"\"\".format(id=html_id))" + "notebook_html(\"\"\"\"\"\".format(id=audio_id))" ] }, {