title: How to prevent session timeout without sending "no-op" message in Watson Speech To Text?
body: <p>I have made a Python app that runs on NAO Robot functioned as a "friend" with the help of Watson Speech To Text and Watson Conversation services. The Robot will alternate between asking the question and answering a question. </p>
  
  <p>When the robot is in "asking question" mode, it will listen to Human and stream the speech to Watson STT. The speech is recorded using Arecord. Arecord is then stopped whenever user finishes talking. The transcribed speech will then be sent to Conversation and Robot will then answer the question accordingly. Usually, the "answering question" mode will last less than 30 seconds. But some reply is long enough that the Watson STT will trigger session timeout. </p>
  
  <p>To prevent this session timeout, we used to send "no-op" message signal every 10 seconds. </p>
  
  <pre><code>def keepAlive(self):
      self.send({"action": "no-op"})
  </code></pre>
  
  <p>However, Watson <a href="https://www.ibm.com/watson/developercloud/doc/speech-to-text/release-notes.html#March2017" rel="nofollow noreferrer">recently deprecated</a> the sending "no-op" message to prevent session timeout. As an alternative to sending "no-op", you can send a silence audio data to prevent session timeout. According to the documentation: </p>
  
  <blockquote>
    <p>"Sending audio data, including silence, to the service to avoid the 30-second >session timeout. You will be charged for any data sent to the service, >including the silence that you send to extend the session." </p>
  </blockquote>
  
  <p>So I tried this:</p>
  
  <pre><code>def keepAlive(self):
      data = {"action": "start", "content-type": "audio/l16;rate=16000", "inactivity_timeout":-1}
      self.send(json.dumps(data).encode('utf8'), binary)
      reccmd = ["arecord", "-f", "S16_LE", "-r", "16000", "-t", "raw"]
      p = subprocess.Popen(reccmd, stdout=subprocess.PIPE)
      data = p.stdout.read(1024)
      self.send(bytearray(data), binary=True)
      self.send({"action": "stop"})
  </code></pre>
  
  <p>However, I received this error:</p>
  
  <blockquote>
    <p><em>Msg received: {u'error': u'could not detect endianness after looking at the tail 924 non-zero byte string in a data stream of 1024 bytes.
    Is the bytestream really PCM data?'}</em></p>
  </blockquote>
  
  <p>The websocket is also closed immediately after that. What is the correct way to send silence audio data to Watson STT? Or is there any other workaround to prevent session timeout?</p>