made cli work with new interface

This commit is contained in:
Jaikinator
2024-01-25 16:08:53 +01:00
parent c65dc51541
commit ef7bd6e15c
3 changed files with 100 additions and 49 deletions
+15
View File
@@ -1,6 +1,7 @@
import os
import yaml
from pyannote.audio.core.model import CACHE_DIR as PYANNOTE_CACHE_DIR
from argparse import Action
CACHE_DIR = os.getenv(
"AUTOT_CACHE",
@@ -38,3 +39,17 @@ def config_diarization_yaml(file_path: str, path_to_segmentation: str = None) ->
with open(file_path, "w") as stream:
yaml.dump(yml, stream)
class ParseKwargs(Action):
"""
Custom argparse action to parse keyword arguments.
"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, dict())
for value in values:
key, value = value.split('=')
try:
value = eval(value)
except:
pass
getattr(namespace, self.dest)[key] = value