__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# Orca
#
# Copyright 2004-2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA 02110-1301 USA.
# pylint: disable=broad-exception-caught
"""Manages the default speech server for orca. A script can use this
as its speech server, or it can feel free to create one of its own."""
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
__license__ = "LGPL"
import importlib
from . import debug
from . import settings
from . import speech_generator
from .acss import ACSS
from .speechserver import VoiceFamily
# The speech server to use for all speech operations.
#
_speechserver = None
def _init_speech_server(module_name, speech_server_info):
global _speechserver
if not module_name:
return
factory = None
try:
factory = importlib.import_module(f'orca.{module_name}')
except Exception:
try:
factory = importlib.import_module(module_name)
except Exception:
debug.print_exception(debug.LEVEL_SEVERE)
# Now, get the speech server we care about.
#
speech_server_info = settings.speechServerInfo
if speech_server_info:
_speechserver = factory.SpeechServer.get_speech_server(speech_server_info)
if not _speechserver:
_speechserver = factory.SpeechServer.get_speech_server()
if speech_server_info:
tokens = ["SPEECH: Invalid speechServerInfo:", speech_server_info]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
if not _speechserver:
raise RuntimeError(f"ERROR: No speech server for factory: {module_name}")
def init():
"""Initializes the speech server."""
debug.print_message(debug.LEVEL_INFO, 'SPEECH: Initializing', True)
if _speechserver:
debug.print_message(debug.LEVEL_INFO, 'SPEECH: Already initialized', True)
return
# HACK: Orca goes to incredible lengths to avoid a broken configuration, so this
# last-chance override exists to get the speech system loaded, without risking
# it being written to disk unintentionally.
if settings.speechSystemOverride:
setattr(settings, 'speechServerFactory', settings.speechSystemOverride)
setattr(settings, 'speechServerInfo', ['Default Synthesizer', 'default'])
try:
module_name = settings.speechServerFactory
_init_speech_server(module_name, settings.speechServerInfo)
except Exception:
module_names = settings.speechFactoryModules
for module_name in module_names:
if module_name != settings.speechServerFactory:
try:
_init_speech_server(module_name, None)
if _speechserver:
break
except Exception:
debug.print_exception(debug.LEVEL_SEVERE)
if _speechserver:
tokens = ["SPEECH: Using speech server factory:", module_name]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
else:
msg = 'SPEECH: Not available'
debug.print_message(debug.LEVEL_INFO, msg, True)
debug.print_message(debug.LEVEL_INFO, 'SPEECH: Initialized', True)
def __resolve_acss(acss=None):
if isinstance(acss, ACSS):
family = acss.get(acss.FAMILY)
try:
family = VoiceFamily(family)
except Exception:
family = VoiceFamily({})
acss[acss.FAMILY] = family
return acss
if isinstance(acss, list) and len(acss) == 1:
return ACSS(acss[0])
if isinstance(acss, dict):
return ACSS(acss)
voices = settings.voices
return ACSS(voices[settings.DEFAULT_VOICE])
def say_all(utterance_iterator, progress_callback):
"""Speaks each item in the utterance_iterator."""
if settings.silenceSpeech:
return
if _speechserver:
_speechserver.say_all(utterance_iterator, progress_callback)
else:
for [context, _acss] in utterance_iterator:
log_line = f"SPEECH OUTPUT: '{context.utterance}'"
debug.print_message(debug.LEVEL_INFO, log_line, True)
def _speak(text, acss, interrupt):
"""Speaks the individual string using the given ACSS."""
if not _speechserver:
log_line = f"SPEECH OUTPUT: '{text}' {acss}"
debug.print_message(debug.LEVEL_INFO, log_line, True)
return
voice = ACSS(settings.voices.get(settings.DEFAULT_VOICE))
try:
voice.update(__resolve_acss(acss))
except Exception as error:
msg = f"SPEECH: Exception updated voice with {acss}: {error}"
debug.print_message(debug.LEVEL_INFO, msg, True)
resolved_voice = __resolve_acss(voice)
msg = f"SPEECH OUTPUT: '{text}' {resolved_voice}"
debug.print_message(debug.LEVEL_INFO, msg, True)
_speechserver.speak(text, resolved_voice, interrupt)
def speak(content, acss=None, interrupt=True):
"""Speaks the given content. The content can be either a simple
string or an array of arrays of objects returned by a speech
generator."""
if settings.silenceSpeech:
return
valid_types = (str, list, speech_generator.Pause, ACSS)
error = "SPEECH: Bad content sent to speak():"
if not isinstance(content, valid_types):
debug.print_message(debug.LEVEL_INFO, error + str(content), True, True)
return
if isinstance(content, str):
msg = f"SPEECH: Speak '{content}' acss: {acss}"
debug.print_message(debug.LEVEL_INFO, msg, True)
else:
tokens = ["SPEECH: Speak", content, ", acss:", acss]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
if isinstance(content, str):
_speak(content, acss, interrupt)
if not isinstance(content, list):
return
to_speak = []
active_voice = acss
if acss is not None:
active_voice = ACSS(acss)
for element in content:
if not isinstance(element, valid_types):
debug.print_message(debug.LEVEL_INFO, error + str(element), True, True)
elif isinstance(element, list):
speak(element, acss, interrupt)
elif isinstance(element, str):
if len(element):
to_speak.append(element)
elif to_speak:
new_voice = ACSS(acss)
new_items_to_speak = []
if isinstance(element, speech_generator.Pause):
if to_speak[-1] and to_speak[-1][-1].isalnum():
to_speak[-1] += '.'
elif isinstance(element, ACSS):
new_voice.update(element)
if active_voice is None:
active_voice = new_voice
if new_voice == active_voice:
continue
tokens = ["SPEECH: New voice", new_voice, " != active voice", active_voice]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
new_items_to_speak.append(to_speak.pop())
if to_speak:
string = " ".join(to_speak)
_speak(string, active_voice, interrupt)
active_voice = new_voice
to_speak = new_items_to_speak
if to_speak:
string = " ".join(to_speak)
_speak(string, active_voice, interrupt)
def speak_key_event(event, acss=None):
"""Speaks event immediately using the voice specified by acss."""
if settings.silenceSpeech:
return
key_name = event.get_key_name()
acss = __resolve_acss(acss)
msg = f"{key_name} {event.get_locking_state_string()}"
log_line = f"SPEECH OUTPUT: '{msg.strip()}' {acss}"
debug.print_message(debug.LEVEL_INFO, log_line, True)
if _speechserver:
_speechserver.speak_key_event(event, acss)
def speak_character(character, acss=None):
"""Speaks character immediately using the voice specified by acss."""
if settings.silenceSpeech:
return
acss = __resolve_acss(acss)
log_line = f"SPEECH OUTPUT: '{character}'"
tokens = [log_line, acss]
debug.print_tokens(debug.LEVEL_INFO, tokens, True)
if _speechserver:
_speechserver.speak_character(character, acss=acss)
def get_speech_server():
"""Returns the current speech server."""
return _speechserver
def deprecated_clear_server():
"""This is a sad workaround for the current global _speechserver."""
global _speechserver
_speechserver = None
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| backends | Folder | 0755 |
|
|
| scripts | Folder | 0755 |
|
|
| __init__.py | File | 115 B | 0644 |
|
| acss.py | File | 3.85 KB | 0644 |
|
| action_presenter.py | File | 8.65 KB | 0644 |
|
| ax_collection.py | File | 6.16 KB | 0644 |
|
| ax_component.py | File | 14.93 KB | 0644 |
|
| ax_document.py | File | 9.36 KB | 0644 |
|
| ax_event_synthesizer.py | File | 17.39 KB | 0644 |
|
| ax_hypertext.py | File | 8.36 KB | 0644 |
|
| ax_object.py | File | 47.84 KB | 0644 |
|
| ax_selection.py | File | 4.54 KB | 0644 |
|
| ax_table.py | File | 47.98 KB | 0644 |
|
| ax_text.py | File | 45.13 KB | 0644 |
|
| ax_utilities.py | File | 28.24 KB | 0644 |
|
| ax_utilities_application.py | File | 7.17 KB | 0644 |
|
| ax_utilities_collection.py | File | 86.79 KB | 0644 |
|
| ax_utilities_debugging.py | File | 10.12 KB | 0644 |
|
| ax_utilities_event.py | File | 32.78 KB | 0644 |
|
| ax_utilities_relation.py | File | 15.2 KB | 0644 |
|
| ax_utilities_role.py | File | 91.79 KB | 0644 |
|
| ax_utilities_state.py | File | 11.63 KB | 0644 |
|
| ax_value.py | File | 6.83 KB | 0644 |
|
| bookmarks.py | File | 11.95 KB | 0644 |
|
| braille.py | File | 74.03 KB | 0644 |
|
| braille_generator.py | File | 55.79 KB | 0644 |
|
| braille_rolenames.py | File | 10.23 KB | 0644 |
|
| brlmon.py | File | 6.53 KB | 0644 |
|
| brltablenames.py | File | 7.3 KB | 0644 |
|
| bypass_mode_manager.py | File | 4.79 KB | 0644 |
|
| caret_navigation.py | File | 19.51 KB | 0644 |
|
| chat.py | File | 32.03 KB | 0644 |
|
| clipboard.py | File | 20.45 KB | 0644 |
|
| cmdnames.py | File | 61.77 KB | 0644 |
|
| colornames.py | File | 39.22 KB | 0644 |
|
| debug.py | File | 3.95 KB | 0644 |
|
| debugging_tools_manager.py | File | 10.69 KB | 0644 |
|
| event_manager.py | File | 36.07 KB | 0644 |
|
| flat_review.py | File | 48.89 KB | 0644 |
|
| flat_review_finder.py | File | 20.2 KB | 0644 |
|
| flat_review_presenter.py | File | 45.94 KB | 0644 |
|
| focus_manager.py | File | 11.52 KB | 0644 |
|
| generator.py | File | 67.07 KB | 0644 |
|
| guilabels.py | File | 56.38 KB | 0644 |
|
| highlighter.py | File | 6.95 KB | 0644 |
|
| input_event.py | File | 30.05 KB | 0644 |
|
| input_event_manager.py | File | 35.66 KB | 0644 |
|
| keybindings.py | File | 24.87 KB | 0644 |
|
| keynames.py | File | 9.55 KB | 0644 |
|
| label_inference.py | File | 19.77 KB | 0644 |
|
| learn_mode_presenter.py | File | 14.72 KB | 0644 |
|
| liveregions.py | File | 25.77 KB | 0644 |
|
| mathsymbols.py | File | 88.65 KB | 0644 |
|
| messages.py | File | 152.28 KB | 0644 |
|
| mouse_review.py | File | 23.34 KB | 0644 |
|
| notification_presenter.py | File | 14.17 KB | 0644 |
|
| object_navigator.py | File | 13.24 KB | 0644 |
|
| object_properties.py | File | 33.86 KB | 0644 |
|
| orca.py | File | 9.83 KB | 0644 |
|
| orca_gtkbuilder.py | File | 5.42 KB | 0644 |
|
| orca_gui_navlist.py | File | 6.51 KB | 0644 |
|
| orca_gui_prefs.py | File | 141.9 KB | 0644 |
|
| orca_gui_profile.py | File | 3.98 KB | 0644 |
|
| orca_i18n.py | File | 3.13 KB | 0644 |
|
| orca_modifier_manager.py | File | 13.76 KB | 0644 |
|
| orca_platform.py | File | 1.43 KB | 0644 |
|
| phonnames.py | File | 2.76 KB | 0644 |
|
| pronunciation_dict.py | File | 2.55 KB | 0644 |
|
| script.py | File | 11.11 KB | 0644 |
|
| script_manager.py | File | 14.68 KB | 0644 |
|
| script_utilities.py | File | 64.21 KB | 0644 |
|
| settings.py | File | 10.66 KB | 0644 |
|
| settings_manager.py | File | 27.13 KB | 0644 |
|
| sleep_mode_manager.py | File | 5.04 KB | 0644 |
|
| sound.py | File | 5.51 KB | 0644 |
|
| sound_generator.py | File | 48.88 KB | 0644 |
|
| speech.py | File | 8.87 KB | 0644 |
|
| speech_and_verbosity_manager.py | File | 27.71 KB | 0644 |
|
| speech_generator.py | File | 163.53 KB | 0644 |
|
| speechdispatcherfactory.py | File | 24.68 KB | 0644 |
|
| speechserver.py | File | 8 KB | 0644 |
|
| spellcheck.py | File | 18.11 KB | 0644 |
|
| spiel.py | File | 25.59 KB | 0644 |
|
| ssml.py | File | 6.71 KB | 0644 |
|
| structural_navigation.py | File | 77.63 KB | 0644 |
|
| system_information_presenter.py | File | 7.44 KB | 0644 |
|
| table_navigator.py | File | 29.78 KB | 0644 |
|
| text_attribute_names.py | File | 27.31 KB | 0644 |
|
| where_am_i_presenter.py | File | 21.59 KB | 0644 |
|