Skip to content

Commit

Permalink
* 修正在語音合成器非選擇 WorldVoice 時,語音設定問題,改以顯示提示文字
Browse files Browse the repository at this point in the history
*	修正 aisound 音量調整問題
*	修正語音設定中偵測語言時間點的重啟條件
*	修正長按按鍵後語音無法中斷問題
*	修正多項語意問題(flake8)
*	相容於 NVDA 版本 2022.1
  • Loading branch information
tsengwoody committed May 5, 2022
1 parent 7b0f355 commit 92c5788
Show file tree
Hide file tree
Showing 22 changed files with 574 additions and 438 deletions.
9 changes: 9 additions & 0 deletions addon/doc/zh_CN/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ WorldVoice -> 档案汇入:可汇入档案,可用于汇入语音包。

## 更新版本日志

### v3.2

* 修正在语音合成器非选择 WorldVoice 时,语音设定问题,改以显示提示文字
* 修正 aisound 音量调整问题
* 修正语音设定中侦测语言时间点的重启条件
* 修正长按按键后语音无法中断问题
* 修正多项语意问题(flake8)
* 兼容于 NVDA 版本 2022.1

### v3.1

* 在网页浏览中中断无声报读
Expand Down
9 changes: 9 additions & 0 deletions addon/doc/zh_HK/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ WorldVoice -> 檔案匯入:可匯入檔案,可用於匯入語音包。

## 更新版本日誌

### v3.2

* 修正在語音合成器非選擇 WorldVoice 時,語音設定問題,改以顯示提示文字
* 修正 aisound 音量調整問題
* 修正語音設定中偵測語言時間點的重啟條件
* 修正長按按鍵後語音無法中斷問題
* 修正多項語意問題(flake8)
* 相容於 NVDA 版本 2022.1

### v3.1

* 在網頁瀏覽中中斷無聲報讀
Expand Down
9 changes: 9 additions & 0 deletions addon/doc/zh_TW/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ WorldVoice -> 檔案匯入:可匯入檔案,可用於匯入語音包。

## 更新版本日誌

### v3.2

* 修正在語音合成器非選擇 WorldVoice 時,語音設定問題,改以顯示提示文字
* 修正 aisound 音量調整問題
* 修正語音設定中偵測語言時間點的重啟條件
* 修正長按按鍵後語音無法中斷問題
* 修正多項語意問題(flake8)
* 相容於 NVDA 版本 2022.1

### v3.1

* 在網頁瀏覽中中斷無聲報讀
Expand Down
12 changes: 8 additions & 4 deletions addon/generics/speechSymbols/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
SYMMOD_FORCE = 1

SPEECH_SYMBOL_MODE_LABELS = {
SYMMOD_CONTEXT: _("context"),
SYMMOD_FORCE: _("force"),
SYMMOD_CONTEXT: _("context"),
SYMMOD_FORCE: _("force"),
}


