1

I have a pandas DataFrame where one of the columns is filled with Pydub AudioSegment objects.

I can display a single AudioSegment as an HTML audio player by just doing this in a cell:

from pydub import AudioSegment
AudioSegment.from_wav("never_gonna_give_you_up.wav")

However, when I display the pandas DataFrame, I just get a column filled with object references: (((<pydub.audio_segment.AudioSegment object at...

What I would like is for the column to fill with HTML audio players so I can view the metadata and listen to the clips.

Vinay
  • 469
  • 3
  • 14

1 Answers1

0

I had the same issue, Here is how I managed to display audio files in dataframe in Jupyter

import IPython.display as ipd

df['wav_pydub'] = df['wav_pydub'].apply(lambda x:x._repr_html_().replace('\n', '').strip(), axis=1)
df_html = df.to_html(escape=False, index=False)

ipd.display(ipd.HTML(table_html))
HazimoRa3d
  • 517
  • 5
  • 12