Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| import librosa | |
| pipe = pipeline("automatic-speech-recognition", model="model") | |
| def transcribe(audiofile): | |
| audio, sr = librosa.load(audiofile, sr=None) | |
| if sr != 16_000: | |
| audio = librosa.resample(audio, orig_sr=sr, target_sr=16_000) | |
| text = pipe(audio, chunk_length_s=25, stride_length_s=(5, 5))['text'] | |
| return text | |
| demo = gr.Interface( | |
| fn=transcribe, | |
| inputs=gr.Audio(type='filepath'), | |
| outputs=gr.Textbox(show_copy_button=True) | |
| ) | |
| if __name__ == '__main__': | |
| demo.launch() | |