<commit_before># -*- coding: utf-8 -*-

import os.path

from ..internal.OCR import OCR

try:
    import adecaptcha.clslib as clslib
except ImportError:
    pass


class UlozTo(OCR):
    __name__ = "UlozTo"
    __type__ = "captcha"
    __version__ = "0.04"
    __status__ = "testing"

    __description__ = """UlozTo audio captcha service plugin"""
    __license__ = "GPLv3"
    __authors__ = [("sodd", None),
                   ("GammaC0de", "<EMAIL>[AT]yahoo[DOT]com")]

    def recognize(self, audio):
        """ Audio decoding - more info could be found at https://launchpad.net/adecaptcha """
        # print("!!!CAPTCHA :", audio)
        try:
            cfg_file = os.path.join(
                os.path.split(
                    clslib.__file__)[0],
                'ulozto.cfg')
            text = clslib.classify_audio_file(audio, cfg_file)
            return text

        except NameError:
            self.log_error(_("Unable to decode audio captcha"),
                           _("Please install adecaptcha library from https://github.com/izderadicka/adecaptcha"))<commit_msg>[Captcha] Ulozto - fix audio recognition (#3172)<commit_after># -*- coding: utf-8 -*-

import os.path

from ..internal.OCR import OCR

try:
    import adecaptcha.clslib as clslib
except ImportError:
    pass


class UlozTo(OCR):
    __name__ = "UlozTo"
    __type__ = "captcha"
    __version__ = "0.05"
    __status__ = "testing"

    __description__ = """UlozTo audio captcha service plugin"""
    __license__ = "GPLv3"
    __authors__ = [("sodd", None),
                   ("GammaC0de", "nit<EMAIL>1[AT]yahoo[DOT]com")]

    def recognize(self, audio):
        """ Audio decoding - more info could be found at https://launchpad.net/adecaptcha """
        # print("!!!CAPTCHA :", audio)
        try:
            cfg_file = os.path.join(
                os.path.split(
                    clslib.__file__)[0],
                'ulozto.cfg')
            ext_file = os.path.splitext(audio)[1]
            text = clslib.classify_audio_file(audio, cfg_file, ext_file)
            return text

        except NameError:
            self.log_error(_("Unable to decode audio captcha"),
                           _("Please install adecaptcha library from https://github.com/izderadicka/adecaptcha"))
{'fraction_non_alphanumeric': 0.12352168199737187, 'fraction_numerical': 0.008760402978537012, 'mean_word_length': 2.1634349030470914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4206296', 'n_tokens_mistral': 758, 'n_tokens_neox': 717, 'n_words': 163}