File size: 745 Bytes
4d18b1a
 
 
 
08a9934
4d18b1a
 
691851d
d63a731
 
4d18b1a
 
 
 
 
 
d63a731
 
4d18b1a
 
 
 
 
 
 
3fd7ea6
691851d
d63a731
4d18b1a
 
691851d
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
import torch
import gradio as gr
from transformers import pipeline

model_id = "openai/whisper-large"  # Using the model you provided
pipe = pipeline("automatic-speech-recognition", model=model_id)

title = "Automatic Speech Recognition"
description = """
"""

def transcribe_speech(filepath):
    output = pipe(
        filepath,
        generate_kwargs={
            "task": "transcribe",
            "language": "english",  # Set to English
        },  
    )
    return output["text"]

file_transcribe = gr.Interface(
    fn=transcribe_speech,
    inputs=gr.Audio(source="upload", type="filepath"),
    outputs=gr.outputs.Textbox(),
    examples=[["./example.wav"]],
    title=title,
    description=description,
)

file_transcribe.launch()