import gradio as gr import assemblyai as aai # Replace with your AssemblyAI API key aai.settings.api_key = "62acec891bb04c339ec059b738bedac6" # Function to handle audio recording and transcription def transcribe_audio(audio_path): # Transcribe the audio file using AssemblyAI transcriber = aai.Transcriber() transcript = transcriber.transcribe(audio_path) # Handle the transcription result if transcript.status == aai.TranscriptStatus.error: return transcript.error else: return transcript.text # Create the Gradio interface with gr.Blocks() as demo: gr.Markdown("# Audio Transcription App") with gr.Row(): with gr.Column(): audio_input = gr.Audio(type="filepath", label="Record your audio") output_text = gr.Textbox(label="Transcription") with gr.Column(): transcribe_button = gr.Button("Transcribe") transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=output_text) # Launch the app demo.launch()