Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion rumps/rumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

from Foundation import (NSDate, NSTimer, NSRunLoop, NSDefaultRunLoopMode, NSSearchPathForDirectoriesInDomains,
NSMakeRect, NSLog, NSObject)
from AppKit import NSApplication, NSStatusBar, NSMenu, NSMenuItem, NSAlert, NSTextField, NSSecureTextField, NSImage
from AppKit import (NSApplication, NSStatusBar, NSMenu, NSMenuItem, NSAlert, NSTextField, NSSecureTextField, NSImage,
NSSpeechSynthesizer)
from PyObjCTools import AppHelper

import inspect
Expand All @@ -46,9 +47,28 @@ def _log(*args):
else:
def _log(*_):
pass


debug_mode(False)


class SpeechSynthesizer:
"""Wrapper for Objective-C's NSSpeechSynthesizer class.

Implements core functionality of speech in rumps.
"""
def __init__(self, message):
self.synth = NSSpeechSynthesizer.alloc().initWithVoice_(None)
self.synth.startSpeakingString_(message)

def stop(self):
"""
Stops the current speech, if speaking.
"""
if self.synth.speaking:
self.synth.stopSpeaking()


def alert(title=None, message='', ok=None, cancel=None, other=None, icon_path=None):
"""Generate a simple alert window.

Expand Down