Download transcriber.py from 404chain/shortV: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/404chain/shortV/resolve/main/transcriber.py
- Command line
-
hf download hf://spaces/404chain/shortV/transcriber.py
-
curl -L -o transcriber.py https://huggingface.co/spaces/404chain/shortV/resolve/main/transcriber.py
721 Bytes
| import whisper | |
| import warnings | |
| # Mengabaikan peringatan sistem agar log tetap bersih | |
| warnings.filterwarnings("ignore") | |
| def transcribe_video(video_path): | |
| """Mengekstrak audio dari video dan mengubahnya menjadi teks""" | |
| try: | |
| # Kita menggunakan model 'base' agar prosesnya cepat di server gratis | |
| model = whisper.load_model("base") | |
| # Proses transkripsi (mengubah suara ke teks) | |
| result = model.transcribe(video_path) | |
| # result["text"] berisi seluruh ucapan di dalam video | |
| return result["text"], "✅ Suara berhasil diubah menjadi teks transkrip lengkap." | |
| except Exception as e: | |
| return None, f"❌ Gagal melakukan transkripsi: {str(e)}" |