Spaces:
Sleeping
Sleeping
Commit
·
5bb77aa
1
Parent(s):
b11b1a0
Upload whisper_audio_file.py
Browse files- whisper_audio_file.py +42 -0
whisper_audio_file.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""whisper_audio_file.ipynb
|
| 3 |
+
|
| 4 |
+
Automatically generated by Colaboratory.
|
| 5 |
+
|
| 6 |
+
Original file is located at
|
| 7 |
+
https://colab.research.google.com/drive/1Drv49mO5QDOUMBpoWeRW6RrxGHLe0b2o
|
| 8 |
+
|
| 9 |
+
# Using gradio for making a nice UI.
|
| 10 |
+
Upload audio file version.
|
| 11 |
+
|
| 12 |
+
Installing requirements.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
!pip install gradio
|
| 16 |
+
!pip install git+https://github.com/huggingface/transformers
|
| 17 |
+
|
| 18 |
+
from transformers import pipeline
|
| 19 |
+
import gradio as gr
|
| 20 |
+
import os
|
| 21 |
+
|
| 22 |
+
"""## Building a Demo"""
|
| 23 |
+
|
| 24 |
+
pipe = pipeline(model="Victorlopo21/whisper-medium-gl-30")
|
| 25 |
+
#pipe = pipeline(model="marvmk/whisper-small-gl") # change to "your-username/the-name-you-picked"
|
| 26 |
+
|
| 27 |
+
def transcribe(audio):
|
| 28 |
+
text = pipe(audio, chunk_length=10)['text']
|
| 29 |
+
return text
|
| 30 |
+
|
| 31 |
+
iface = gr.Interface(
|
| 32 |
+
fn=transcribe,
|
| 33 |
+
inputs=gr.Audio(type="filepath"),
|
| 34 |
+
outputs="text",
|
| 35 |
+
title="Whisper Small Galician",
|
| 36 |
+
description="Realtime demo for Galician speech recognition using a fine-tuned Whisper small model.",
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
iface.launch(debug=True)
|
| 40 |
+
|
| 41 |
+
# TO TRY
|
| 42 |
+
|