pip install audioread python import audioread with audioread.audio_open("audio.mp3") as f: print(f.channels, f.samplerate, f.duration) for frame in f: print(frame) python import audioread import librosa import matplotlib.pyplot as plt with audioread.audio_open("audio.wav") as f: audio, sr = librosa.load(f, sr=f.samplerate) mel_specgram = librosa.feature.melspectrogram(y=audio, sr=sr) plt.figure(figsize=(10, 4)) librosa.display.specshow(librosa.power_to_db(mel_specgram, ref=np.max), x_axis='time', y_axis='mel', sr=sr, fmax=8000) plt.colorbar(format='%+2.0f dB') plt.title('Mel Spectrogram') plt.tight_layout() plt.show()


上一篇:
下一篇:
切换中文