CoolFace
Apppublic

AfifAlvan/WhisperAPI

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
transcribe.py26 linesDownload Raw Back to root
1import whisper2import os3from download import download_video4 5model_name = "base.en"6model = whisper.load_model(model_name)7 8def transcribe(url):9    video = download_video(url)10    result = model.transcribe(video["file_name"])11    os.remove(video["file_name"])12 13    segments = []14    for item in result["segments"]:15        segments.append(format_item(item))16 17    return {18        "title": video["title"],19        "segments": segments20    }21 22def format_item(item):23    return {24        "time": item["start"],25        "text": item["text"]26    }