Esempio n. 1
0
def main():
    print("Reading YAML paths from stdin...", file=sys.stderr)

    for yml_path_str in sys.stdin:
        yml_path = Path(yml_path_str.strip())
        profile_dir = yml_path.parent
        profile_name = profile_dir.name

        # Check common files
        common_files = [
            profile_dir / "acoustic_model",
            profile_dir / "base_dictionary.txt",
            profile_dir / "base_language_model.txt",
            profile_dir / "g2p.fst",
            profile_dir / "phoneme_examples.txt",
            profile_dir / "espeak_phonemes.txt",
            profile_dir / "sentences.ini",
            profile_dir / "stop_words.txt",
            profile_dir / "custom_words.txt",
            profile_dir / "frequent_words.txt",
            profile_dir / "SOURCE",
            profile_dir / "LICENSE",
            profile_dir / "clean.sh",
        ]

        for p in common_files:
            if not path_exists(p):
                print(profile_name, "missing", p.name)

        # ---------------------------------------------------------------------

        with open(yml_path, "r") as yml_file:
            profile = load_profile(yml_file)

        kaldi_model_type = pydash.get(profile,
                                      "speech-to-text.kaldi.model-type", "")

        if len(kaldi_model_type) > 0:
            # Check Kaldi specific files
            model_dir = profile_dir / "acoustic_model"
            kaldi_files = [
                model_dir / "model" / "final.mdl",
                model_dir / "model" / "graph" / "HCLG.fst",
                model_dir / "phones" / "nonsilence_phones.txt",
                model_dir / "phones" / "silence_phones.txt",
            ]

            if kaldi_model_type == "gmm":
                kaldi_files.extend([model_dir / "conf" / "mfcc.conf"])
            elif kaldi_model_type == "nnet3":
                kaldi_files.extend([
                    model_dir / "conf" / "online_cmvn.conf",
                    model_dir / "conf" / "mfcc_hires.conf",
                ])

            for p in kaldi_files:
                if not path_exists(p):
                    print(profile_name, "missing", p.name)
Esempio n. 2
0
    def handle_hello(self, request: custom_types.HttpRequest) -> None:
        if request.method != "get":
            raise errors.MethodNotAllowed

        profile = utils.load_profile(request.session)
        user = custom_types.User.build(profile)

        content = self.render_hello_page(request, user, user)

        self.respond(content)
Esempio n. 3
0
    def handle_hello(self, request: HttpRequest) -> None:
        if request.method != "get":
            raise MethodNotAllowed

        profile = load_profile(request.session)
        user = User.build(profile)

        content = self.render_hello_page(request, user, user)
        # session = self.get_session()
        # if not session:
        #     session = self.generate_new_session
        #     user = User.build("")
        #     content = self.render_hello_page(user, user)
        #     self.respond(content, session=session)
        #
        # query = self.load_user_data(session)
        # user = User.build(query)
        #
        # content = self.render_hello_page(user, user)
        self.respond(content)
Esempio n. 4
0
    def handle_hello_update(self, request: HttpRequest) -> None:
        if request.method != "post":
            raise MethodNotAllowed

        form_data = self.get_form_data()
        new_user = User.build(form_data)

        response_kwargs = {}
        session = request.session
        if not session:
            session = generate_new_session()
            response_kwargs["session"] = session

        if new_user.errors:
            saved_data = load_profile(session)
            saved_user = User.build(saved_data)
            html = self.render_hello_page(request, new_user, saved_user)
            self.respond(html, **response_kwargs)
        else:
            store_profile(session, form_data)
            self.redirect("/hello", **response_kwargs)