From 9cd98367cd77e841c7278685fbd08f16dc4a66c0 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 28 Feb 2020 16:57:23 +0300 Subject: [PATCH] Remove punctuation --- hugvey/speech/google.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hugvey/speech/google.py b/hugvey/speech/google.py index cfa718f..745dbfa 100644 --- a/hugvey/speech/google.py +++ b/hugvey/speech/google.py @@ -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")