Expand Down Expand Up @@ -171,10 +171,14 @@ def _saveSymbol(self, symbol):
self.IDENTIFIER_ESCAPES_OUTPUT[identifier[0]], identifier[1:])
except KeyError:
pass
fields = [identifier,
fields = [
identifier,
self._saveSymbolField(symbol.replacement),
self._saveSymbolField(symbol.language),
self._saveSymbolField(symbol.mode, self.MODE_OUTPUT)
self._saveSymbolField(
symbol.mode,
self.MODE_OUTPUT
)
]
# Strip optional fields with default values.
for field in reversed(fields[2:]):
Expand Down
32 changes: 17 additions & 15 deletions addon/generics/speechSymbols/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import copy
import os
import wx

import addonHandler
import core
import globalVars
import gui
from gui import nvdaControls
from gui import guiHelper
from gui import guiHelper, nvdaControls
from gui.settingsDialogs import SettingsDialog
from logHandler import log
import queueHandler

from .contextHelp import *
from .contextHelp import ContextHelpMixin
from .models import SpeechSymbols, SpeechSymbol, SPEECH_SYMBOL_LANGUAGE_LABELS, SPEECH_SYMBOL_MODE_LABELS

addonHandler.initTranslation()
Expand All @@ -29,7 +28,7 @@ class AddSymbolDialog(
def __init__(self, parent):
# Translators: This is the label for the add symbol dialog.
super().__init__(parent, title=_("Add Symbol"))
mainSizer=wx.BoxSizer(wx.VERTICAL)
mainSizer = wx.BoxSizer(wx.VERTICAL)
sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL)

# Translators: This is the label for the edit field in the add symbol dialog.
Expand All @@ -53,7 +52,7 @@ def __new__(cls, *args, **kwargs):
cls._instance = obj
return obj

def __init__(self,parent):
def __init__(self, parent):
# Translators: This is the label for the unicode setting dialog.
self.speechSymbols = None
self.title = _("Unicode Setting")
Expand All @@ -73,7 +72,7 @@ def makeSettings(self, settingsSizer):
# Translators: The label of a text field to search for symbols in the speech symbols dialog.
filterText = pgettext("speechSymbols", "&Filter by:")
self.filterEdit = sHelper.addLabeledControl(
labelText = filterText,
labelText=filterText,
wxCtrlClass=wx.TextCtrl,
size=(self.scaleSize(310), -1),
)
Expand Down Expand Up @@ -115,7 +114,7 @@ def makeSettings(self, settingsSizer):
# generally the advice on the wx documentation is: "In general, it is recommended to skip all non-command events
# to allow the default handling to take place. The command events are, however, normally not skipped as usually
# a single command such as a button click or menu item selection must only be processed by one handler."
def skipEventAndCall(handler):
def skipEventAndCall(handler):
def wrapWithEventSkip(event):
if event:
event.Skip()
Expand Down Expand Up @@ -246,13 +245,16 @@ def OnAddClick(self, evt):
if not identifier:
return
# Clean the filter, so we can select the new entry.
self.filterEdit.Value=""
self.filterEdit.Value = ""
self.filter()
for index, symbol in enumerate(self.symbols):
if identifier == symbol.identifier:
# Translators: An error reported in the Symbol Pronunciation dialog when adding a symbol that is already present.
gui.messageBox(_('Symbol "%s" is already present.') % identifier,
_("Error"), wx.OK | wx.ICON_ERROR)
gui.messageBox(
_('Symbol "%s" is already present.') % identifier,
_("Error"),
wx.OK | wx.ICON_ERROR
)
self.symbolsList.Select(index)
self.symbolsList.Focus(index)
self.symbolsList.SetFocus()
Expand Down Expand Up @@ -319,17 +321,17 @@ def onOk(self, evt):
# Translators: The message displayed
_("For the edited unicode rule to apply, NVDA must be restarted. Do you want to restart NVDA now?"),
# Translators: The title of the dialog
_("unicode rule edited"), wx.OK|wx.CANCEL|wx.ICON_WARNING, self
)==wx.OK:
queueHandler.queueFunction(queueHandler.eventQueue,core.restart)
_("unicode rule edited"), wx.OK | wx.CANCEL | wx.ICON_WARNING, self
) == wx.OK:
queueHandler.queueFunction(queueHandler.eventQueue, core.restart)

self.__class__._instance = None
super(SpeechSymbolsDialog, self).onOk(evt)

def _refreshVisibleItems(self):
count = self.symbolsList.GetCountPerPage()
first = self.symbolsList.GetTopItem()
self.symbolsList.RefreshItems(first, first+count)
self.symbolsList.RefreshItems(first, first + count)

def onFilterEditTextChange(self, evt):
self.filter(self.filterEdit.Value)
Expand Down
31 changes: 15 additions & 16 deletions addon/globalPlugins/WorldVoice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import os
import sys

import wx

