Closed zacaintmyname closed 4 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
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.
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.
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.
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!!
Hi, same for me! The service was working like clockwork in Feb for me as well!
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.
Closing due to inactivity.
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.
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;
}, removeEventListener=function _removeEventListener(type, oldListener) { var listenersType, i, listener;
}, dispatchEvent=function _dispatchEvent(event) { var type, listenersType, dummyListener, stopImmediatePropagation = false, i, listener;
}, _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;
}, 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;
} 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');
}
// 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);
verbose: TJBot initializing microphone ^Z2019-04-09 12:14:02 sigHandler: Unhandled signal 20, terminating