示例#1
0
class TestSpeakerWithSay(TestCase):
    def setUp(self):
        self.speaker = Speaker(service='say')

    def test_create(self):
        self.assertIsInstance(self.speaker, Speaker)

    @patch('os.system')
    def test_speak(self, mock_os):
        text = 'Text for testing with say'
        self.speaker.speak(text)
        mock_os.assert_has_calls([call("say '{text}'".format(text=text))])
示例#2
0
 def __init__(self, listener=None, speaker=None):
     self.__listener = listener or Listener(
         service='sphinx')  # sphinx | google
     self.__speaker = speaker or Speaker(service='say')  # say | espeak
示例#3
0
 def setUp(self):
     self.speaker = Speaker(service='say')
示例#4
0
    def test_create(self):
        with self.assertRaises(NotImplementedError) as context:
            Speaker()

        self.assertIn('No available text to speech service chosen.',
                      str(context.exception))
示例#5
0
 def setUp(self):
     self.speaker = Speaker(service='espeak')