0

I have built an app for recording audio through microphone using Gradio. I'am trying to display an error which will appear if the user hasn't attached a microphone. I need two things to be happening

  1. Error message should be displayed if there is no microphone attached
  2. After recording is complete and user clicks on stop recording, then there should be a button to enable downloading the call Please help in this code how to incorporate the same. The code is displayed below:
import gradio as gr
import os

def record_audio(microphone):
        if (microphone is None):
                raise gr.Error( "ERROR: Please attach a microphone as the audio source")

mf_record = gr.Interface(fn = record_audio,inputs = [gr.inputs.Audio(source="microphone", type="filepath", optional=True)],outputs = None,title = "Audio Recorder",live=True,css = "footer {visibility: hidden}",description = ("Tool to enable voice recording through a microphone"),allow_flagging = "manual")

if __name__ == "__main__":
        mf_record.launch()
Mike Szyndel
  • 10,461
  • 10
  • 47
  • 63
Indranil
  • 31
  • 6

0 Answers0