Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- requirements.txt +0 -0
- transcribir_audio_whisper_hugginface.py +42 -0
requirements.txt
ADDED
File without changes
|
transcribir_audio_whisper_hugginface.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""Transcribir_audio_whisper.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1T1cju7HyQUWWlCiZQ87fNwT9plZ9CG3x
|
8 |
+
"""
|
9 |
+
|
10 |
+
!pip install gradio
|
11 |
+
!pip install openai-whisper
|
12 |
+
import whisper # Importing the whisper library
|
13 |
+
|
14 |
+
try:
|
15 |
+
import gradio as gr
|
16 |
+
except ModuleNotFoundError:
|
17 |
+
!pip install gradio
|
18 |
+
import gradio as gr
|
19 |
+
|
20 |
+
# Cargar el modelo de Whisper
|
21 |
+
model = whisper.load_model("base")
|
22 |
+
|
23 |
+
# Función principal que procesa el archivo de audio
|
24 |
+
def transcribe_and_translate(audio_file):
|
25 |
+
# Paso 1: Transcripción en español
|
26 |
+
result = model.transcribe(audio_file, language="es")
|
27 |
+
spanish_text = result["text"]
|
28 |
+
|
29 |
+
# Retornar la transcripción para que Gradio pueda mostrarla
|
30 |
+
return spanish_text
|
31 |
+
|
32 |
+
# Crear la interfaz de Gradio
|
33 |
+
iface = gr.Interface(
|
34 |
+
fn=transcribe_and_translate, # La función a llamar
|
35 |
+
inputs=gr.Audio(type="filepath"), # Subir archivo de audio
|
36 |
+
outputs=gr.Textbox(label="Transcripción en Español"),
|
37 |
+
title="Transcriptor de audio",
|
38 |
+
description="Sube un archivo de audio para obtener su transcripción."
|
39 |
+
)
|
40 |
+
|
41 |
+
# Iniciar la aplicación
|
42 |
+
iface.launch()
|