ibmtjbot / tjbot

IBM TJBot
https://ibmtjbot.github.io
Apache License 2.0
481 stars 282 forks source link

TJBot freezes after Sudo Node Conversation.js, followed by huge error message #137

Closed zacaintmyname closed 4 years ago

zacaintmyname commented 5 years ago

Hi team,

My credentials are updated, my speaker plays music as well. But now I just cant seem to get the last command to work! Experiencing the same issue for conversation.js and stt.js.

pi@DoctorBroccoliJunior:~/tjbot/recipes/conversation $ sudo node conversation.jsverbose: TJBot initializing microphone verbose: TJBot initializing LED verbose: TJBot initializing servo motor on PIN 7 verbose: TJBot initializing assistant service verbose: TJBot initializing speech_to_text service verbose: TJBot initializing text_to_speech service verbose: TJBot initializing visual_recognition service info: Hello from TJBot! My name is Watson. verbose: TJBot library version v1.5.1 You can ask me to introduce myself or tell you a joke. Try saying, "Watson, please introduce yourself" or "Watson, what can you do?" You can also say, "Watson, tell me a joke!" verbose: TJBot initializing microphone error: the speech_to_text service returned an error. message=Session timed out., stack=Error: Session timed out. at emitError (/home/pi/tjbot/recipes/conversation/node_modules/watson-developer-cloud/lib/recognize-stream.js:247:23) at W3CWebSocket.socket.onmessage (/home/pi/tjbot/recipes/conversation/node_modules/watson-developer-cloud/lib/recognize-stream.js:272:17) at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/pi/tjbot/recipes/conversation/node_modules/yaeti/lib/EventTarget.js:107:17) at W3CWebSocket.onMessage (/home/pi/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:234:14) at WebSocketConnection. (/home/pi/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:205:19) at WebSocketConnection.emit (events.js:180:13) at WebSocketConnection.processFrame (/home/pi/tjbot/recipes/conversation/node_modules/websocket/lib/WebSocketConnection.js:554:26) at /home/pi/tjbot/recipes/conversation/node_modules/websocket/lib/WebSocketConnection.js:323:40 at process._tickCallback (internal/process/next_tick.js:176:11), type=message, isTrusted=false, _yaeti=true, data={ "error": "Session timed out." }, , addEventListener=function _addEventListener(type, newListener) { var listenersType, i, listener;

if (!type || !newListener) {
    return;
}

listenersType = this._listeners[type];
if (listenersType === undefined) {
    this._listeners[type] = listenersType = [];
}

for (i = 0; !!(listener = listenersType[i]); i++) {
    if (listener === newListener) {
        return;
    }
}

listenersType.push(newListener);

}, removeEventListener=function _removeEventListener(type, oldListener) { var listenersType, i, listener;

if (!type || !oldListener) {
    return;
}

listenersType = this._listeners[type];
if (listenersType === undefined) {
    return;
}

for (i = 0; !!(listener = listenersType[i]); i++) {
    if (listener === oldListener) {
        listenersType.splice(i, 1);
        break;
    }
}

if (listenersType.length === 0) {
    delete this._listeners[type];
}

}, dispatchEvent=function _dispatchEvent(event) { var type, listenersType, dummyListener, stopImmediatePropagation = false, i, listener;

if (!event || typeof event.type !== 'string') {
    throw new Error('`event` must have a valid `type` property');
}

// Do some stuff to emulate DOM Event behavior (just if this is not a
// DOM Event object)
if (event._yaeti) {
    event.target = this;
    event.cancelable = true;
}

// Attempt to override the stopImmediatePropagation() method
try {
    event.stopImmediatePropagation = function () {
        stopImmediatePropagation = true;
    };
} catch (error) {}

type = event.type;
listenersType = (this._listeners[type] || []);

dummyListener = this['on' + type];
if (typeof dummyListener === 'function') {
    dummyListener.call(this, event);
}

for (i = 0; !!(listener = listenersType[i]); i++) {
    if (stopImmediatePropagation) {
        break;
    }

    listener.call(this, event);
}

return !event.defaultPrevented;

}, _url=wss://gateway-syd.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_BroadbandModel, _readyState=1, _protocol=undefined, _extensions=[], _bufferedAmount=0, _binaryType=arraybuffer, _debug=function debug() { // disabled? if (!debug.enabled) return;

