Spaces:
Build error
Build error
| import gradio as gr | |
| import torch | |
| from transformers import pipeline | |
| device = "cuda:0" if torch.cuda.is_available() else "cpu" | |
| pipe = pipeline( | |
| "automatic-speech-recognition", | |
| model="jonatasgrosman/wav2vec2-large-xlsr-53-persian", | |
| chunk_length_s=30, | |
| device=device, | |
| ) | |
| def transcribe(audio): | |
| text = pipe(audio["file"])["text"] | |
| return text | |
| iface = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(sources=["upload", "microphone"]), | |
| outputs="text", | |
| title="تبدیل گفتار به متن فارسی", | |
| description="فایل صوتی خود را آپلود کنید یا از طریق میکروفون صحبت کنید تا متن آن را دریافت کنید.", | |
| ) | |
| iface.launch() |