~ubuntu-branches/ubuntu/trusty/speech-dispatcher/trusty-proposed

« back to all changes in this revision

Viewing changes to src/python/speechd/_test.py

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich, Samuel Thibault, Luke Yelavich, Jason White, David Henningsson
  • Date: 2013-11-11 16:38:46 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20131111163846-lvu37ypp5sy9z5so
Tags: 0.8-0ubuntu1
[ Samuel Thibault ]
* debian/control: Set libspeechd2 multi-arch: same.
* debian/rules: Set multiarch libdir.
* debian/libspeechd-dev.install,libspeechd2.install,
  speech-dispatcher.install: Use multiarch libdir.
* Do not depend on dpkg | install-info, now that we use the install-info
  trigger.
* Bump Standards-Version to 3.9.5.
* Bump dotconf dependency to >= 1.3.

[ Luke Yelavich ]
* New upstream release
* debian/patches/infinite-loop.patch: Refreshed
* Dropped patches:
  - debian/patches/build-doc.patch
  - debian/patches/procname.patch
  - debian/patches/paths+files.patch
  - debian/patches/pthread.patch
* Add libltdl-dev and intltool to build-depends
* Update packaging for speech-dispatcher python 3 bindings.
* Move speech-dispatcher modules to an architecture independant dir, since
  modules can be written in any language, and i386 only modules can be
  used on amd64 systems
* Create separate audio plugins package
* Convert to debhelper 7+ packaging.
* Use dh-autoreconf to handle autotools file rebuilds.
* Update standards version to 3.9.3.
* Add X-Python-Version related fields to debian/control.
* Patch in the speech-dispatcher-cs.texi file since it was forgotten in the
  0.8 tarball
* Add translations to speech-dispatcher
* Merge from debian unreleased git.  Remaining changes:
  - Moved the flite output module to a separate package, and added
    it to suggests, we don't want flite on the Ubuntu CD image
  - Don't build depend on libaudio-dev or libao-dev, Ubuntu CD size is an
    issue, every little bit helps
  - debian/gbp.conf: Adjust for the Ubuntu git branch
  - Python3-speechd needs to conflict against python-speechd

[ Jason White ]
* Raise level of subsection in fdl.texi to correct document structure.

