verbanote-server/verbanote/rp_handler.py
Marty Oehme 7e91b7a1a2
Create simple loaders infrastructure
Loaders for models, necessary ffmpeg binaries and input files.
2023-08-20 13:29:13 +02:00

31 lines
922 B
Python

from pathlib import Path
import runpod
from runpod.serverless import os
import loaders
access_token = os.environ.get("VERBANOTE_HF_TOKEN")
output_path = os.environ.get("VERBANOTE_OUTPUT_PATH", "/transcriptions")
output_path = str(Path(output_path))
input_path = os.environ.get("VERBANOTE_INPUT_PATH", "/audiofiles")
input_path = str(Path(input_path))
loaders.prep()
diarize_pipeline = loaders.diarization(access_token)
whisper_model = loaders.whisper()
def handler(job):
input = job["input"]
audiofile = loaders.audiofile(input.get("file"), path = input_path)
if not audiofile:
return {"error": "missing audio file location"}
return {
"speaker_timings": "s3-address-to-speakers",
"transcription_text": "s3-address-to-transcription",
"transcription_page": "web-address-to-deployment",
}
if __name__ == "__main__":
runpod.serverless.start({"handler": handler})