Skip to content

Commit

Permalink
Try using IPython.display.display instead of returning IPython.displa…
Browse files Browse the repository at this point in the history
…y.Audio in ipywidgets.interact in examples/pitch_manipulation.ipynb, as workaround for deadline
  • Loading branch information
YannickJadoul committed Mar 18, 2024
1 parent c2349a8 commit 22fb469
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions docs/examples/pitch_manipulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -226,30 +226,18 @@
"source": [
"import ipywidgets\n",
"import glob\n",
"from IPython.display import Audio\n",
"\n",
"\n",
"def interactive_change_pitch(audio_file, factor):\n",
" sound = parselmouth.Sound(audio_file)\n",
" sound_changed_pitch = change_pitch(sound, factor)\n",
" return Audio(data=sound_changed_pitch.values, rate=sound_changed_pitch.sampling_frequency)\n",
" display(Audio(data=sound_changed_pitch.values, rate=sound_changed_pitch.sampling_frequency))\n",
"\n",
"w = ipywidgets.interact(interactive_change_pitch,\n",
" audio_file=ipywidgets.Dropdown(options=sorted(glob.glob(\"audio/*.wav\")), value=\"audio/4_b.wav\"),\n",
" factor=ipywidgets.FloatSlider(min=0.25, max=4, step=0.05, value=1.5))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbsphinx": "hidden",
"tags": []
},
"outputs": [],
"source": [
"# Workaround deadlock with ipywidgets.interact and IPython.display.Audio (https://github.com/jupyter/nbconvert/issues/2029)\n",
"import time\n",
"time.sleep(2)"
]
}
],
"metadata": {
Expand Down

0 comments on commit 22fb469

Please sign in to comment.