Spaces:
Runtime error
Runtime error
mrolando
commited on
Commit
·
f58d4e7
1
Parent(s):
ef2c7e1
first
Browse files- Iso_Logotipo_Ceibal.png +0 -0
- app.py +62 -0
- requirements.txt +2 -0
Iso_Logotipo_Ceibal.png
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import base64
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
model_id = "openai/whisper-small" # update with your model id
|
6 |
+
#model_id ="openai/whisper-tiny"
|
7 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
8 |
+
|
9 |
+
def transcribe_speech(filepath):
|
10 |
+
output = pipe(
|
11 |
+
filepath,
|
12 |
+
max_new_tokens=256,
|
13 |
+
generate_kwargs={
|
14 |
+
"task": "transcribe",
|
15 |
+
"language": "spanish",
|
16 |
+
}, # update with the language you've fine-tuned on
|
17 |
+
chunk_length_s=30,
|
18 |
+
batch_size=8,
|
19 |
+
)
|
20 |
+
return output["text"]
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
|
26 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
27 |
+
|
28 |
+
demo = gr.Blocks()
|
29 |
+
|
30 |
+
mic_transcribe = gr.Interface(
|
31 |
+
fn=transcribe_speech,
|
32 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
33 |
+
outputs="textbox",
|
34 |
+
)
|
35 |
+
|
36 |
+
file_transcribe = gr.Interface(
|
37 |
+
fn=transcribe_speech,
|
38 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
39 |
+
outputs="textbox",
|
40 |
+
)
|
41 |
+
|
42 |
+
|
43 |
+
with demo:
|
44 |
+
gr.Markdown(
|
45 |
+
"""
|
46 |
+
<center>
|
47 |
+
<h1>
|
48 |
+
Uso de AI para transcribir audio a texto.
|
49 |
+
</h1>
|
50 |
+
<img src='data:image/jpg;base64,{}' width=200px>
|
51 |
+
<h3>
|
52 |
+
Con este espacio podrás transcribir audio a texto.
|
53 |
+
</h3>
|
54 |
+
</center>
|
55 |
+
""".format(encoded_image))
|
56 |
+
|
57 |
+
gr.TabbedInterface(
|
58 |
+
[mic_transcribe, file_transcribe],
|
59 |
+
["Transcribir desde el micrófono.", "Transcribir desde un Archivo de Audio."],
|
60 |
+
)
|
61 |
+
|
62 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|