2023-08-20 11:29:13 +00:00
|
|
|
from pathlib import Path
|
2023-08-20 10:31:14 +00:00
|
|
|
import runpod
|
2023-08-20 11:29:13 +00:00
|
|
|
from runpod.serverless import os
|
|
|
|
import loaders
|
2023-08-22 08:32:07 +00:00
|
|
|
# import process
|
2023-08-20 12:29:36 +00:00
|
|
|
|
2023-08-20 10:31:14 +00:00
|
|
|
|
2023-08-22 08:32:07 +00:00
|
|
|
output_path:Path = Path(os.environ.get("VERBANOTE_OUTPUT_PATH", "/in"))
|
|
|
|
input_path:Path = Path(os.environ.get("VERBANOTE_INPUT_PATH", "/out"))
|
2023-08-20 12:29:36 +00:00
|
|
|
|
2023-08-22 08:32:07 +00:00
|
|
|
access_token: str = os.environ.get("VERBANOTE_HF_TOKEN", "")
|
2023-08-20 10:31:14 +00:00
|
|
|
|
2023-08-20 11:29:13 +00:00
|
|
|
loaders.prep()
|
2023-08-22 08:32:07 +00:00
|
|
|
# diarize_pipeline = loaders.diarization(access_token)
|
|
|
|
# whisper_model = loaders.whisper()
|
2023-08-20 10:31:14 +00:00
|
|
|
|
|
|
|
|
2023-08-20 11:29:13 +00:00
|
|
|
def handler(job):
|
2023-08-22 08:32:07 +00:00
|
|
|
input:dict = job["input"]
|
|
|
|
url: str | None = input.get("url")
|
|
|
|
|
|
|
|
if not url:
|
|
|
|
return {"error": "no file link provided"}
|
|
|
|
|
|
|
|
try:
|
|
|
|
audiofile = loaders.audiofile(url, input_path=input_path)
|
|
|
|
except Exception:
|
|
|
|
return {"error": "audiofile import failed"}
|
|
|
|
|
|
|
|
# diarized = process.diarize(audiofile, diarize_pipeline, output_path)
|
|
|
|
# diarized_groups = process.save_diarized_audio_files(
|
|
|
|
# diarized, audiofile, output_path
|
|
|
|
# )
|
|
|
|
# process.transcribe(
|
|
|
|
# model=whisper_model, diarized_groups=diarized_groups, output_path=output_path
|
|
|
|
# )
|
2023-08-20 12:29:36 +00:00
|
|
|
|
2023-08-20 11:29:13 +00:00
|
|
|
return {
|
|
|
|
"speaker_timings": "s3-address-to-speakers",
|
|
|
|
"transcription_text": "s3-address-to-transcription",
|
|
|
|
"transcription_page": "web-address-to-deployment",
|
2023-08-22 08:32:07 +00:00
|
|
|
"audiofile_path": str(audiofile)
|
2023-08-20 11:29:13 +00:00
|
|
|
}
|
2023-08-20 10:31:14 +00:00
|
|
|
|
2023-08-20 12:29:36 +00:00
|
|
|
# speakers = {
|
|
|
|
# # speaker, textboxcolor, speaker color
|
|
|
|
# "SPEAKER_00": ("SPEAKER00", "white", "darkgreen"),
|
|
|
|
# "SPEAKER_01": ("SPEAKER01", "white", "darkorange"),
|
|
|
|
# "SPEAKER_02": ("SPEAKER02", "white", "darkred"),
|
|
|
|
# "SPEAKER_03": ("SPEAKER03", "white", "darkblue"),
|
|
|
|
# "SPEAKER_04": ("SPEAKER04", "white", "darkyellow"),
|
|
|
|
# "SPEAKER_05": ("SPEAKER05", "white", "lightgreen"),
|
|
|
|
# "SPEAKER_06": ("SPEAKER06", "white", "lightred"),
|
|
|
|
# "SPEAKER_07": ("SPEAKER07", "white", "lightblue"),
|
|
|
|
# }
|
|
|
|
|
2023-08-20 10:31:14 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-08-20 11:29:13 +00:00
|
|
|
runpod.serverless.start({"handler": handler})
|