File size: 337 Bytes
1f5d38f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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")