var self = debug;

// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;

// turn the `arguments` into a proper Array
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
  args[i] = arguments[i];
}

args[0] = exports.coerce(args[0]);

if ('string' !== typeof args[0]) {
  // anything else let's inspect with %O
  args.unshift('%O');
}

// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  // if we encounter an escaped % then don't increase the array index
  if (match === '%%') return match;
  index++;
  var formatter = exports.formatters[format];
  if ('function' === typeof formatter) {
    var val = args[index];
    match = formatter.call(self, val);

    // now we need to remove `args[index]` since it's inlined in the `format`
    args.splice(index, 1);
    index--;
  }
  return match;
});

// apply env-specific formatting (colors, etc.)
exports.formatArgs.call(self, args);

var logFn = debug.log || exports.log || console.log.bind(console);
logFn.apply(self, args);

}, newListener=function (ev) { if (ev === 'ping'){ this._pingListenerCount++; } }, removeListener=function (ev) { if (ev === 'ping') { this._pingListenerCount--; } }, close=function (code, reason) { onClose.call(self, code, reason); }, message=function (msg) { onMessage.call(self, msg); }, _eventsCount=4, _maxListeners=undefined, _pingListenerCount=0, maxReceivedFrameSize=1048576, maxReceivedMessageSize=8388608, fragmentOutgoingMessages=true, fragmentationThreshold=16384, webSocketVersion=13, assembleFragments=true, disableNagleAlgorithm=true, closeTimeout=5000, rejectUnauthorized=true, pipe=false, , singleUse=true, isServer=false, requestCert=true, rejectUnauthorized=true, session=undefined, NPNProtocols=undefined, ALPNProtocols=undefined, requestOCSP=undefined, _secureEstablished=true, _securePending=false, _newSessionPending=false, _controlReleased=true, _SNICallback=null, servername=gateway-syd.watsonplatform.net, npnProtocol=false, alpnProtocol=false, authorized=true, authorizationError=null, encrypted=true, close=[function onSocketCloseDestroySSL() { // Make sure we are not doing it on OpenSSL's stack setImmediate(destroySSL, this); this[kRes] = null; }, function () { [native code] }, function () { [native code] }], finish=function onSocketFinish() { // If still connecting - defer handling 'finish' until 'connect' will happen if (this.connecting) { debug('osF: not yet connected'); return this.once('connect', onSocketFinish); }

debug('onSocketFinish'); if (!this.readable || this._readableState.ended) { debug('oSF: ended, destroy', this._readableState); return this.destroy(); }

debug('oSF: not ended, call shutdown()');

// otherwise, just shutdown, or destroy() if not possible if (!this._handle || !this._handle.shutdown) return this.destroy();

var err = defaultTriggerAsyncIdScope( this[async_id_symbol], shutdownSocket, this, afterShutdown );

if (err) return this.destroy(errnoException(err, 'shutdown')); }, end=[function onReadableStreamEnd() { maybeDestroy(this); }, function () { [native code] }], secure=function onConnectSecure() { const options = this[kConnectOptions];

// Check the size of DHE parameter above minimum requirement // specified in options. const ekeyinfo = this.getEphemeralKeyInfo(); if (ekeyinfo.type === 'DH' && ekeyinfo.size < options.minDHSize) { const err = new errors.Error('ERR_TLS_DH_PARAM_SIZE', ekeyinfo.size); this.emit('error', err); this.destroy(); return; }

let verifyError = this._handle.verifyError();

// Verify that server's identity matches it's certificate's names // Unless server has resumed our existing session if (!verifyError && !this.isSessionReused()) { const hostname = options.servername || options.host || (options.socket && options.socket._host) || 'localhost'; const cert = this.getPeerCertificate(true); verifyError = options.checkServerIdentity(hostname, cert); }

if (verifyError) { this.authorized = false; this.authorizationError = verifyError.code || verifyError.message;

if (options.rejectUnauthorized) {
  this.destroy(verifyError);
  return;
} else {
  this.emit('secureConnect');
}

} else { this.authorized = true; this.emit('secureConnect'); }

// Uncork incoming data this.removeListener('end', onConnectEnd); }, error=function () { [native code] }, drain=function () { [native code] }, pause=function () { [native code] }, resume=function () { [native code] }, data=function () { [native code] }, _eventsCount=9, connecting=false, _hadError=false, reading=true, $ref=$["raw"]["target"]["_connection"]["socket"], onread=null, onconnection=null, _parentWrap=undefined, $ref=$["raw"]["target"]["_connection"]["socket"]["_tlsOptions"]["secureContext"], reading=true, $ref=$["raw"]["target"]["_connection"]["socket"], onread=function onread(nread, buffer) { var handle = this; var self = handle.owner; assert(handle === self._handle, 'handle != self._handle');

self._unrefTimer();

debug('onread', nread);

if (nread > 0) { debug('got data');

// read success.
// In theory (and in practice) calling readStop right now
// will prevent this from being called again until _read() gets
// called again.

// Optimization: emit the original buffer with end points
var ret = self.push(buffer);

if (handle.reading && !ret) {
  handle.reading = false;
  debug('readStop');
  var err = handle.readStop();
  if (err)
    self.destroy(errnoException(err, 'read'));
}
return;

}

// if we didn't get any bytes, that doesn't necessarily mean EOF. // wait for the next one. if (nread === 0) { debug('not any data, keep waiting'); return; }

// Error, possibly EOF. if (nread !== UV_EOF) { return self.destroy(errnoException(nread, 'read')); }

debug('EOF');

// push a null to signal the end of data. // Do it before maybeDestroy for correct order of events: // end -> close self.push(null); self.read(0);

if (!self.allowHalfOpen) { self.write = writeAfterFIN; self.destroySoon(); }

// internal end event so that we know that the actual socket // is no longer readable, and we can start the shutdown // procedure. No need to wait for all the data to be consumed. self.emit('_socketEnd'); }, onhandshakestart=() => {}, onhandshakedone=function () { [native code] }, onocspresponse=function onocspresponse(resp) { this.owner.emit('OCSPResponse', resp); }, onerror=function onerror(err) { const owner = this.owner;

if (owner._writableState.errorEmitted) return;

// Destroy socket if error happened before handshake's finish if (!owner._secureEstablished) { // When handshake fails control is not yet released, // so self._tlsError will return null instead of actual error owner.destroy(err); } else if (owner._tlsOptions.isServer && owner._rejectUnauthorized && /peer did not return a certificate/.test(err.message)) { // Ignore server's authorization errors owner.destroy(); } else { // Throw error owner._emitTLSError(err); }

owner._writableState.errorEmitted = true; }, _parent=null, _host=gateway-syd.watsonplatform.net, objectMode=false, highWaterMark=16384, head=null, tail=null, length=0, length=0, pipes=null, pipesCount=0, flowing=true, ended=false, endEmitted=false, reading=true, sync=false, needReadable=true, emittedReadable=false, readableListening=false, resumeScheduled=false, destroyed=false, defaultEncoding=utf8, awaitDrain=0, readingMore=true, decoder=null, encoding=null, readable=true, _maxListeners=undefined, objectMode=false, highWaterMark=16384, finalCalled=false, needDrain=false, ending=false, ended=false, finished=false, destroyed=false, decodeStrings=false, defaultEncoding=utf8, length=0, writing=false, corked=0, sync=false, bufferProcessing=false, onwrite=function () { [native code] }, writecb=null, writelen=0, bufferedRequest=null, lastBufferedRequest=null, pendingcb=0, prefinished=false, errorEmitted=false, bufferedRequestCount=0, next=null, entry=null, finish=function () { [native code] }, entry=null, finish=function () { [native code] }, writable=true, _bytesDispatched=6268995, _sockname=null, _pendingData=null, _pendingEncoding=, allowHalfOpen=false, server=undefined, _server=null, $ref=$["raw"]["target"]["_connection"]["socket"]["_handle"], _requestCert=true, _rejectUnauthorized=true, parser=null, _httpMessage=null, address=23.74.234.6, family=IPv4, port=443, _idleNext=null, _idlePrev=null, _idleTimeout=-1, protocol=undefined, $ref=$["raw"]["target"]["_extensions"], remoteAddress=23.74.234.6, closeReasonCode=-1, closeDescription=null, closeEventEmitted=false, maskOutgoingPackets=true, 0=178, 1=8, 2=12, 3=186, 0=129, 1=36, 2=184, 3=2, 4=232, 5=201, 6=184, 7=2, 8=112, 9=204, , _eventsCount=0, _maxListeners=undefined, encoding=undefined, length=0, write=function (buf) { if (!head.buffer) { head.buffer = buf; last = head; } else { last.next = { next : null, buffer : buf }; last = last.next; } length += buf.length; self.emit('write', buf); return true; }, end=function (buf) { if (Buffer.isBuffer(buf)) self.write(buf); }, push=function () { var args = [].concat.apply([], arguments); args.forEach(self.write); return self; }, forEach=function (fn) { if (!head.buffer) return bufferAllocUnsafe(0);

    if (head.buffer.length - offset <= 0) return self;
    var firstBuf = head.buffer.slice(offset);

    var b = { buffer : firstBuf, next : head.next };

    while (b && b.buffer) {
        var r = fn(b.buffer);
        if (r) break;
        b = b.next;
    }

    return self;
}, join=function (start, end) {
    if (!head.buffer) return bufferAllocUnsafe(0);
    if (start == undefined) start = 0;
    if (end == undefined) end = self.length;

    var big = bufferAllocUnsafe(end - start);
    var ix = 0;
    self.forEach(function (buffer) {
        if (start < (ix + buffer.length) && ix < end) {
            // at least partially contained in the range
            buffer.copy(
                big,
                Math.max(0, ix - start),
                Math.max(0, start - ix),
                Math.min(buffer.length, end - ix)
            );
        }
        ix += buffer.length;
        if (ix > end) return true; // stop processing past end
    });

    return big;
}, joinInto=function (targetBuffer, targetStart, sourceStart, sourceEnd) {
    if (!head.buffer) return new bufferAllocUnsafe(0);
    if (sourceStart == undefined) sourceStart = 0;
    if (sourceEnd == undefined) sourceEnd = self.length;

    var big = targetBuffer;
    if (big.length - targetStart < sourceEnd - sourceStart) {
        throw new Error("Insufficient space available in target Buffer.");
    }
    var ix = 0;
    self.forEach(function (buffer) {
        if (sourceStart < (ix + buffer.length) && ix < sourceEnd) {
            // at least partially contained in the range
            buffer.copy(
                big,
                Math.max(targetStart, targetStart + ix - sourceStart),
                Math.max(0, sourceStart - ix),
                Math.min(buffer.length, sourceEnd - ix)
            );
        }
        ix += buffer.length;
        if (ix > sourceEnd) return true; // stop processing past end
    });

    return big;
}, advance=function (n) {
    offset += n;
    length -= n;
    while (head.buffer && offset >= head.buffer.length) {
        offset -= head.buffer.length;
        head = head.next
            ? head.next
            : { buffer : null, next : null }
        ;
    }
    if (head.buffer === null) last = { next : null, buffer : null };
    self.emit('advance', n);
    return self;
}, take=function (n, encoding) {
    if (n == undefined) n = self.length;
    else if (typeof n !== 'number') {
        encoding = n;
        n = self.length;
    }
    var b = head;
    if (!encoding) encoding = self.encoding;
    if (encoding) {
        var acc = '';
        self.forEach(function (buffer) {
            if (n <= 0) return true;
            acc += buffer.toString(
                encoding, 0, Math.min(n,buffer.length)
            );
            n -= buffer.length;
        });
        return acc;
    } else {
        // If no 'encoding' is specified, then return a Buffer.
        return self.join(0, n);
    }
}, toString=function () {
    return self.take('binary');
}, $ref=$["raw"]["target"]["_connection"]["maskBytes"], $ref=$["raw"]["target"]["_connection"]["frameHeader"], $ref=$["raw"]["target"]["_connection"]["config"], maxReceivedFrameSize=1048576, protocolError=false, frameTooLarge=false, invalidCloseFrameLength=false, parseState=1, closeStatus=-1, fragmentationSize=0, frameQueue=[], connected=true, state=open, waitingForCloseResponse=false, receivedEnd=false, closeTimeout=5000, assembleFragments=true, maxReceivedMessageSize=8388608, outputBufferFull=false, inputPaused=false, receivedDataHandler=function () { [native code] }, _closeTimerHandler=function () { [native code] }, webSocketVersion=13, connect=function (connection) {
    onConnect.call(self, connection);
}, connectFailed=function () {
    onConnectFailed.call(self);
}, _eventsCount=2, _maxListeners=undefined, $ref=$["raw"]["target"]["_connection"]["config"], _req=null, protocols=[], origin=null, protocol=wss:, slashes=true, auth=null, host=gateway-syd.watsonplatform.net, port=443, hostname=gateway-syd.watsonplatform.net, hash=null, search=?model=en-US_BroadbandModel, query=model=en-US_BroadbandModel, pathname=/speech-to-text/api/v1/recognize, path=/speech-to-text/api/v1/recognize?model=en-US_BroadbandModel, href=wss://gateway-syd.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_BroadbandModel, secure=true, base64nonce=kDo6nuIoFQ9rjZfKZg/b6Q==, $ref=$["raw"]["target"]["_connection"]["socket"], objectMode=false, highWaterMark=16384, head=null, tail=null, length=0, length=0, pipes=null, pipesCount=0, flowing=null, ended=true, endEmitted=false, reading=false, sync=true, needReadable=false, emittedReadable=true, readableListening=false, resumeScheduled=false, destroyed=false, defaultEncoding=utf8, awaitDrain=0, readingMore=true, decoder=null, encoding=null, readable=true, , _eventsCount=0, _maxListeners=undefined, $ref=$["raw"]["target"]["_connection"]["socket"], $ref=$["raw"]["target"]["_connection"]["socket"], httpVersionMajor=1, httpVersionMinor=1, httpVersion=1.1, complete=true, content-type=application/octet-stream, sec-websocket-accept=g6E/eXl9mUC0shYnvrN8SSWfSnA=, x-global-transaction-id=3599eb03f63737f005bdb603ebc9198b, x-dp-watson-tran-id=3599eb03f63737f005bdb603ebc9198b, date=Tue, 09 Apr 2019 04:13:24 GMT, upgrade=websocket, connection=Upgrade, rawHeaders=[Content-Type, application/octet-stream, Sec-Websocket-Accept, g6E/eXl9mUC0shYnvrN8SSWfSnA=, x-global-transaction-id, 3599eb03f63737f005bdb603ebc9198b, X-DP-Watson-Tran-ID, 3599eb03f63737f005bdb603ebc9198b, Date, Tue, 09 Apr 2019 04:13:24 GMT, Upgrade, websocket, Connection, Upgrade], , rawTrailers=[], upgrade=true, url=, method=null, statusCode=101, statusMessage=Switching Protocols, $ref=$["raw"]["target"]["_connection"]["socket"], _consuming=false, _dumped=false, firstDataChunk=null, onerror=function (event) {
        self.listening = false;
        var err = new Error('WebSocket connection error');
        err.name = RecognizeStream.WEBSOCKET_CONNECTION_ERROR;
        err['event'] = event;
        self.emit('error', err);
        self.push(null);
    }, onopen=function () {
        self.sendJSON(openingMessage);
        /**
         * emitted once the WebSocket connection has been established
         * @event RecognizeStream#open
         */
        self.emit('open');
    }, onclose=function (e) {
        self.listening = false;
        self.push(null);
        /**
         * @event RecognizeStream#close
         * @param {Number} reasonCode
         * @param {String} description
         */
        self.emit('close', e.code, e.reason);
    }, onmessage=function (frame) {
        if (typeof frame.data !== 'string') {
            return emitError('Unexpected binary data received from server', frame);
        }
        var data;
        try {
            data = JSON.parse(frame.data);
        }
        catch (jsonEx) {
            return emitError('Invalid JSON received from service:', frame, jsonEx);
        }
        /**
         * Emit any messages received over the wire, mainly used for debugging.
         *
         * @event RecognizeStream#message
         * @param {Object} message - frame object with a data attribute that's either a string or a Buffer/TypedArray
         * @param {Object} [data] - parsed JSON object (if possible);
         */
        self.emit('message', frame, data);
        if (data.error) {
            emitError(data.error, frame);
        }
        else if (data.state === 'listening') {
            // this is emitted both when the server is ready for audio, and after we send the close message to indicate that it's done processing
            if (self.listening) {
                self.listening = false;
                socket.close();
            }
            else {
                self.listening = true;
                /**
                 * Emitted when the Watson Service indicates readiness to transcribe audio. Any audio sent before this point will be buffered until now.
                 * @event RecognizeStream#listening
                 */
                self.emit('listening');
            }
        }
        else {
            if (options.readableObjectMode) {
                /**
                 * Object with interim or final results, possibly including confidence scores, alternatives, and word timing.
                 * @event RecognizeStream#data
                 * @param {Object} data
                 */
                self.push(data);
            }
            else if (Array.isArray(data.results)) {
                data.results.forEach(function (result) {
                    if (result.final && result.alternatives) {
                        /**
                         * Finalized text
                         * @event RecognizeStream#data
                         * @param {String} transcript
                         */
                        self.push(result.alternatives[0].transcript, 'utf8');
                    }
                });
            }
        }
    }, cancelable=true, stopImmediatePropagation=function () {
        stopImmediatePropagation = true;
    }

