Team Ai
Apppublic

deepak2563/opensourcetranscriptmaker

sourceHugging Faceunknownupdated 4mo agoView on Hugging Face
0likes
storage.py40 linesDownload Raw Back to services
1import os2import shutil3from typing import Dict4from ..models.job import Job5 6TEMP_STORAGE_PATH = os.environ.get("TEMP_STORAGE_PATH", "./data")7 8# In-memory database for MVP (wipes on restart, which is fine since Render free tier has ephemeral disk anyway)9jobs_db: Dict[str, Job] = {}10 11def get_job(job_id: str) -> Job | None:12    return jobs_db.get(job_id)13 14def save_job(job: Job):15    jobs_db[job.jobId] = job16 17def delete_job(job_id: str):18    if job_id in jobs_db:19        job = jobs_db[job_id]20        if os.path.exists(job.audioPath):21            try:22                os.remove(job.audioPath)23            except:24                pass25        if job.transcriptPath and os.path.exists(job.transcriptPath):26            try:27                os.remove(job.transcriptPath)28            except:29                pass30        del jobs_db[job_id]31 32def get_audio_path(job_id: str, filename: str) -> str:33    os.makedirs(TEMP_STORAGE_PATH, exist_ok=True)34    ext = os.path.splitext(filename)[1]35    return os.path.join(TEMP_STORAGE_PATH, f"{job_id}_audio{ext}")36 37def get_transcript_path(job_id: str) -> str:38    os.makedirs(TEMP_STORAGE_PATH, exist_ok=True)39    return os.path.join(TEMP_STORAGE_PATH, f"{job_id}_transcript.txt")40