model / app.py
Drashti's picture
Update app.py
50d330a verified
Raw
History Blame Contribute Delete
840 Bytes
# -*- 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()