This file is indexed.

/usr/lib/python3/dist-packages/speechd/_test.py is in python3-speechd 0.8-7.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python

# Copyright (C) 2003, 2006, 2007 Brailcom, o.p.s.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public Licensex1 as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import unittest
import time

from .client import PunctuationMode, CallbackType, SSIPClient, Scope, Speaker


class _SSIPClientTest(unittest.TestCase):
        
    def setUp(self):
        self._client = SSIPClient('test')
        self._client.set_language('en')
        self._client.set_rate(30)

    def tearDown(self):
        self._client.close()

class AutomaticTest(_SSIPClientTest):
    """A set of tests which may be evaluated automatically.

    Please put all tests which require a user to listen to their output to the
    VoiceTest below.

    """
    def test_callbacks(self):
        # TODO: This needs to be fixed. There is no guarantee that
        # the message will start in one second nor is there any
        # guarantee that it will start at all. It can be interrupted
        # by other applications etc. Also there is no guarantee that
        # the cancel will arrive on time and the end callback will be
        # received on time. Also the combination cancel/end does not have
        # to work as expected and SD and the interface can still be ok.
        # -- Hynek Hanke
        self._client.set_output_module('flite')
        called = {CallbackType.BEGIN: [],
                  CallbackType.CANCEL: [],
                  CallbackType.END: []}
        self._client.speak("This message should get interrupted.  It is "
                           "hopefully long enough to last more than 1 second.",
                           callback=lambda type: called[type].append('msg1'))
        self._client.speak("This second message should not be spoken at all.",
                           callback=lambda type: called[type].append('msg2'))
        time.sleep(1)
        self._client.cancel()
        self._client.speak("Hi.",
                           callback=lambda type: called[type].append('msg3'))
        # Wait for pending events...
        time.sleep(3)
        started, canceled, ended = [called[t] for t in (CallbackType.BEGIN,
                                                        CallbackType.CANCEL,
                                                        CallbackType.END)]
        assert started == ['msg1', 'msg3'] and ended == ['msg3'] and \
               'msg1' in canceled and 'msg2' in canceled and \
               'msg3' not in canceled, \
               (called,
                "This failure only indicates a possible error.  The test "
                "depends on proper timing and results may warry depending "
                "on the used output module and other conditions.  See the "
                "code of this test method if you want to investigate "
                "further.")

    

class VoiceTest(_SSIPClientTest):
    """This set of tests requires a user to listen to it.

    The success or failure of the tests defined here can not be detected
    automatically.

    """
    
    def test_escapes(self):
        c = self._client
        c.speak("Testing data escapes:")
        c.set_punctuation(PunctuationMode.ALL)
        c.speak(".")
        c.speak("Marker at the end.\r\n.\r\n")
        c.speak(".\r\nMarker at the beginning.")
    
    def test_voice_properties(self):
        c = self._client
        c.speak("Testing voice properties:")
        c.set_pitch(-100)
        c.speak("I am fat Billy")
        c.set_pitch(100)
        c.speak("I am slim Willy")
        c.set_pitch(0)
        c.set_rate(100)
        c.speak("I am quick Dick.")
        c.set_rate(-80)
        c.speak("I am slow Joe.")
        c.set_rate(0)
        c.set_pitch(100)
        c.set_volume(-50)
        c.speak("I am quiet Mariette.")
        c.set_volume(100)
        c.speak("I am noisy Daisy.")

    def test_other_commands(self):
        c = self._client
        c.speak("Testing other commands:")
        c.char("a")
        c.key("shift_b")
        c.sound_icon("empty")
        
    def test_lists(self):
         c = self._client
         for module in  c.list_output_modules():
             c.set_output_module(module)
             print("**", module)
             c.speak(module +"using default voice")
             for name, lang, dialect in c.list_synthesis_voices():
                 print(" -", module, name, lang, dialect)
                 c.set_synthesis_voice(name)
                 c.speak(module +" using voice "+ name)
        

if __name__ == '__main__':
    unittest.main()