import addonHandler
import config
import globalPluginHandler
import globalVars
import gui
from scriptHandler import script, getLastScriptRepeatCount
from scriptHandler import script
import speech
try:
from synthDriverHandler import getSynth
except:
except BaseException:
from speech import getSynth
import ui

from .speechSettingsDialog import SpeechSettingsDialog
from generics.speechSymbols.views import SpeechSymbolsDialog
from synthDrivers.WorldVoice import VEVoice, Sapi5Voice, AisoundVoice
from synthDrivers.WorldVoice.voiceManager import VEVoice, AisoundVoice
from synthDrivers.WorldVoice import WVStart, WVEnd
from synthDrivers.WorldVoice.hook import Hook

addonHandler.initTranslation()
ADDON_SUMMARY = addonHandler.getCodeAddon().manifest["summary"]
workspace_path = os.path.join(globalVars.appArgs.configPath, "WorldVoice-workspace")


class GlobalPlugin(globalPluginHandler.GlobalPlugin):
def __init__(self):
super().__init__()
Expand All @@ -37,7 +36,7 @@ def __init__(self):
speech.speech.getTextInfoSpeech,
speech.speech.SpeakTextInfoState,
)
except:
except BaseException:
pass

if globalVars.appArgs.secure:
Expand Down Expand Up @@ -67,23 +66,23 @@ def createMenu(self):
item = self.submenu_vocalizer.Append(wx.ID_ANY, _("&Speech Settings"), _("Speech Settings."))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.popup_SpeechSettingsDialog, item)
item = self.submenu_vocalizer.Append(wx.ID_ANY, _("&Unicode Settings"), _("Unicode Settings."))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU , self.popup_SpeechSymbolsDialog, item)
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.popup_SpeechSymbolsDialog, item)
item = self.submenu_vocalizer.Append(wx.ID_ANY, _("&File Import"), _("Import File."))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU , self.onFileImport, item)
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onFileImport, item)
if not VEVoice.install():
item = self.submenu_vocalizer.Append(wx.ID_ANY, _("VE Core Install"), _("Install VE Core."))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU , self.onVECoreInstall, item)
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onVECoreInstall, item)
if not AisoundVoice.install():
item = self.submenu_vocalizer.Append(wx.ID_ANY, _("&Aisound Core Install"), _("Install Aisound Core."))
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU , self.onAisoundCoreInstall, item)
gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU, self.onAisoundCoreInstall, item)

self.submenu_item = gui.mainFrame.sysTrayIcon.menu.Insert(2, wx.ID_ANY, _("WorldVoice"), self.submenu_vocalizer)

def removeMenu(self):
if self.submenu_item is not None:
try:
gui.mainFrame.sysTrayIcon.menu.Remove(self.submenu_item)
except AttributeError: # We can get this somehow from wx python when NVDA is shuttingdown, just ignore
except AttributeError: # We can get this somehow from wx python when NVDA is shuttingdown, just ignore
pass
self.submenu_item.Destroy()

Expand All @@ -98,19 +97,19 @@ def fileImport(self, import_path):
with ZipFile(path, 'r') as core_file:
core_file.testzip()
core_file.extractall(import_path)
except:
except BaseException:
gui.messageBox(
_("Import fail"),
_("Import File"),wx.OK
_("Import File"), wx.OK
)
else:
if gui.messageBox(
_("For the new file to import, NVDA must be restarted. Are you want to restart NVDA now ?"),
_("Import File"),wx.OK|wx.CANCEL|wx.ICON_WARNING
)==wx.OK:
_("Import File"), wx.OK | wx.CANCEL | wx.ICON_WARNING
) == wx.OK:
import core
import queueHandler
queueHandler.queueFunction(queueHandler.eventQueue,core.restart)
queueHandler.queueFunction(queueHandler.eventQueue, core.restart)

def onFileImport(self, event):
self.fileImport(workspace_path)
Expand Down
Loading

0 comments on commit 92c5788

Please sign in to comment.