Spaces:
Runtime error
Runtime error
import librosa | |
import torch | |
from pathlib import Path | |
import whisper | |
sample_rate: int = 16000 | |
float_factor: float = 32678.0 | |
def preprocess_audio(filepath: str): | |
# 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() | |