"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const speech_1 = require("../../../../../api/speech");
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class SpeechToText extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['opt'],
            fo: [],
            i: ['stop'],
            o: ['text'],
        }, {}, system, _ids_1.ID_SPEECH_TO_TEXT);
        this._recorder = null;
    }
    f({ opt }, done) {
        const recorder = new speech_1.SpeechRecorder(this.__system, opt);
        this._recorder = recorder;
        this._recorder.start();
        this._recorder.addListener('transcript', (text) => {
            this._output.text.push(text);
        });
        this._recorder.addListener('err', (err) => {
            done(undefined, err);
        });
        this._recorder.addListener('end', () => {
            this._recorder = null;
            done();
        });
    }
    onIterDataInputData(name, data) {
        // if (name === 'stop') {
        this._recorder.stop();
        // }
    }
}
exports.default = SpeechToText;
//# sourceMappingURL=index.js.map