Skip to content

Commit 2cd201c

Browse files
committed
Update chapter 11
1 parent ab26df0 commit 2cd201c

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

chapter11_image/02_filters.ipynb

Lines changed: 7 additions & 6 deletions
Large diffs are not rendered by default.

chapter11_image/06_speech.ipynb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"from io import BytesIO\n",
17+
"import tempfile\n",
1718
"import requests\n",
1819
"import numpy as np\n",
1920
"import scipy.signal as sg\n",
@@ -32,9 +33,10 @@
3233
"def speak(data):\n",
3334
" # We convert the mp3 bytes to wav.\n",
3435
" audio = pydub.AudioSegment.from_mp3(BytesIO(data))\n",
35-
" wave = audio.export('_', format='wav')\n",
36-
" wave.seek(0)\n",
37-
" wave = wave.read()\n",
36+
" with tempfile.TemporaryFile() as fn:\n",
37+
" wavef = audio.export(fn, format='wav')\n",
38+
" wavef.seek(0)\n",
39+
" wave = wavef.read()\n",
3840
" # We get the raw data by removing the 24 first bytes\n",
3941
" # of the header.\n",
4042
" x = np.frombuffer(wave, np.int16)[24:] / 2.**15\n",

chapter11_image/07_synth.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@
114114
" # in a dedicated Output widget.\n",
115115
" with widgets.Output():\n",
116116
" synth(f)\n",
117+
"\n",
117118
" button.on_click(partial(on_button_clicked, f))\n",
118119
" buttons.append(button)\n",
120+
"\n",
119121
"# We place all buttons horizontally.\n",
120122
"widgets.Box(children=buttons)"
121123
]

0 commit comments

Comments
 (0)