whisper_simple / src /utils.py
nunenuh's picture
feat: add preloader for effiecient in time
7640294
raw
history blame contribute delete
503 Bytes
from pathlib import Path
import whisper
from typing import Any
def preprocess_audio(filepath: str) -> Any:
# load audio and pad/trim it to fit 30 seconds
audio = whisper.load_audio(filepath)
audio = whisper.pad_or_trim(audio)
return audio
def parsing_text(filepath: str):
path = Path(filepath)
if path.suffix.lower() not in ('.txt', '.md'):
raise ValueError("Invalid file type. Only '.txt' and '.md' files are supported.")
return path.read_text()