2023-08-20 11:29:13 +00:00
|
|
|
import locale
|
|
|
|
from pathlib import Path
|
2023-08-22 08:32:07 +00:00
|
|
|
# from whisper import Whisper
|
|
|
|
# from pyannote.audio import Pipeline
|
|
|
|
# import torch
|
2023-08-20 11:29:13 +00:00
|
|
|
import static_ffmpeg
|
2023-08-22 08:32:07 +00:00
|
|
|
import file_operations
|
2023-08-20 11:29:13 +00:00
|
|
|
|
|
|
|
def prep() -> None:
|
|
|
|
locale.getpreferredencoding = lambda: "UTF-8"
|
|
|
|
# download and add ffmpeg to env
|
|
|
|
static_ffmpeg.add_paths()
|
|
|
|
|
2023-08-20 12:29:36 +00:00
|
|
|
|
2023-08-22 08:32:07 +00:00
|
|
|
def audiofile(url: str, input_path: Path) -> Path:
|
|
|
|
file = file_operations.download_from_url(url, input_path)
|
|
|
|
file_wav = file_operations.convert_to_wav(file, input_path)
|
|
|
|
file.unlink()
|
|
|
|
return file_wav
|
|
|
|
|
|
|
|
#
|
|
|
|
# def diarization(access_token: str | None) -> Pipeline:
|
|
|
|
# pipeline = Pipeline.from_pretrained(
|
|
|
|
# "pyannote/speaker-diarization", use_auth_token=access_token
|
|
|
|
# )
|
|
|
|
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
# return pipeline.to(device)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# def whisper() -> Whisper:
|
|
|
|
# # LOAD MODEL INTO VRAM
|
|
|
|
# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
# return whisper.load_model("large", device=device)
|