Now accepts fr-FR2 as language code

This commit is contained in:
Ruben van de Ven 2019-11-05 07:28:10 +01:00
parent f833d952fb
commit ea5b9cc060
2 changed files with 9 additions and 3 deletions

View file

@ -102,6 +102,12 @@ class GoogleVoiceClient(object):
self.isRunning.clear()
self.restart = True
def getOfficialLangCode(self):
# October 2019: multiple versions for the French language exists, called fr-FR2
# Instead of rewriting the whole codebase to accept a different language id, we can also
# just strip the numbers from the language code :-)
return ''.join([i for i in self.language_code if not i.isdigit()])
def run(self):
self.isRunning.set()
@ -112,7 +118,7 @@ class GoogleVoiceClient(object):
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=self.src_rate,
language_code=self.language_code)
language_code=self.getOfficialLangCode())
self.streaming_config = types.StreamingRecognitionConfig(
config=config,
interim_results=True)