carlfeynman's picture
Update app.py
369b584 verified
raw
history blame contribute delete
902 Bytes
from transformers import pipeline
model_id = 'carlfeynman/whisper-small-tamil'
pipe = pipeline('automatic-speech-recognition', model=model_id)
def transcribe_speech(filepath):
pred = pipe(
filepath,
max_new_tokens=256,
generate_kwargs={
"task": "transcribe",
"language": "tamil",
},
chunk_length_s=30,
batch_size=8,
)
return pred['text']
import gradio as gr
demo = gr.Blocks()
mic_transcribe = gr.Interface(
fn=transcribe_speech,
inputs=gr.Audio(source='microphone',type='filepath'),
outputs="textbox"
)
file_transcribe = gr.Interface(
fn=transcribe_speech,
inputs=gr.Audio(source='upload', type='filepath'),
outputs="textbox"
)
with demo:
gr.TabbedInterface(
[mic_transcribe, file_transcribe],
["Transcribe Microphone", "Transcribe Audio File"],
)
demo.launch(share=True)