<commit_before>package danubis.derrick.library;

import android.content.Context;

import danubis.derrick.library.Ear.CnEar;
import danubis.derrick.library.Ear.Ear;
import danubis.derrick.library.Ear.EarListener;
import danubis.derrick.library.Ear.EnEar;
import danubis.derrick.library.Mouth.CnMouth;
import danubis.derrick.library.Mouth.EnMouth;
import danubis.derrick.library.Mouth.Mouth;
import danubis.derrick.library.Mouth.MouthListener;


public class Avatar implements MouthListener, EarListener {

    public static final String ZH_CN = "zhCN";
    public static final String EN = "en";

    public static final String SPEAK_TIME = "time";
    public static final String SPEAK_DATE = "date";


    private Context context;
    private Body body;
    private Ear ear;
    private Mouth mouth;
    private AvatarListener listener;

    private String lastSpokeText;


    private Avatar(Context context,
                   String appId,
                   String language,
                   Body body,
                   AvatarListener listener) {

        this.context = context;
        this.body = body;
        this.listener = listener;

        switch (language) {
            case ZH_CN:
                ear = new CnEar(context, appId);
                mouth = new CnMouth(context);
                break;
            case EN:
                ear = new EnEar(context, appId);
                mouth = new EnMouth(context);
                break;
        }
        ear.setListener(this);
        mouth.setListener(this);
    }


    public static class Builder {

        private Context context;
        private String xfAppId;
        private String language;
        private Body body;
        private AvatarListener listener;

        public Builder context(Context context) {
            this.context = context;
            return this;
        }

        public Builder xfAppId(String appid) {
            this.xfAppId = appid;
            return this;
        }

        public Builder language(String language) {
            this.language = language;
            return this;
        }

        public Builder body(Body body) {
            this.body = body;
            return this;
        }

        public Builder listener(AvatarListener listener) {
            this.listener = listener;
            return this;
        }

        public Avatar build() {
            return new Avatar(context, xfAppId, language, body, listener);
        }
    }


    public void speak(String textToSpeak) {
        lastSpokeText = textToSpeak;
        stopListening();
        mouth.speak(textToSpeak);
    }


    public void speakTime() {
        mouth.speakTime();
    }


    public void speakDate() {
        mouth.speakDate();
    }


    public void stopSpeaking() {
        mouth.stopSpeaking();
    }


    public String getLastSpokeText() {
        return lastSpokeText;
    }


    public void listen() {
        stopSpeaking();
        body.doWaitingAction();
        ear.listen();
    }


    public void stopListening() {
        ear.stopListening();
    }


    public void pause() {
        body.pause();
        stopSpeaking();
        stopListening();
    }


    public void resume() {
        body.resume();
    }


    public void destroy() {
        body.destroy();
        ear.destroy();
        mouth.destroy();
    }


    @Override
    public void onSpeakStarted(String speakingText) {
        body.doSpeakingAction();
        listener.onSpeakStarted(speakingText);
    }


    @Override
    public void onSpeakEnded() {
        body.doWaitingAction();
        listener.onSpeakEnded();
    }


    @Override
    public void onListenResult(String result) {
        listener.onListenResult(result);
    }
}<commit_msg>updated library to work without body.<commit_after>package danubis.derrick.library;

import android.content.Context;

import danubis.derrick.library.Ear.CnEar;
import danubis.derrick.library.Ear.Ear;
import danubis.derrick.library.Ear.EarListener;
import danubis.derrick.library.Ear.EnEar;
import danubis.derrick.library.Mouth.CnMouth;
import danubis.derrick.library.Mouth.EnMouth;
import danubis.derrick.library.Mouth.Mouth;
import danubis.derrick.library.Mouth.MouthListener;


public class Avatar implements MouthListener, EarListener {

    public static final String ZH_CN = "zhCN";
    public static final String EN = "en";

    public static final String SPEAK_TIME = "time";
    public static final String SPEAK_DATE = "date";


    private Context context;
    private Body body;
    private Ear ear;
    private Mouth mouth;
    private AvatarListener listener;

    private String lastSpokeText;


    private Avatar(Context context,
                   String appId,
                   String language,
                   Body body,
                   AvatarListener listener) {

        this.context = context;
        this.body = body;
        this.listener = listener;

        switch (language) {
            case ZH_CN:
                ear = new CnEar(context, appId);
                mouth = new CnMouth(context);
                break;
            case EN:
                ear = new EnEar(context, appId);
                mouth = new EnMouth(context);
                break;
        }
        ear.setListener(this);
        mouth.setListener(this);
    }


    public static class Builder {

        private Context context;
        private String xfAppId;
        private String language;
        private Body body;
        private AvatarListener listener;

        public Builder context(Context context) {
            this.context = context;
            return this;
        }

        public Builder xfAppId(String appid) {
            this.xfAppId = appid;
            return this;
        }

        public Builder language(String language) {
            this.language = language;
            return this;
        }

        public Builder body(Body body) {
            this.body = body;
            return this;
        }

        public Builder listener(AvatarListener listener) {
            this.listener = listener;
            return this;
        }

        public Avatar build() {
            return new Avatar(context, xfAppId, language, body, listener);
        }
    }


    public void speak(String textToSpeak) {
        lastSpokeText = textToSpeak;
        stopListening();
        mouth.speak(textToSpeak);
    }


    public void speakTime() {
        mouth.speakTime();
    }


    public void speakDate() {
        mouth.speakDate();
    }


    public void stopSpeaking() {
        mouth.stopSpeaking();
    }


    public String getLastSpokeText() {
        return lastSpokeText;
    }


    public void listen() {
        stopSpeaking();
        ear.listen();
        if (body != null) {
            body.doWaitingAction();
        }
    }


    public void stopListening() {
        ear.stopListening();
    }


    public void pause() {
        stopSpeaking();
        stopListening();
        if (body != null) {
            body.pause();
        }
    }


    public void resume() {
        if (body != null) {
            body.resume();
        }
    }


    public void destroy() {
        ear.destroy();
        mouth.destroy();
        if (body != null) {
            body.destroy();
        }
    }


    @Override
    public void onSpeakStarted(String speakingText) {
        listener.onSpeakStarted(speakingText);
        if (body != null) {
            body.doSpeakingAction();
        }
    }


    @Override
    public void onSpeakEnded() {
        listener.onSpeakEnded();
        if (body != null) {
            body.doWaitingAction();
        }
    }


    @Override
    public void onListenResult(String result) {
        listener.onListenResult(result);
    }
}
{'fraction_non_alphanumeric': 0.0873424234628248, 'fraction_numerical': 0.0, 'mean_word_length': 1.8200943054044252, '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': '6745961', 'n_tokens_mistral': 2258, 'n_tokens_neox': 2102, 'n_words': 519}