Download app.py from CNYTX/test-3: direct link, hf CLI and curl.
- Browser
- Download file 947 Bytes
-
https://huggingface.co/spaces/CNYTX/test-3/resolve/main/app.py
- Command line
-
hf download hf://spaces/CNYTX/test-3/app.py
-
curl -L -o app.py https://huggingface.co/spaces/CNYTX/test-3/resolve/main/app.py
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() | |