File size: 905 Bytes
f5c0f72 dd39c7c f5c0f72 dd39c7c cdc56f1 dd39c7c cdc56f1 dd39c7c cdc56f1 bac0abc cdc56f1 f5c0f72 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
import torchaudio
from speechbrain.pretrained import EncoderClassifier
# Load the SpeechBrain model separately
model = EncoderClassifier.from_hparams(source="speechbrain/mtl-mimic-voicebank", savedir="tmp")
# Define the function to transcribe audio
def transcribe(audio):
# Load and process the audio file using torchaudio
signal, rate = torchaudio.load(audio)
# Make predictions using the SpeechBrain model
output = model.classify_batch(signal)
return output
# Define a CSS string to hide the footer
custom_css = """
footer {visibility: hidden;}
"""
# Create the Gradio interface
demo = gr.Interface(
fn=transcribe, # Function to process input
inputs=gr.Audio(sources="upload"), # Take audio input
outputs="text", # Display output as text
css=custom_css # Hide the Gradio footer
)
# Launch the interface
demo.launch() |