File size: 933 Bytes
3a8d435 650621b 88ba4c2 9235ff8 3a8d435 9235ff8 88ba4c2 3a8d435 88ba4c2 3a8d435 9235ff8 650621b 9235ff8 480b0b2 9235ff8 |
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 |
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
|