Spaces:
Runtime error
Runtime error
File size: 1,019 Bytes
bb5feba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import librosa
from librosa import display
from librosa import feature
import numpy as np
from matplotlib import pyplot as plt
import scipy
from numpy import typing as npt
import typing
def show_duration(y: npt.ArrayLike, sr: int) -> float:
pass
def selcet_time(start_time: float, end_time: float) :
pass
def plot_waveform(ax, y: npt.ArrayLike, sr: int, start_time: float = 0.0, end_time: float = None) -> None :
# ax = plt.subplot(2, 1, 1)
startIdx = int(start_time * sr)
if not end_time :
librosa.display.waveshow(y[startIdx:], sr)
else :
endIdx = int(end_time * sr)
librosa.display.waveshow(y[startIdx:endIdx - 1], sr)
return
def signal_RMS_analysis(y: npt.ArrayLike, shift_time: float = 0.0) :
fig, ax = plt.subplots()
rms = librosa.feature.rms(y = y)
times = librosa.times_like(rms) + shift_time
ax.plot(times, rms[0])
ax.set_xlabel('Time (s)')
ax.set_ylabel('RMS')
return fig, ax, times, rms |