File size: 1,287 Bytes
e43431e
 
 
 
20472e0
e43431e
 
 
 
 
 
 
 
 
 
 
 
 
c30114c
 
 
e43431e
 
 
 
c30114c
e43431e
 
 
 
 
3f4d22d
e43431e
 
 
 
 
 
3f4d22d
e43431e
 
0a5db34
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
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
from transformers import pipeline

# Load the Hugging Face model pipeline (example: Automatic Speech Recognition)
model = pipeline("automatic-speech-recognition", model="kattojuprashanth238/whisper-small-te-v9")

def process_audio(audio):
    """
    Process the audio input and return the transcription.
    Args:
    - audio: file path of the uploaded or recorded audio

    Returns:
    - Transcription text
    """
    if audio is None:
        return "No audio input provided."
    try:
        # Hugging Face model processing with long-form transcription
        result = model(audio, return_timestamps=True)
        transcription = result["text"]
        return transcription
    except Exception as e:
        return f"Error processing audio: {str(e)}"


# Gradio interface
with gr.Blocks() as app:
    gr.Markdown("## Audio Transcription Interface")
    gr.Markdown("Record audio or upload an audio file to transcribe it.")

    audio_input = gr.Audio(type="filepath", label="Record or Upload Audio")
    output = gr.Textbox(label="Transcription Result")

    # Submit button for processing
    btn = gr.Button("Transcribe")

    # Logic for the interface
    btn.click(process_audio, inputs=audio_input, outputs=output)

# Launch the interface
app.launch()