Coverage Report - orca.acss

ModuleCoverage %
orca.acss
75%
1
# Orca
2
#
3
# Copyright 2005-2007 Google Inc.
4
# Portions Copyright 2007, Sun Microsystems, Inc.
5
#
6
# This library is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU Library General Public
8
# License as published by the Free Software Foundation; either
9
# version 2 of the License, or (at your option) any later version.
10
#
11
# This library is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# Library General Public License for more details.
15
#
16
# You should have received a copy of the GNU Library General Public
17
# License along with this library; if not, write to the
18
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
# Boston, MA 02111-1307, USA.
20
#
21
"""ACSS --- Aural CSS.
22
23
Class ACSS defines a simple wrapper for holding ACSS voice
24
definitions.  Speech engines implement the code for converting
25
ACSS definitions into engine-specific markup codes.
26
27 1
"""
28
29 1
__id__ = "$Id: acss.py 2233 2007-04-02 17:45:02Z wwalker $"
30 1
__author__ = "T. V. Raman"
31 1
__version__ = "$Revision: 2233 $"
32 1
__date__ = "$Date: 2007-04-02 13:45:02 -0400 (Mon, 02 Apr 2007) $"
33 1
__copyright__ = "Copyright (c) 2005-2007 Google Inc."
34 1
__license__ = "LGPL"
35
36 2
class ACSS(dict):
37
38 1
    """Holds ACSS representation of a voice."""
39
40 1
    FAMILY        = 'family'
41 1
    RATE          = 'rate'
42 1
    GAIN          = 'gain'
43 1
    AVERAGE_PITCH = 'average-pitch'
44 1
    PITCH_RANGE   = 'pitch-range'
45 1
    STRESS        = 'stress'
46 1
    RICHNESS      = 'richness'
47 1
    PUNCTUATIONS  = 'punctuations'
48
49
    # A value of None means use the engine's default value.
50
    #
51 1
    settings = {
52 1
        FAMILY :        None,
53 1
        RATE :          50,
54 1
        GAIN :          5,
55 1
        AVERAGE_PITCH : 5,
56 1
        PITCH_RANGE :   5,
57 1
        STRESS :        5,
58 1
        RICHNESS :      5,
59 1
        PUNCTUATIONS :  'all'
60
    }
61
62 1
    def __init__(self,props={}):
63
        """Create and initialize ACSS structure."""
64 4
        for k in props:
65 1
            if k in ACSS.settings:
66
                # Do a 'deep copy' of the family.  Otherwise,
67
                # the new ACSS shares the actual data with the
68
                # props passed in.  This can cause unexpected
69
                # side effects.
70
                #
71 1
                if k == ACSS.FAMILY:
72 0
                    self[k] = {}
73 0
                    for j in props[k].keys():
74 0
                        self[k][j] = props[k][j]
75
                else:
76 1
                    self[k] = props[k]
77
78 1
    def __setitem__ (self, key, value):
79
        """Update name when we change values."""
80 1
        dict.__setitem__(self, key, value)
81
82 1
    def __delitem__(self, key):
83
        """Update name if we delete a key."""
84 0
        dict.__delitem__(self,key)
85
86 1
    def updateName(self):
87
        """Update name based on settings."""
88
89 1
    def name(self):
90 0
        _name='acss-'
91 0
        names = self.keys()
92 0
        if names:
93 0
            names.sort()
94 0
            for  k in names:
95 0
                _name += "%s-%s:" % (k, self[k])
96 0
        self._name = _name[:-1]
97 0
        return self._name