示例#1
0
    def __init__(self, path: Path = None):
        if path is None:
            name = hasher.new()
            super().__init__(parent_path=Path(user_data_dir('elpis')),
                             dir_name=name,
                             pre_allocated_hash=name,
                             name=name)
        else:
            path = Path(path).absolute()
            super().__init__(parent_path=path.parent, dir_name=path.name)
        # ensure object directories exist
        self.datasets_path = self.path.joinpath('datasets')
        self.datasets_path.mkdir(parents=True, exist_ok=True)
        self.pron_dicts_path = self.path.joinpath('pron_dicts')
        self.pron_dicts_path.mkdir(parents=True, exist_ok=True)
        self.models_path = self.path.joinpath('models')
        self.models_path.mkdir(parents=True, exist_ok=True)
        self.loggers_path = self.path.joinpath('loggers')
        self.loggers_path.mkdir(parents=True, exist_ok=True)
        self.transcriptions_path = self.path.joinpath('transcriptions')
        # config objects
        self.loggers = []
        self.datasets = {}
        self.pron_dicts = {}
        self.models = {}
        self.transcriptions = {}

        self.config['loggers'] = []
        self.config['datasets'] = {}
        self.config['pron_dicts'] = {}
        self.config['models'] = {}
        self.config['transcriptions'] = {}

        # make a default logger
        self.new_logger(default=True)
示例#2
0
    def __init__(self,
                 parent_path: Path = None,
                 dir_name: str = None,
                 name: str = None,
                 logger: Logger = None,
                 pre_allocated_hash: str = None):
        if pre_allocated_hash is None:
            h = hasher.new()
        else:
            h = pre_allocated_hash
        if dir_name is None:
            dir_name = h

        # path to the object
        self.__path = Path(parent_path).joinpath(dir_name)
        self.path.mkdir(parents=True, exist_ok=True)
        self.logger = logger
        self.ConfigurationInterface(self)._save({})
        self.config['name'] = name
        self.config['hash'] = h
        self.config['date'] = str(time.time())

        if logger is None:
            self.config['logger'] = None
        else:
            self.config['logger'] = logger.hash
示例#3
0
def new():
    kaldi: KaldiInterface = app.config['INTERFACE']
    transcription = kaldi.new_transcription(
        hasher.new())  # TODO transcriptions have no name
    model: Model = app.config['CURRENT_MODEL']
    transcription.link(model)
    app.config['CURRENT_TRANSCRIPTION'] = transcription
    file = request.files['file']
    transcription.prepare_audio(
        file, on_complete=lambda: print('Prepared audio file!'))
    return jsonify({"status": "ok", "data": transcription.status})
示例#4
0
def new():
    kaldi: KaldiInterface = app.config['INTERFACE']
    transcription = kaldi.new_transcription(hasher.new())
    model: Model = app.config['CURRENT_MODEL']
    transcription.link(model)
    app.config['CURRENT_TRANSCRIPTION'] = transcription
    file = request.files['file']
    transcription.prepare_audio(file, on_complete=lambda: print('Prepared audio file!'))
    data = {
        "status": transcription.status,
        "originalFilename": file.filename
    }
    return jsonify({
        "status": 200,
        "data": data
    })
示例#5
0
 def __init__(self, path: Path = None):
     if path is None:
         name = hasher.new()
         super().__init__(
             parent_path=Path(user_data_dir('elpis')),
             dir_name = name,
             pre_allocated_hash=name,
             name=name
         )
     else:
         path = Path(path).absolute()
         super().__init__(
             parent_path=path.parent,
             dir_name=path.name
         )
     # ensure object directories exist
     self.datasets_path = self.path.joinpath('datasets')
     self.datasets_path.mkdir(parents=True, exist_ok=True)
     self.pron_dicts_path = self.path.joinpath('pron_dicts')
     self.pron_dicts_path.mkdir(parents=True, exist_ok=True)
     self.models_path = self.path.joinpath('models')
     self.models_path.mkdir(parents=True, exist_ok=True)
     self.loggers_path = self.path.joinpath('loggers')
     self.loggers_path.mkdir(parents=True, exist_ok=True)
     self.transcriptions_path = self.path.joinpath('transcriptions')
     # config objects
     self.loggers = []
     self.datasets = {}
     self.pron_dicts = {}
     self.models = {}
     self.transcriptions = {}
     """
     TODO: temporarily don't set config here while we are still doing
     hacky mode of checking ig config_file_path.exists() in fsobject.py
     because this is wiping exising object info from interface.json.
     When we are happy with proper way of using existing state, change this.
     """
     # self.config['loggers'] = []
     # self.config['datasets'] = {}
     # self.config['pron_dicts'] = {}
     # self.config['models'] = {}
     # self.config['transcriptions'] = {}
     # make a default logger
     self.new_logger(default=True)
 def __init__(self, base_path: Path):
     self.hash = hasher.new()
     self.path = base_path.joinpath(self.hash)