Spaces:
Sleeping
Sleeping
File size: 699 Bytes
711a34a 0fb5565 711a34a 0fb5565 711a34a 2c18b36 0fb5565 2c18b36 |
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 |
import gradio as gr
from transformers import pipeline
model = "openai/whisper-small"
pipe = pipeline("automatic-speech-recognition", model=model)
def transcribe_speech(filepath):
output = pipe(
filepath,
max_new_tokens=256,
generate_kwargs={
"task": "transcribe",
},
chunk_length_s=30,
batch_size=8,
)
return output["text"]
demo = gr.Blocks()
mic_transcribe = gr.Interface(
fn=transcribe_speech,
inputs=gr.Audio(sources="microphone", type="filepath"),
outputs=gr.outputs.Textbox(),
)
with demo:
gr.TabbedInterface(
[mic_transcribe],
["Transcribe Microphone"],
)
demo.launch(debug=True) |