Temporarily disable recording while playing audio
This commit is contained in:
parent
02eac88560
commit
58b977f5df
2 changed files with 18 additions and 2 deletions
|
@ -16,6 +16,7 @@ import asyncio
|
|||
import threading
|
||||
import queue
|
||||
import uuid
|
||||
from hugvey.communication import LOG_BS
|
||||
|
||||
|
||||
logger = logging.getLogger("speech")
|
||||
|
@ -48,10 +49,11 @@ class GoogleVoiceClient(object):
|
|||
self.restart = True
|
||||
|
||||
def resume(self):
|
||||
self.buffer = queue.Queue() # have a clear queue when resuming
|
||||
self.isRunning.set()
|
||||
|
||||
def generator(self):
|
||||
while not self.toBeShutdown:
|
||||
while not self.toBeShutdown and self.isRunning.is_set():
|
||||
yield self.buffer.get()
|
||||
|
||||
def setLanguage(self, language_code):
|
||||
|
@ -147,6 +149,10 @@ class GoogleVoiceClient(object):
|
|||
if not self.task.isAlive():
|
||||
raise Exception("Voice thread died")
|
||||
|
||||
if not self.isRunning.is_set():
|
||||
# logger.log(LOG_BS, "Don't put to queue if google is paused")
|
||||
return
|
||||
|
||||
if self.src_rate == self.target_rate:
|
||||
data = chunk
|
||||
else:
|
||||
|
|
|
@ -528,7 +528,12 @@ class Story(object):
|
|||
if e['msgId'] == self.currentMessage.id:
|
||||
#TODO: migrate value to Messagage instead of Story
|
||||
self.lastMsgFinishTime = self.timer.getElapsed()
|
||||
|
||||
|
||||
# 2019-02-22 temporary disable listening while playing audio:
|
||||
if self.hugvey.google is not None:
|
||||
logger.warn("Temporary 'fix' -> resume recording?")
|
||||
self.hugvey.google.resume()
|
||||
|
||||
if self.currentMessage.id not in self.directionsPerMsg:
|
||||
logger.info("THE END!")
|
||||
self.stop()
|
||||
|
@ -637,6 +642,11 @@ class Story(object):
|
|||
'file': await message.getAudioFilePath(self),
|
||||
'id': message.id,
|
||||
})
|
||||
|
||||
# 2019-02-22 temporary disable listening while playing audio:
|
||||
if self.hugvey.google is not None:
|
||||
logger.warn("Temporary 'fix' -> stop recording")
|
||||
self.hugvey.google.pause()
|
||||
|
||||
logger.debug("Pending directions: ")
|
||||
|
||||
|
|
Loading…
Reference in a new issue