def init Found at: pyttsx.__init__def init(driverName=None, debug=False):'''Constructs a new TTS engine instance or reuses the existing instance forthe driver name.@param driverName: Name of the platform specific driver to use. IfNone, selects the default driver for the operating system.@type: str@param debug: Debugging output enabled or not@type debug: bool@return: Engine instance@rtype: L{engine.Engine}'''try:eng = _activeEngines[driverName]except KeyError:eng = Engine(driverName, debug)_activeEngines[driverName] = engreturn engclass WeakValueDictionary(collections.MutableMapping):"""Mapping class that references values weakly.Entries in the dictionary will be discarded when no strongreference to the value exists anymore"""# We inherit the constructor without worrying about the input# dictionary; since it uses our .update() method, we get the right# checks (if the other dictionary is a WeakValueDictionary,# objects are unwrapped on the way out, and we always wrap on the# way in).def __init__(*args, **kw):if not args:raise TypeError("descriptor '__init__' of 'WeakValueDictionary' ""object needs an argument")self, *args = argsif len(args) > 1:raise TypeError('expected at most 1 arguments, got %d' % len(args))def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):self = selfref()if self is not None:if self._iterating:self._pending_removals.append(wr.key)else:# Atomic removal is necessary since this function# can be called asynchronously by the GC_atomic_removal(d, wr.key)self._remove = remove# A list of keys to be removedself._pending_removals = []self._iterating = set()self.data = d = {}self.update(*args, **kw)def _commit_removals(self):l = self._pending_removalsd = self.data# We shouldn't encounter any KeyError, because this method should# always be called *before* mutating the dict.while l:key = l.pop()_remove_dead_weakref(d, key)def __getitem__(self, key):if self._pending_removals:self._commit_removals()o = self.data[key]()if o is None:raise KeyError(key)else:return odef __delitem__(self, key):if self._pending_removals:self._commit_removals()del self.data[key]def __len__(self):if self._pending_removals:self._commit_removals()return len(self.data)def __contains__(self, key):if self._pending_removals:self._commit_removals()try:o = self.data[key]()except KeyError:return Falsereturn o is not Nonedef __repr__(self):return "<%s at %#x>" % (self.__class__.__name__, id(self))def __setitem__(self, key, value):if self._pending_removals:self._commit_removals()self.data[key] = KeyedRef(value, self._remove, key)def copy(self):if self._pending_removals:self._commit_removals()new = WeakValueDictionary()for key, wr in self.data.items():o = wr()if o is not None:new[key] = oreturn new__copy__ = copydef __deepcopy__(self, memo):from copy import deepcopyif self._pending_removals:self._commit_removals()new = self.__class__()for key, wr in self.data.items():o = wr()if o is not None:new[deepcopy(key, memo)] = oreturn newdef get(self, key, default=None):if self._pending_removals:self._commit_removals()try:wr = self.data[key]except KeyError:return defaultelse:o = wr()if o is None:# This should only happenreturn defaultelse:return odef items(self):if self._pending_removals:self._commit_removals()with _IterationGuard(self):for k, wr in self.data.items():v = wr()if v is not None:yield k, vdef keys(self):if self._pending_removals:self._commit_removals()with _IterationGuard(self):for k, wr in self.data.items():if wr() is not None:yield k__iter__ = keysdef itervaluerefs(self):"""Return an iterator that yields the weak references to the values.The references are not guaranteed to be 'live' at the timethey are used, so the result of calling the references needsto be checked before being used. This can be used to avoidcreating references that will cause the garbage collector tokeep the values around longer than needed."""if self._pending_removals:self._commit_removals()with _IterationGuard(self):yield from self.data.values()def values(self):if self._pending_removals:self._commit_removals()with _IterationGuard(self):for wr in self.data.values():obj = wr()if obj is not None:yield objdef popitem(self):if self._pending_removals:self._commit_removals()while True:key, wr = self.data.popitem()o = wr()if o is not None:return key, odef pop(self, key, *args):if self._pending_removals:self._commit_removals()try:o = self.data.pop(key)()except KeyError:o = Noneif o is None:if args:return args[0]else:raise KeyError(key)else:return odef setdefault(self, key, default=None):try:o = self.data[key]()except KeyError:o = Noneif o is None:if self._pending_removals:self._commit_removals()self.data[key] = KeyedRef(default, self._remove, key)return defaultelse:return odef update(*args, **kwargs):if not args:raise TypeError("descriptor 'update' of 'WeakValueDictionary' ""object needs an argument")self, *args = argsif len(args) > 1:raise TypeError('expected at most 1 arguments, got %d' % len(args))dict = args[0] if args else Noneif self._pending_removals:self._commit_removals()d = self.dataif dict is not None:if not hasattr(dict, "items"):dict = type({})(dict)for key, o in dict.items():d[key] = KeyedRef(o, self._remove, key)if len(kwargs):self.update(kwargs)def valuerefs(self):"""Return a list of weak references to the values.The references are not guaranteed to be 'live' at the timethey are used, so the result of calling the references needsto be checked before being used. This can be used to avoidcreating references that will cause the garbage collector tokeep the values around longer than needed."""if self._pending_removals:self._commit_removals()return list(self.data.values())