File size: 663 Bytes
d7aa11b
05e9e3a
3ecb0fd
f3c7107
61f52ca
05e9e3a
c575d84
61f52ca
3ecb0fd
61f52ca
fcdc02f
 
05e9e3a
f3c7107
3ecb0fd
d7aa11b
05e9e3a
61f52ca
d7aa11b
 
f3c7107
61f52ca
c227f48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline
import librosa

# Initialize the ASR model
asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small")

def transcribe(file_path):
    # Load the audio file with librosa
    data, samplerate = librosa.load(file_path, sr=None)
    # Pass the audio data to the model for transcription without specifying sampling_rate
    transcription = asr_model(data)
    return transcription["text"]

# Create the Gradio interface
iface = gr.Interface(
    fn=transcribe,
    inputs=gr.Audio(type="filepath", label="Record or Upload Audio"),
    outputs="text"
)

# Launch the interface
iface.launch()