Remove punctuation

This commit is contained in:
Ruben van de Ven 2020-02-28 16:57:23 +03:00
parent b9196db157
commit 9cd98367cd

View file

@ -20,10 +20,13 @@ from hugvey.communication import LOG_BS
import audioop
import gc
import time
import string
mainLogger = logging.getLogger("hugvey")
logger = mainLogger.getChild("google")
punctuationTranslation = str.maketrans('','',string.punctuation)
class RequireRestart(Exception):
pass
@ -175,6 +178,13 @@ class GoogleVoiceClient(object):
else:
self.logger.info(f"Text: {transcript}")
self.lastNonFinalTranscript = None
# if any(p in transcript for p in string.punctuation):
# self.logger.warning(f"Google returned punctuation in the string. It is removed: {transcript}")
# remove any possible punctuation from string. As google has sometimes
# given results _with_ punctuation, even though it should not?
transcript = transcript.translate(punctuationTranslation)
if result.is_final:
self.logger.info("native final")