import streamlit as st from audiorecorder import audiorecorder st.title("Streamlit + LLM") st.caption("🚀 Dodo AI") with st.sidebar: openai_api_key = st.text_input("OpenAI API Key", key="chatbot_api_key", type="password") "[Get an OpenAI API key](https://platform.openai.com/account/api-keys)" def generate_response(input_text): st.info(input_text) # llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key) # st.info(llm(input_text)) with st.form('my_form'): text = st.text_area('Enter text:', 'What are the three key pieces of advice for learning how to code?') submitted = st.form_submit_button('Submit') if not openai_api_key.startswith('sk-'): st.warning('Please enter your OpenAI API key!', icon='⚠') if submitted and openai_api_key.startswith('sk-'): generate_response(text) audio = audiorecorder("", "") if len(audio) > 0: # To play audio in frontend: st.audio(audio.export().read()) # To save audio to a file, use pydub export method: audio.export("audio.wav", format="wav") # To get audio properties, use pydub AudioSegment properties: st.write(f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds")