test-3 / app.py
CNYTX's picture
Update app.py
91373ab verified
Raw History Blame Contribute Delete
947 Bytes
import gradio as gr
import whisper
# Whisper modelini yükle
model = whisper.load_model("base") # "small", "tiny", "medium", "large" seçenekleri de kullanılabilir
def transcribe(audio):
"""Ses dosyasını metne çeviren fonksiyon"""
audio = whisper.load_audio(audio)
audio = whisper.pad_or_trim(audio)
mel = whisper.log_mel_spectrogram(audio).to(model.device)
options = whisper.DecodingOptions(fp16=False)
result = whisper.decode(model, mel, options)
return result.text
# Gradio arayüzü
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"), # "sources" yerine "source" kullanıldı
outputs=gr.Textbox(),
title="Whisper Speech-to-Text",
description="Konuşmayı metne çeviren OpenAI Whisper tabanlı bir uygulama.",
live=True # "streaming" kaldırıldı, sadece Interface seviyesinde kullanıldı
)
# Uygulamayı başlat
iface.launch()