Remove punctuation
This commit is contained in:
parent
b9196db157
commit
9cd98367cd
1 changed files with 10 additions and 0 deletions
|
@ -20,10 +20,13 @@ from hugvey.communication import LOG_BS
|
||||||
import audioop
|
import audioop
|
||||||
import gc
|
import gc
|
||||||
import time
|
import time
|
||||||
|
import string
|
||||||
|
|
||||||
mainLogger = logging.getLogger("hugvey")
|
mainLogger = logging.getLogger("hugvey")
|
||||||
logger = mainLogger.getChild("google")
|
logger = mainLogger.getChild("google")
|
||||||
|
|
||||||
|
punctuationTranslation = str.maketrans('','',string.punctuation)
|
||||||
|
|
||||||
class RequireRestart(Exception):
|
class RequireRestart(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -175,6 +178,13 @@ class GoogleVoiceClient(object):
|
||||||
else:
|
else:
|
||||||
self.logger.info(f"Text: {transcript}")
|
self.logger.info(f"Text: {transcript}")
|
||||||
self.lastNonFinalTranscript = None
|
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:
|
if result.is_final:
|
||||||
self.logger.info("native final")
|
self.logger.info("native final")
|
||||||
|
|
Loading…
Reference in a new issue