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