drum-kit-generator / audio_utils.py
arhanv's picture
ported audio_utils and inference from colab
1f5d38f
raw
history blame
337 Bytes
import streamlit as st
import soundfile as sf
import librosa
import numpy as np
import io
def play_audio(file_path):
"""Load and play an audio file."""
audio, sr = librosa.load(file_path, sr=16000)
audio_buffer = io.BytesIO()
sf.write(audio_buffer, audio, sr, format="wav")
st.audio(audio_buffer, format="audio/wav")