-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (23 loc) · 1.02 KB
/
app.py
File metadata and controls
30 lines (23 loc) · 1.02 KB
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
from src.helper import voice_input, text_to_speech, llm_model_object
def main():
st.title("Multilingual AI Assistant")
if st.button("Ask me anything!"):
with st.spinner("Listening..."):
text = voice_input()
if not text:
st.error("Sorry, could not understand the audio. Please try again.")
return
response = llm_model_object(text)
text_to_speech(response)
# Display audio player and download link
audio_file = open("speech.mp3", 'rb')
audio_bytes = audio_file.read()
st.text_area(label="Response:", value=response, height=350)
st.audio(audio_bytes, format='audio/mp3')
st.download_button(label="Download Speech",
data=audio_bytes,
file_name="speech.mp3",
mime="audio/mp3")
if __name__ == "__main__":
main()