[ David Henningsson ]
* debian/patches/pulse-default-latency.patch:
  Default to 20 ms latency instead of 1 ms latency (LP: #1208826)

[ Luke Yelavich ]
* spd_audio: Expose dlopened library's symbols to libs it loads. Thanks to
  Christopher Brannon <chris@the-brannons.com> for the patch, taken from
  the speech-dispatcher mailing list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
# Copyright (C) 2003, 2006, 2007 Brailcom, o.p.s.
4
 
#
5
 
# This program is free software; you can redistribute it and/or modify
6
 
# it under the terms of the GNU General Public Licensex1 as published by
7
 
# the Free Software Foundation; either version 2 of the License, or
8
 
# (at your option) any later version.
9
 
#
10
 
# This program is distributed in the hope that it will be useful,
11
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
# GNU General Public License for more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License
16
 
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 
19
 
import unittest
20
 
import time
21
 
 
22
 
from .client import PunctuationMode, CallbackType, SSIPClient, Scope, Speaker
23
 
 
24
 
 
25
 
class _SSIPClientTest(unittest.TestCase):
26
 
        
27
 
    def setUp(self):
28
 
        self._client = SSIPClient('test')
29
 
        self._client.set_language('en')
30
 
        self._client.set_rate(30)
31
 
 
32
 
    def tearDown(self):
33
 
        self._client.close()
34
 
 
35
 
class AutomaticTest(_SSIPClientTest):
36
 
    """A set of tests which may be evaluated automatically.
37
 
 
38
 
    Please put all tests which require a user to listen to their output to the
39
 
    VoiceTest below.
40
 
 
41
 
    """
42
 
    def test_callbacks(self):
43
 
        # TODO: This needs to be fixed. There is no guarantee that
44
 
        # the message will start in one second nor is there any
45
 
        # guarantee that it will start at all. It can be interrupted
46
 
        # by other applications etc. Also there is no guarantee that
47
 
        # the cancel will arrive on time and the end callback will be
48
 
        # received on time. Also the combination cancel/end does not have
49
 
        # to work as expected and SD and the interface can still be ok.
50
 
        # -- Hynek Hanke
51
 
        self._client.set_output_module('flite')
52
 
        called = {CallbackType.BEGIN: [],
53
 
                  CallbackType.CANCEL: [],
54
 
                  CallbackType.END: []}
55
 
        self._client.speak("This message should get interrupted.  It is "
56
 
                           "hopefully long enough to last more than 1 second.",
57
 
                           callback=lambda type: called[type].append('msg1'))
58
 
        self._client.speak("This second message should not be spoken at all.",
59
 
                           callback=lambda type: called[type].append('msg2'))
60
 
        time.sleep(1)
61
 
        self._client.cancel()
62
 
        self._client.speak("Hi.",
63
 
                           callback=lambda type: called[type].append('msg3'))
64
 
        # Wait for pending events...
65
 
        time.sleep(3)
66
 
        started, canceled, ended = [called[t] for t in (CallbackType.BEGIN,
67
 
                                                        CallbackType.CANCEL,
68
 
                                                        CallbackType.END)]
69
 
        assert started == ['msg1', 'msg3'] and ended == ['msg3'] and \
70
 
               'msg1' in canceled and 'msg2' in canceled and \
71
 
               'msg3' not in canceled, \
72
 
               (called,
73
 
                "This failure only indicates a possible error.  The test "
74
 
                "depends on proper timing and results may warry depending "
75
 
                "on the used output module and other conditions.  See the "
76
 
                "code of this test method if you want to investigate "
77
 
                "further.")
78
 
 
79
 
    
80
 
 
81
 
class VoiceTest(_SSIPClientTest):
82
 
    """This set of tests requires a user to listen to it.
83
 
 
84
 
    The success or failure of the tests defined here can not be detected
85
 
    automatically.
86
 
 
87
 
    """
88
 
    
89
 
    def test_escapes(self):
90
 
        c = self._client
91
 
        c.speak("Testing data escapes:")
92
 
        c.set_punctuation(PunctuationMode.ALL)
93
 
        c.speak(".")
94
 
        c.speak("Marker at the end.\r\n.\r\n")
95
 
        c.speak(".\r\nMarker at the beginning.")
96
 
    
97
 
    def test_voice_properties(self):
98
 
        c = self._client
99
 
        c.speak("Testing voice properties:")
100
 
        c.set_pitch(-100)
101
 
        c.speak("I am fat Billy")
102
 
        c.set_pitch(100)
103
 
        c.speak("I am slim Willy")
104
 
        c.set_pitch(0)
105
 
        c.set_rate(100)
106
 
        c.speak("I am quick Dick.")
107
 
        c.set_rate(-80)
108
 
        c.speak("I am slow Joe.")
109
 
        c.set_rate(0)
110
 
        c.set_pitch(100)
111
 
        c.set_volume(-50)
112
 
        c.speak("I am quiet Mariette.")
113
 
        c.set_volume(100)
114
 
        c.speak("I am noisy Daisy.")
115
 
 
116
 
    def test_other_commands(self):
117
 
        c = self._client
118
 
        c.speak("Testing other commands:")
119
 
        c.char("a")
120
 
        c.key("shift_b")
121
 
        c.sound_icon("empty")
122
 
        
123
 
    def test_lists(self):
124
 
         c = self._client
125
 
         for module in  c.list_output_modules():
126
 
             c.set_output_module(module)
127
 
             print("**", module)
128
 
             c.speak(module +"using default voice")
129
 
             for name, lang, dialect in c.list_synthesis_voices():
130
 
                 print(" -", module, name, lang, dialect)
131
 
                 c.set_synthesis_voice(name)
132
 
                 c.speak(module +" using voice "+ name)
133
 
        
134
 
 
135
 
if __name__ == '__main__':
136
 
    unittest.main()