I have a Streamlit application where I use two forms, one in each column. The first form transcribes an audio file using Wav2Vec2, and the second one asks questions about the transcription using ChatGPT. The problem I’m facing is that when I click the “chatgpt_submit_button”, it also triggers the “transcribe_submit_button”. I need them to be separated, so that each column operates independently.
Here’s a simplified version of my code:
import streamlit as st st.set_page_config(page_title="Speech-to-Text Transcription & ChatGPT", layout="wide", page_icon="🎤") c1, c2 = st.columns([1, 1], gap="medium") with c1: st.header("Transcribe your audio") with st.form("transcribe_form"): f = st.file_uploader("", type=[".wav"]) transcribe_submit_button = st.form_submit_button("Transcribe") if f and transcribe_submit_button is not None: # Transcription code here pass with c2: st.header("Ask ChatGPT about the transcription") with st.form("chatgpt_form"): prompt = st.text_area("Enter your query:", "", height=200) chatgpt_submit_button = st.form_submit_button("Generate response") if chatgpt_submit_button: # ChatGPT code here pass
I want the “transcribe_submit_button” and “chatgpt_submit_button” to work independently of each other. How can I achieve this in Streamlit? Any help would be greatly appreciated.