import gradio as gr from speechbrain.pretrained import MetricGAN # Load the MetricGAN model from Hugging Face model = MetricGAN.from_hparams(source="speechbrain/metricgan-plus-voicebank") # Define a function to enhance speech def enhance_speech(audio_path): # Process the uploaded audio file through the model enhanced_audio = model.enhance(audio_path) return enhanced_audio # Set up the Gradio interface iface = gr.Interface( fn=enhance_speech, inputs=gr.Audio(source="upload", type="filepath"), outputs=gr.Audio(type="filepath"), title="Speech Enhancement" ) # Launch the Gradio interface iface.launch()