sAIvahini / app.py
TruthLens's picture
Update app.py
9235ff8 verified
raw
history blame
933 Bytes
import streamlit as st
import requests
import numpy as np
import sounddevice as sd
import wave
import io
# βœ… Set page title and layout
st.set_page_config(page_title="Sai Vahini AI Assistant", layout="centered")
# βœ… Render API URL (Ensure this matches your deployed API on Render)
RENDER_API_URL = "https://saivahini.onrender.com/process_audio"
# βœ… UI Header
st.markdown("<h1 style='text-align: center; color: #ff5733;'>Sai Vahini AI Voice Assistant πŸ•‰οΈ</h1>", unsafe_allow_html=True)
# βœ… Audio recording parameters
DURATION = 5 # Seconds
SAMPLE_RATE = 16000
# βœ… Function to record audio
def record_audio():
st.info("🎀 Recording... Speak now!")
audio = sd.rec(int(DURATION * SAMPLE_RATE), samplerate=SAMPLE_RATE, channels=1, dtype=np.int16)
sd.wait() # Wait until recording is finished
st.success("βœ… Recording completed!")
# βœ… Save the audio as a WAV file
audio_bytes = io.BytesIO