diff --git a/hugvey/central_command.py b/hugvey/central_command.py index e623cef..17cd9cb 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -557,7 +557,9 @@ class HugveyState(object): self.logger.info(f"set language: {language_code}") self.language_code = language_code - self.google.setLanguage(language_code) + + if self.google: + self.google.setLanguage(language_code) if self.isRunning.is_set(): self.restart() diff --git a/hugvey/speech/google.py b/hugvey/speech/google.py index f4bd782..fe5d488 100644 --- a/hugvey/speech/google.py +++ b/hugvey/speech/google.py @@ -78,22 +78,25 @@ class GoogleVoiceClient(object): self.logger.info("Change language from {} to {}".format(self.language_code, language_code)) self.language_code = language_code + self.isRunning.clear() self.restart = True def run(self): self.isRunning.set() + # Leave this here to avoid "Too many files open" errors. self.speech_client = speech.SpeechClient() - config = types.RecognitionConfig( - encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16, - sample_rate_hertz=self.src_rate, - language_code=self.language_code) - self.streaming_config = types.StreamingRecognitionConfig( - config=config, - interim_results=True) while not self.toBeShutdown: try: + config = types.RecognitionConfig( + encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16, + sample_rate_hertz=self.src_rate, + language_code=self.language_code) + self.streaming_config = types.StreamingRecognitionConfig( + config=config, + interim_results=True) + self.logger.log(LOG_BS,"wait for Google Voice") if not self.isRunning.wait(timeout=1): continue # re-ceck toBeShutdown diff --git a/hugvey/story.py b/hugvey/story.py index 5e487cd..cee4b90 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1226,7 +1226,7 @@ class Story(object): """ self.finish() #stop google etc: - self.hugvey.awaiting() + self.hugvey.available() def finish(self): """ diff --git a/www/index.html b/www/index.html index 1388dbc..8df8f00 100644 --- a/www/index.html +++ b/www/index.html @@ -1,6 +1,6 @@
-