本文整理汇总了Python中speech.speak函数的典型用法代码示例。如果您正苦于以下问题:Python speak函数的具体用法?Python speak怎么用?Python speak使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speak函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: autonomous
def autonomous(self):
speech.speak("I am Humphrey!")
while self.autonomous_thread_running:
if self.autonomous_thread_pause:
time.sleep(.1)
self.time_of_last_stuck = time.time()
continue
self.start_forward()
if config.SERVO_ON:
servo = self.next_step()
self.set_servo(servo)
self.current_distance = self.get_top_distance()
if self.object_detected(self.current_distance, servo):
self.stop_forward()
self.backward(config.BACKWARD_TIME)
self.auto_turn(servo)
elif self.is_robot_stuck():
self.stop_forward()
self.get_unstuck()
speech.say_something()
开发者ID:nibty,项目名称:robot-wirus,代码行数:27,代码来源:wirus.py
示例2: possibilities
def possibilities(self, event):
l = self._board.possibilities(self._x, self._y)
if l:
message = " ".join(map(str, l))
speech.speak(message)
else:
speech.speak(_("Nothing"))
开发者ID:ragb,项目名称:sudoaudio,代码行数:7,代码来源:game.py
示例3: sayAndPrint
def sayAndPrint(text,
stop=False,
getInput=False,
speechServer=None,
voice=None):
"""Prints the given text. In addition, if the text field
is not None, speaks the given text, optionally interrupting
anything currently being spoken.
Arguments:
- text: the text to print and speak
- stop: if True, interrupt any speech currently being spoken
- getInput: if True, elicits raw input from the user and returns it
- speechServer: the speech server to use
- voice: the ACSS to use for speaking
Returns raw input from the user if getInput is True.
"""
if stop:
speech.stop()
if speechServer:
speechServer.stop()
if speechServer:
speechServer.speak(text, voice)
else:
speech.speak(text, voice)
if getInput:
return raw_input(text)
else:
print text
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:33,代码来源:orca_console_prefs.py
示例4: utterMessage
def utterMessage(self, chatRoomName, message, focused=True):
""" Speak/braille a chat room message.
Arguments:
- chatRoomName: name of the chat room this message came from
- message: the chat room message
- focused: whether or not the current chatroom has focus. Defaults
to True so that we can use this method to present chat history
as well as incoming messages.
"""
# Only speak/braille the new message if it matches how the user
# wants chat messages spoken.
#
verbosity = self._script.getSettings().chatMessageVerbosity
if orca_state.activeScript.name != self._script.name and verbosity == settings.CHAT_SPEAK_ALL_IF_FOCUSED:
return
elif not focused and verbosity == settings.CHAT_SPEAK_FOCUSED_CHANNEL:
return
text = ""
if _settingsManager.getSetting("chatSpeakRoomName") and chatRoomName:
text = _("Message from chat room %s") % chatRoomName
text = self._script.utilities.appendString(text, message)
if len(text.strip()):
speech.speak(text)
self._script.displayBrailleMessage(text)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:28,代码来源:chat.py
示例5: processInputEvent
def processInputEvent(self, script, inputEvent):
"""Processes an input event. If settings.learnModeEnabled is True,
this will merely report the description of the input event to braille
and speech. If settings.learnModeEnabled is False, this will call the
function bound to this InputEventHandler instance, passing the
inputEvent as the sole argument to the function.
This function is expected to return True if it consumes the
event; otherwise it is expected to return False.
Arguments:
- script: the script (if any) associated with this event
- inputEvent: the input event to pass to the function bound
to this InputEventHandler instance.
"""
consumed = False
if settings.learnModeEnabled and self._learnModeEnabled:
if self._description:
# These imports are here to eliminate circular imports.
#
import braille
import speech
braille.displayMessage(self._description)
speech.speak(self._description)
consumed = True
else:
try:
consumed = self._function(script, inputEvent)
except:
debug.printException(debug.LEVEL_SEVERE)
return consumed
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:34,代码来源:input_event.py
示例6: process_name_change
def process_name_change(new_name):
if new_name:
settings.set_username(new_name)
speech.speak('Pleased to meet you, ' + settings.username + '!', True)
return True
else:
return False
开发者ID:WarriorIng64,项目名称:LTUAssistant,代码行数:7,代码来源:assistantdb.py
示例7: removeFile
def removeFile(file):
"""remove a file"""
if "y" in speech.question("Are you sure you want to remove " + file + "? (Y/N): "):
speech.speak("Removing " + file + " with the 'rm' command.")
subprocess.call(["rm", "-r", file])
else:
speech.speak("Okay, I won't remove " + file + ".")
开发者ID:mikemelch,项目名称:hallie,代码行数:7,代码来源:files.py
示例8: script_navigate
def script_navigate(self, gesture):
modNames = gesture.modifierNames
try:
text = self.provider._mpNavigation.DoNavigateKeyPress(gesture.vkCode,
"shift" in modNames, "control" in modNames, "alt" in modNames, False)
except COMError:
return
speech.speak(_processMpSpeech(text, self.provider._language))
开发者ID:Alain-Ambazac,项目名称:nvda,代码行数:8,代码来源:mathPlayer.py
示例9: speakInstalledPackages
def speakInstalledPackages(package, package_manager, installed, similar=[], speakSimilar=True):
if installed:
speech.speak("The package '" + package + "' is installed with the '" + package_manager + "' package manager.\n")
elif speakSimilar:
speech.speak("The package '" + package + "' is not installed with the '" + package_manager + "' package manager." +
("" if similar else "\n"))
if similar:
speakSimilarPackages(similar)
开发者ID:mikemelch,项目名称:hallie,代码行数:8,代码来源:install.py
示例10: process_send_email
def process_send_email(recipient_info, verbose):
'''Take appropriate action with the given email recipient information.'''
if recipient_info and recipient_info.find("@") != -1:
recipient = 'mailto:' + recipient_info # Open default email client
else:
recipient = 'https://mail.google.com/mail/u/0/#compose' # Gmail
speech.speak('Composing an email...', verbose)
webbrowser.open(recipient)
开发者ID:WarriorIng64,项目名称:LTUAssistant,代码行数:8,代码来源:assistantdb.py
示例11: copy
def copy(location):
"""copy file or directory at a given location; can be pasted later"""
copyData = settings.getDataFile()
copyFileLocation = os.path.abspath(location)
copy = {"copyLocation": copyFileLocation}
dataFile = open(copyData, "wb")
pickle.dump(copy, dataFile)
speech.speak(location + " copied successfully!")
speech.speak("Tip: use 'hallie paste' to paste this file.")
开发者ID:mikemelch,项目名称:hallie,代码行数:9,代码来源:files.py
示例12: put
def put(self, event):
value = event.key - K_0
ret = self._board.put(self._x, self._y, value)
if ret:
self._move_sound.play()
self.speak_current()
if self._board.is_solution():
self._win_sound.play()
speech.speak(_("Solution found"))
else:
speech.speak(_("Impossible move"))
开发者ID:ragb,项目名称:sudoaudio,代码行数:11,代码来源:game.py
示例13: process_add_cal_event
def process_add_cal_event(event_str, verbose):
'''Schedule a new calendar event with the user.'''
if event_str == 'event':
event_sentence = speech.ask_question('Okay, what is the event called?', verbose)
day_sentence = speech.ask_question('What day will this be on?', verbose)
time_sentence = speech.ask_question('What time will this start at?', verbose)
cal_event = calendardb.CalendarEvent(event_sentence, day_sentence, time_sentence, '')
calendardb.add_event(cal_event)
feedback_sentence = 'Alright, I\'m putting down ' + str(cal_event) + '.'
speech.speak(feedback_sentence, verbose)
else:
speech.speak('Sorry, I am unable to help you schedule this right now.', verbose)
开发者ID:WarriorIng64,项目名称:LTUAssistant,代码行数:12,代码来源:assistantdb.py
示例14: saveBookmarks
def saveBookmarks(self, inputEvent):
""" Save the bookmarks for this script. """
try:
self._saveBookmarksToDisk(self._bookmarks)
# Translators: this announces that a bookmark has been saved to
# disk
#
speech.speak(_('bookmarks saved'))
except IOError:
# Translators: this announces that a bookmark could not be saved to
# disk
#
speech.speak(_('bookmarks could not be saved'))
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:13,代码来源:bookmarks.py
示例15: help
def help(self, event):
help_string = _(
"""
To move around the board use the arrow keys.
To put a number on a square use numbers from 1 to 9.
To clear a square use the 0 key. A square can only be cleared if it was blank on the original puzzle.
To speak the current square position on the board use the p key.
To know how many squares are still blank press b.
To speak what possibilities exist for the current square press s.
To quit the game press the q key.
"""
)
speech.speak(help_string)
开发者ID:ragb,项目名称:sudoaudio,代码行数:13,代码来源:game.py
示例16: shutdown
def shutdown(script=None, inputEvent=None):
"""Exits Orca. Unregisters any event listeners and cleans up. Also
quits the bonobo main loop and resets the initialized state to False.
Returns True if the shutdown procedure ran or False if this module
was never initialized.
"""
global _initialized
if not _initialized:
return False
# Try to say goodbye, but be defensive if something has hung.
#
if settings.timeoutCallback and (settings.timeoutTime > 0):
signal.signal(signal.SIGALRM, settings.timeoutCallback)
signal.alarm(settings.timeoutTime)
# Translators: this is what Orca speaks and brailles when it quits.
#
speech.speak(_("Goodbye."))
braille.displayMessage(_("Goodbye."))
# Deregister our event listeners
#
registry = atspi.Registry()
registry.deregisterEventListener(_onChildrenChanged,
"object:children-changed:")
registry.deregisterEventListener(_onMouseButton,
"mouse:button")
if _currentPresentationManager >= 0:
_PRESENTATION_MANAGERS[_currentPresentationManager].deactivate()
# Shutdown all the other support.
#
if settings.enableSpeech:
speech.shutdown()
if settings.enableBraille:
braille.shutdown();
if settings.enableMagnifier:
mag.shutdown();
registry.stop()
if settings.timeoutCallback and (settings.timeoutTime > 0):
signal.alarm(0)
_initialized = False
return True
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:51,代码来源:orca.py
示例17: showPreferencesUI
def showPreferencesUI():
global applicationName, appScript
# There must be an application with focus for this to work.
#
if not orca_state.locusOfFocus or not orca_state.locusOfFocus.getApplication():
message = _("No application has focus.")
braille.displayMessage(message)
speech.speak(message)
return
appScript = orca_state.activeScript
# The name of the application that currently has focus.
#
applicationName = orca_state.activeScript.app.name
if not orca_state.appOS and not orca_state.orcaOS:
# Translators: Orca Preferences in this case, is a configuration GUI
# for allowing users to set application specific settings from within
# Orca for the application that currently has focus.
#
line = _("Starting Orca Preferences for %s.") % applicationName
appScript.presentMessage(line)
prefsDict = orca_prefs.readPreferences()
orca_state.prefsUIFile = os.path.join(
orca_platform.prefix, orca_platform.datadirname, orca_platform.package, "ui", "orca-setup.ui"
)
orca_state.appOS = OrcaSetupGUI(orca_state.prefsUIFile, "orcaSetupWindow", prefsDict)
orca_state.appOS.initAppGUIState(appScript)
orca_state.appOS.init()
else:
if not orca_state.orcaWD:
orca_state.orcaWarningDialogUIFile = os.path.join(
orca_platform.prefix,
orca_platform.datadirname,
orca_platform.package,
"ui",
"orca-preferences-warning.ui",
)
orca_state.orcaWD = WarningDialogGUI(orca_state.orcaWarningDialogUIFile, "orcaPrefsWarningDialog")
warningDialog = orca_state.orcaWD.getPrefsWarningDialog()
warningDialog.realize()
warningDialog.show()
return
orca_state.appOS.showGUI()
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:49,代码来源:app_gui_prefs.py
示例18: do_POST
def do_POST(self):
contentLength = self.headers.getheader('content-length')
if contentLength:
contentLength = int(contentLength)
inputBody = self.rfile.read(contentLength)
debug.println(debug.LEVEL_FINEST,
"httpserver._HTTPRequestHandler received %s" \
% inputBody)
if inputBody.startswith("speak:"):
speech.speak(inputBody[6:])
self.send_response(200, 'OK')
elif inputBody == "stop":
speech.stop()
self.send_response(200, 'OK')
elif inputBody == "isSpeaking":
self.send_response(200, 'OK')
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write("%s" % speech.isSpeaking())
elif inputBody.startswith("log:"):
import logging
logFile = inputBody[4:]
for logger in ['braille', 'speech']:
log = logging.getLogger(logger)
formatter = logging.Formatter('%(name)s.%(message)s')
try:
loggingFileHandlers[logger].close()
log.removeHandler(loggingFileHandlers[logger])
except:
pass
if logFile and len(logFile):
loggingFileHandlers[logger] = logging.FileHandler(
'%s.%s' % (logFile, logger), 'w')
loggingFileHandlers[logger].setFormatter(formatter)
log.addHandler(loggingFileHandlers[logger])
log.setLevel(logging.INFO)
self.send_response(200, 'OK')
elif inputBody.startswith("debug:"):
split = inputBody.split(':')
debug.debugLevel = int(split[1])
if debug.debugFile:
debug.debugFile.close()
debug.debugFile = None
if (len(split) == 3) and (len(split[2])):
debug.debugFile = open('%s.debug' % split[2], 'w', 0)
self.send_response(200, 'OK')
else:
debug.println(debug.LEVEL_FINEST,
"httpserver._HTTPRequestHandler received no data")
开发者ID:guadalinex-archive,项目名称:guadalinex-v4,代码行数:49,代码来源:httpserver.py
示例19: addBookmark
def addBookmark(self, inputEvent):
""" Add an in-page accessible object bookmark for this key. """
context = self._script.getFlatReviewContext()
self._bookmarks[inputEvent.hw_code] = self._contextToBookmark(context)
# Translators: this announces that a bookmark has been entered.
# Orca allows users to tell it to remember a particular spot in an
# application window and provides keystrokes for the user to jump to
# those spots. These spots are known as 'bookmarks'.
#
utterances = [_('bookmark entered')]
utterances.extend(
self._script.speechGenerator.generateSpeech(
context.getCurrentAccessible()))
speech.speak(utterances)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:15,代码来源:bookmarks.py
示例20: paste
def paste(location):
"""paste a file or directory that has been previously copied"""
copyData = settings.getDataFile()
if not location:
location = "."
try:
data = pickle.load(open(copyData, "rb"))
speech.speak("Pasting " + data["copyLocation"] + " to current directory.")
except:
speech.fail("It doesn't look like you've copied anything yet.")
speech.fail("Type 'hallie copy <file>' to copy a file or folder.")
return
process, error = subprocess.Popen(["cp", "-r", data["copyLocation"], location], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()
if "denied" in process:
speech.fail("Unable to paste your file successfully. This is most likely due to a permission issue. You can try to run me as sudo!")
开发者ID:mikemelch,项目名称:hallie,代码行数:15,代码来源:files.py
注:本文中的speech.speak函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论