Music Player and Cutter App: Audio / Song Waveform Plot with Multiselector

Hi,

I’m trying to create an interactive sound waveform. I am able to generate a plot using matplotlib, but when i do the same with plotly, it keeps processing and eventually gives up. Is it because the sample is too big? (my 3 min no_time mp3 had a 1D array with 21891072 datapoints)

####### Code ########
#conda install -c conda-forge pydub
#conda install -c anaconda pyaudio
#conda install -c anaconda pillow
#conda install -c conda-forge ffmpeg

import pyaudio
import pydub
from pydub import AudioSegment
from pydub.playback import play
from matplotlib import pyplot as plt
from PIL import Image, ImageDraw
import numpy as np
import os
import pandas as pd
import copy
import dash
from dash.dependencies import Input, Output, State, ClientsideFunction
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import plotly.graph_objects as go

#you can load any mp3 audio song here
audio = AudioSegment.from_mp3(“No_Time.mp3”)
channels = audio.channels
width = audio.sample_width
frate = audio.frame_rate

#obtaining raw_data from mp3 for plotting songs waveform
data = np.fromstring(audio._data, np.int16)
#audio song aplitude data
g = pd.DataFrame({‘Amplitude’: data})

plt.plot(g)
#plot pic is attached

####### Code Ends ########

For plotly i have tried a bunch:

px.bar(df,x=df.index,y=‘Amplitude’)
px.line(df,x=df.index,y=‘Amplitude’)
go.Figure([go.Scatter(x=df.index, y=df[‘Amplitude’])])

None of them seems to work.

In the end. I want to have a plot like “Completed Wells/Year” in the “New York Oil and Gas” dash sample app.
Oil_gas_app

And regarding, Multi-selector I mean like if you play with the “completed wells/year” graph, you can only “box-select” one portion of a graph at a time, is it possible to have multiple-selector boxes over a plot? With multi-selector boxes hovering over the original plot, I can erase/cut multiple portions of a song in a single cut.

Thanks