<commit_before>package cz.msebera.captcha;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.urbandroid.sleep.captcha.CaptchaSupport;
import com.urbandroid.sleep.captcha.CaptchaSupportFactory;
import com.urbandroid.sleep.captcha.RemainingTimeListener;

import java.util.List;

public final class CaptchaActivity extends Activity {

    private CaptchaSupport captchaSupport;
    private Toast currentToast;
    private SpeechRecognizer speech;
    private final Handler handler = new Handler();
    private int currentOrientation = -1;
    private int difficultyCoefficient = 20;
    private int count = 0;
    private boolean recognitionStarted = false;
    private ProgressBar voiceLevel;
    private TextView score, scoreLabel;
    public static final String TAG = "F*ckaptcha";

    private final RemainingTimeListener remainingTimeListener = new RemainingTimeListener() {
        @Override
        public void timeRemain(int seconds, int aliveTimeout) {
            if (currentToast != null) {
                currentToast.cancel();
            }
            currentToast = Toast.makeText(CaptchaActivity.this, getString(R.string.timeout_toast, seconds, aliveTimeout), Toast.LENGTH_LONG);
            currentToast.show();
        }
    };

    private final RecognitionListener recognitionListener = new RecognitionListener() {
        @Override
        public void onReadyForSpeech(Bundle params) {
            Log.d(TAG, "onReadyForSpeech");
        }

        @Override
        public void onBeginningOfSpeech() {
            Log.d(TAG, "onBeginningOfSpeech");
        }

        @Override
        public void onRmsChanged(float rmsdB) {
            voiceLevel.setProgress((int) ((rmsdB + 120) / 1.8));
        }

        @Override
        public void onBufferReceived(byte[] buffer) {
            Log.d(TAG, "onBufferReceived");
        }

        @Override
        public void onEndOfSpeech() {
            Log.d(TAG, "onEndOfSpeech");
            startVoiceRecognition();
        }

        @Override
        public void onError(int error) {
            Log.d(TAG, String.format("onError %d", error));<commit_msg>Fixed restarting voice recognition<commit_after>package cz.msebera.captcha;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.urbandroid.sleep.captcha.CaptchaSupport;
import com.urbandroid.sleep.captcha.CaptchaSupportFactory;
import com.urbandroid.sleep.captcha.RemainingTimeListener;

import java.util.List;

public final class CaptchaActivity extends Activity {

    private CaptchaSupport captchaSupport;
    private Toast currentToast;
    private SpeechRecognizer speech;
    private final Handler handler = new Handler();
    private int currentOrientation = -1;
    private int difficultyCoefficient = 20;
    private int count = 0;
    private boolean recognitionStarted = false;
    private ProgressBar voiceLevel;
    private TextView score, scoreLabel;
    public static final String TAG = "F*ckaptcha";

    private final RemainingTimeListener remainingTimeListener = new RemainingTimeListener() {
        @Override
        public void timeRemain(int seconds, int aliveTimeout) {
            if (currentToast != null) {
                currentToast.cancel();
            }
            currentToast = Toast.makeText(CaptchaActivity.this, getString(R.string.timeout_toast, seconds, aliveTimeout), Toast.LENGTH_LONG);
            currentToast.show();
        }
    };

    private final RecognitionListener recognitionListener = new RecognitionListener() {
        @Override
        public void onReadyForSpeech(Bundle params) {
            Log.d(TAG, "onReadyForSpeech");
        }

        @Override
        public void onBeginningOfSpeech() {
            Log.d(TAG, "onBeginningOfSpeech");
        }

        @Override
        public void onRmsChanged(float rmsdB) {
            voiceLevel.setProgress((int) ((rmsdB + 120) / 1.8));
        }

        @Override
        public void onBufferReceived(byte[] buffer) {
            Log.d(TAG, "onBufferReceived");
        }

        @Override
        public void onEndOfSpeech() {
            Log.d(TAG, "onEndOfSpeech");
            startVoiceRecognition();
        }

        @Override
        public void onError(int error) {
            Log.d(TAG, String.format("onError %d", error));
            recognitionStarted = false;
{'fraction_non_alphanumeric': 0.08754600038737169, 'fraction_numerical': 0.003486345148169669, 'mean_word_length': 3.024941543257989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3399026', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1369, 'n_words': 330}