diff --git a/UniqueBibleAppVersion.txt b/UniqueBibleAppVersion.txt index 7e8a527dec..6e3510c43e 100755 --- a/UniqueBibleAppVersion.txt +++ b/UniqueBibleAppVersion.txt @@ -1 +1 @@ -35.12 +35.13 diff --git a/latest_changes.txt b/latest_changes.txt index 5104603f4b..970475d18e 100755 --- a/latest_changes.txt +++ b/latest_changes.txt @@ -1,3 +1,6 @@ +Changes in 35.13: +* Fixed google-cloud text-to-speech integration. + Changes in 35.12: * exit w3m without user confirmation diff --git a/patches.txt b/patches.txt index 946f741d88..bfa0fb82c6 100755 --- a/patches.txt +++ b/patches.txt @@ -1299,7 +1299,6 @@ (33.96, "file", "gui/WorkSpace.py") (33.96, "file", "gui/YouTubePopover.py") (33.96, "file", "startup/nonGui.py") -(33.96, "file", "util/CrossPlatform.py") (33.98, "file", "gui/MenuItems.py") (34.04, "file", "htmlResources/material/action/terminal/materialiconsoutlined/48dp/2x/outline_terminal_black_48dp.png") (34.05, "file", "plugins/menu/Terminal.py") @@ -1315,7 +1314,6 @@ (34.20, "file", "gui/PlaylistUI.py") (34.23, "file", "gui/ConfigFlagsWindow.py") (34.23, "file", "util/RemoteCliMainWindow.py") -(34.23, "file", "util/TextEditorUtility.py") (34.26, "file", "install/module.py") (34.26, "file", "util/text_editor_checkup.py") (34.27, "file", "htmlResources/material/action/question_answer/materialiconsoutlined/48dp/2x/outline_question_answer_black_48dp.png") @@ -1382,14 +1380,16 @@ (35.05, "file", "gui/Worker.py") (35.06, "file", "plugins/menu/Bible Chat.py") (35.09, "file", "db/BiblesSqlite.py") -(35.09, "file", "util/TextCommandParser.py") (35.10, "file", "plugins/startup/highlightActiveVerse.py") (35.10, "file", "util/ConfigUtil.py") (35.10, "file", "util/terminal_system_command_prompt.py") (35.12, "file", "plugins/terminal/generate reference table from copied text.py") (35.12, "file", "plugins/terminal/generate reference table from latest content.py") (35.12, "file", "plugins/terminal/open html content with w3m.py") -(35.12, "file", "util/LocalCliHandler.py") -(35.12, "file", "patches.txt") -(35.12, "file", "UniqueBibleAppVersion.txt") -(35.12, "file", "latest_changes.txt") +(35.13, "file", "util/CrossPlatform.py") +(35.13, "file", "util/LocalCliHandler.py") +(35.13, "file", "util/TextCommandParser.py") +(35.13, "file", "util/TextEditorUtility.py") +(35.13, "file", "patches.txt") +(35.13, "file", "UniqueBibleAppVersion.txt") +(35.13, "file", "latest_changes.txt") diff --git a/util/CrossPlatform.py b/util/CrossPlatform.py index 3d7fa84868..4ad2a39df3 100755 --- a/util/CrossPlatform.py +++ b/util/CrossPlatform.py @@ -292,7 +292,7 @@ def saveCloudTTSAudio(self, inputText, languageCode, filename=""): if not moduleInstalled: installmodule("--upgrade google-cloud-texttospeech") os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.path.join(os.getcwd(), "credentials_GoogleCloudTextToSpeech.json") - # Modified from ource: https://cloud.google.com/text-to-speech/docs/create-audio-text-client-libraries#client-libraries-install-python + # Modified from source: https://cloud.google.com/text-to-speech/docs/create-audio-text-client-libraries#client-libraries-install-python """Synthesizes speech from the input string of text or ssml. Make sure to be working in a virtual environment. @@ -308,8 +308,11 @@ def saveCloudTTSAudio(self, inputText, languageCode, filename=""): # Build the voice request, select the language code (e.g. "yue-HK") and the ssml # voice gender ("neutral") + # Supported language: https://cloud.google.com/speech-to-text/docs/speech-to-text-supported-languages + # Voice: https://cloud.google.com/text-to-speech/docs/voices + # Gener: https://cloud.google.com/text-to-speech/docs/reference/rest/v1/SsmlVoiceGender voice = texttospeech.VoiceSelectionParams( - language_code=languageCode, ssml_gender=texttospeech.SsmlVoiceGender.NEUTRAL + language_code=languageCode, ssml_gender=texttospeech.SsmlVoiceGender.SSML_VOICE_GENDER_UNSPECIFIED ) # Select the type of audio file you want returned diff --git a/util/LocalCliHandler.py b/util/LocalCliHandler.py index 4ac44bd86f..f3a3478a7b 100644 --- a/util/LocalCliHandler.py +++ b/util/LocalCliHandler.py @@ -61,6 +61,7 @@ def __init__(self, command="John 3:16"): self.html = "Unique Bible App" self.plainText = "Unique Bible App" self.setupDialogs() + self.audioPlayer = None self.command = command self.dotCommands = self.getDotCommands() self.addShortcuts() @@ -2718,7 +2719,7 @@ def generateImage(self): with open(imageFile, mode="wb") as pngObj: pngObj.write(image_data) if config.terminalEnableTermuxAPI: - config.mainWindow.getCliOutput(f"termux-share {imageFile}") + self.getCliOutput(f"termux-share {imageFile}") else: os.system(f"{config.open} {imageFile}") # error codes: https://platform.openai.com/docs/guides/error-codes/python-library-error-types @@ -4079,7 +4080,7 @@ def changemymenu(self): userInput = prompt(self.inputIndicator, key_bindings=self.prompt_multiline_shared_key_bindings, bottom_toolbar=self.getToolBar(True), enable_system_prompt=True, swap_light_and_dark_colors=Condition(lambda: not config.terminalResourceLinkColor.startswith("ansibright")), style=self.promptStyle, multiline=True, default=default).strip() if userInput.lower() == config.terminal_cancel_action: return self.cancelAction() - config.terminalMyMenu = [i.lower().strip() for i in userInput.split("\n") if i.lower().strip() in config.mainWindow.dotCommands] + config.terminalMyMenu = [i.lower().strip() for i in userInput.split("\n") if i.lower().strip() in self.dotCommands] self.print("config.terminalMyMenu is changed to:") self.print(config.terminalMyMenu) diff --git a/util/TextCommandParser.py b/util/TextCommandParser.py index 69dcc8622e..69e1e70872 100644 --- a/util/TextCommandParser.py +++ b/util/TextCommandParser.py @@ -1,6 +1,5 @@ # coding=utf-8 -import glob, pprint -import pydoc +import glob, pprint, traceback, pydoc import os, re, webbrowser, platform, zipfile, subprocess, config from datetime import date from util.VlcUtil import VlcUtil @@ -1504,7 +1503,10 @@ def googleTextToSpeech(self, command, source): if os.path.isfile(audioFile): self.openMediaPlayer(audioFile, "main", gui=False) except: - self.parent.displayMessage(config.thisTranslation["message_fail"]) + if config.developer: + print(traceback.format_exc()) + else: + self.parent.displayMessage(config.thisTranslation["message_fail"]) # Keep the following codes for future reference # The following method does not work on Windows diff --git a/util/TextEditorUtility.py b/util/TextEditorUtility.py index fb46b4be05..f8d5d2a089 100755 --- a/util/TextEditorUtility.py +++ b/util/TextEditorUtility.py @@ -290,7 +290,7 @@ def saveCloudTTSAudio(self, inputText, languageCode, filename=""): # Build the voice request, select the language code (e.g. "yue-HK") and the ssml # voice gender ("neutral") voice = texttospeech.VoiceSelectionParams( - language_code=languageCode, ssml_gender=texttospeech.SsmlVoiceGender.NEUTRAL + language_code=languageCode, ssml_gender=texttospeech.SsmlVoiceGender.SSML_VOICE_GENDER_UNSPECIFIED ) # Select the type of audio file you want returned