File size: 840 Bytes
e4fcbd0
 
 
 
 
 
 
 
 
50d330a
e4fcbd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""app.ipynb

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/1hjrg_bSp-xL_7P4IPkBVSDuTqeqsTZKY
"""

#!pip install gradio whisper torch

import gradio as gr
from transformers import pipeline

# Load the Whisper model
whisper_model = pipeline("automatic-speech-recognition", model="openai/whisper-small")

def transcribe_audio(audio_file):
    # Run Whisper model for transcription
    transcription = whisper_model(audio_file)["text"]
    return transcription

# Define Gradio Interface
iface = gr.Interface(
    fn=transcribe_audio,
    inputs=gr.Audio(type="filepath"),
    outputs="text",
    title="Whisper AI Small Model - Speech to Text",
    description="Upload or record audio to get the transcription.",
)

# Launch the interface
iface.launch()