In [1]:
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.plotting import figure
from scipy.io import wavfile
from bokeh.models import Range1d
from bokeh.layouts import column
In [2]:
output_notebook()
Loading BokehJS ...
In [3]:
wav_path = './audio_17_1s.wav'
In [4]:
sample_rate, samples = wavfile.read(wav_path)
print(sample_rate)
print(samples.dtype)
44100
int16
In [5]:
xs = [i for i in range(len(samples))]
ys = samples[:, 0] / (np.iinfo(samples.dtype).max + 1)
In [6]:
p = figure(plot_width=800, plot_height=100, background_fill_color="#ffffff")
p.y_range = Range1d(-1.0, 1.0)
p.title.text = wav_path
p.line(xs, ys, line_color="darkgrey", line_width=1, alpha=1.0)
show(column(p))