Spaces:
Build error
Build error
| from transformers.utils import logging | |
| logging.set_verbosity_error() | |
| # from datasets import load_dataset | |
| from transformers import pipeline | |
| import gradio as gr | |
| # dataset = load_dataset("librispeech_asr", | |
| # split="train.clean.100", | |
| # streaming=True, | |
| # trust_remote_code=True) | |
| asr = pipeline(task="automatic-speech-recognition", | |
| model="openai/whisper-small") | |
| demo = gr.Blocks() | |
| def transcribe_long_form(filepath): | |
| if filepath is None: | |
| gr.Warning("No audio found, please retry.") | |
| return "" | |
| output = asr( | |
| filepath, | |
| max_new_tokens=256, | |
| chunk_length_s=30, | |
| batch_size=8, | |
| ) | |
| return output["text"] | |
| mic_transcribe = gr.Interface( | |
| fn=transcribe_long_form, | |
| inputs=gr.Audio(sources="microphone", | |
| type="filepath"), | |
| outputs=gr.Textbox(label="Transcription", | |
| lines=3), | |
| allow_flagging="never") | |
| file_transcribe = gr.Interface( | |
| fn=transcribe_long_form, | |
| inputs=gr.Audio(sources="upload", | |
| type="filepath"), | |
| outputs=gr.Textbox(label="Transcription", | |
| lines=3), | |
| allow_flagging="never", | |
| ) | |
| with demo: | |
| gr.TabbedInterface( | |
| [mic_transcribe, | |
| file_transcribe], | |
| ["Transcribe Microphone", | |
| "Transcribe Audio File"], title= "Automatic Speech Recognition" | |
| ) | |
| demo.launch(share=True) |