Spaces:
Sleeping
Sleeping
File size: 1,011 Bytes
bd7df7f 8389164 bd7df7f 8389164 bd7df7f 8389164 bd7df7f 8389164 84ee29a 8389164 84ee29a 8389164 84ee29a 8389164 bd7df7f 84ee29a f263ba4 |
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 |
import torch
from transformers import pipeline
import gradio as gr
import os
MODEL_NAME = "HarshitJoshi/whisper-small-Hindi"
device = 0 if torch.cuda.is_available() else "cpu"
pipe = pipeline(
task="automatic-speech-recognition",
model=MODEL_NAME,
device=device,
)
def transcribe_speech(filepath):
output = pipe(
filepath,
max_new_tokens=256,
generate_kwargs={
"task": "transcribe",
"language": "hindi",
},
chunk_length_s=10,
batch_size=4,
)
return output["text"]
example_folder = "./examples"
demo = gr.Interface(
fn=transcribe_speech,
inputs=gr.Audio(label="Audio Input", type="filepath"),
outputs=gr.Textbox(label="Transcription"),
title="Hindi Speech Transcription",
description=(
"Upload an audio file or record using your microphone to transcribe Hindi speech."
),
examples=example_folder,
cache_examples=True,
allow_flagging="never",
)
demo.launch(debug=True) |