verbose: TJBot initializing microphone ^Z2019-04-09 12:14:02 sigHandler: Unhandled signal 20, terminating

jweisz commented 5 years ago

error: the speech_to_text service returned an error. message=Session timed out., stack=Error: Session timed out.

Looks like the connection with Watson Speech to Text timed out. This can happen when the microphone is silent for long periods of time.

Try adding inactivityTimeout: -1 to your tjbot config in the config.js file:

exports.tjConfig = {
    log: {
        level: 'verbose'
    },
    listen: {
        inactivityTimeout: -1
    }
};

Technical details here: https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-input#timeouts

andycitron commented 5 years ago

I reported this issue last year. I'm still having it when speaking long messages. Setting the listen inactivityTimeout to -1 did not help. In particular it is fatal when the exception occurs while tjbot is trying to speak. Here are some relevant messages from my debug log: info: TJBot heard: tell me a joke about computers callback from tj.listen ... my code then starts telling a very long joke, not one of the canned jokes.
verbose: TJBot speaking with voice en-US_MichaelV2Voice debug: wrote audio stream to temp file /tmp/tjbot119320-2555-1edluiu.5dh0ejyvi verbose: TJBot speaking: .... followed by...

debug: listening paused debug: microphone paused debug: Playing audio with parameters: filename=/tmp/tjbot119320-2555-1edluiu.5dh0ejyvi, gain=100, debug=true, player=aplay, device=plughw:0,0 ========= { filename: '/tmp/tjbot119320-2555-1edluiu.5dh0ejyvi', gain: 100, debug: true, player: 'aplay', device: 'plughw:0,0' } error: the speech_to_text service returned an error. message=Session timed out., stack=Error: Session timed out. at emitError (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/watson-developer-cloud/lib/recognize-stream.js:232:23) at W3CWebSocket.socket.onmessage (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/watson-developer-cloud/lib/recognize-stream.js:257:17) at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/yaeti/lib/EventTarget.js:107:17) at W3CWebSocket.onMessage (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:234:14) at WebSocketConnection. (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:205:19) at emitOne (events.js:96:13) at WebSocketConnection.emit (events.js:188:7) .... and a long stack trace.

