import gradio as gr import os from helpers import make_header, upload_file, request_transcript, wait_for_completion, make_paragraphs_string title = """
Click here to learn more about the Conformer-1 model
""" def submit_to_AAI(api_key, radio, audio_file, mic_recording): if radio == "Audio File": audio_data = audio_file elif radio == "Record Audio": audio_data = mic_recording header = make_header(api_key) # 1. Upload the audio upload_url = upload_file(audio_data, header, is_file=False) # 2. Request transcript transcript_response = request_transcript(upload_url, header) transcript_id = transcript_response['id'] # 3. Wait for the transcription to complete _, error = wait_for_completion(transcript_id, header) if error is not None: return error # 4. Fetch paragraphs of transcript return make_paragraphs_string(transcript_id, header) def change_audio_source(radio): if radio == "Audio File": return [gr.Audio.update(visible=True), gr.Audio.update(visible=False)] elif radio == "Record Audio": return [gr.Audio.update(visible=False), gr.Audio.update(visible=True)] with gr.Blocks(css = """#col_container {width: 1000px; margin-left: auto; margin-right: auto;} #chatbot {height: 520px; overflow: auto;}""") as demo: gr.HTML('