Why is tjbot listening at all at that point? 1) its already processing a 'return' from listening 2) its speaking and listening is paused and the mic is paused.

With all that said, if it would recover from the exception and start listening again after speaking, all would be well. After the stack trace this is in the log: debug: listening stopped verbose: TJBot initializing microphone debug: microphone deviceID set plughw:1,0 WARNING: createRecognizeStream() was renamed to recognizeUsingWebSocket(). Support for createRecognizeStream() will be removed in the next major release debug: microphone started debug: audio playback finished debug: listening resumed

However, tjbot no longer responds to verbal commands. It does not appear to be listening.

I'm not sure how to debug further.

andycitron commented 5 years ago

Actually, I see now that my listen inactivity timeout setting didn't get picked up properly. But now I did set it correctly (I think). But it made things worse. Upon the first attempt to listen I get this:
verbose: TJBot initializing microphone WARNING: createRecognizeStream() was renamed to recognizeUsingWebSocket(). Support for createRecognizeStream() will be removed in the next major release debug: microphone started error: the speech_to_text service returned an error. message=WebSocket connection error, stack=WebSocket connection error: WebSocket connection error at W3CWebSocket.socket.onerror (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/watson-developer-cloud/lib/recognize-stream.js:197:23) at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/yaeti/lib/EventTarget.js:107:17) at W3CWebSocket.onConnectFailed (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:217:14) at WebSocketClient. (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/W3CWebSocket.js:59:25) at emitOne (events.js:96:13) at WebSocketClient.emit (events.js:188:7) at WebSocketClient.failHandshake (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/WebSocketClient.js:326:10) at ClientRequest. (/home/pi/Desktop/tjbot/recipes/conversation/node_modules/websocket/lib/WebSocketClient.js:265:18) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:478:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23) at TLSSocket.socketOnData (_http_client.js:367:20) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18), name=WebSocket connection error, type=error, isTrusted=false, _yaeti=true, , addEventListener=function _addEventListener(type, newListener) { var listenersType, .... If I remove this: listen: { inactivityTimeout: -1 } the connect works again. So that time out value must be causing that connect exception.

VidhyaSiva commented 5 years ago

I have getting the same error, changed the STT, TTS and conversation credentials to use password and username in config file, tried it vis swift playground and also Raspi command line. wondering what changed since Feb as this was working initially!!

zacaintmyname commented 5 years ago

Hi, same for me! The service was working like clockwork in Feb for me as well!

andycitron commented 5 years ago

Perhaps this will help. I've been working around this problem by using pi native eSpeak to speak long passages. With that, I still get the exception, but TJBot continues listening successfully after the exception.

The difference I see in the logs is when using eSpeak, this shows up in the log BEFORE the exception: debug: listening paused debug: microphone paused debug: listening resumed

When using Watson TTS, the 'debug listening resumed' shows up after the exception and the TJBot no longer response to voice input.

It seems that resuming listening before the exception is a key timing difference that relates to the problem.

I hope this provides a clue.

jweisz commented 4 years ago

Closing due to inactivity.

andycitron commented 4 years ago

FWIW, I suspect this problem still exists. I stopped using Watson text to speech for long phrases. I found a free service that provided the same function but didn't exhibit the hang.