test_aques_talk.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 from __future__ import print_function
5 import os
6 import subprocess
7 import sys
8 import tempfile
9 import unittest
10 import rospy
11 
12 
13 class TestAquestalk(unittest.TestCase):
14 
15  def assertIsFile(self, path):
16  # https://stackoverflow.com/questions/59121161/python-unittest-how-to-assert-the-existence-of-a-file-or-folder-and-print-the-p
17  if not os.path.exists(path):
18  raise AssertionError("File does not exist: %s" % str(path))
19 
20  def test_text2wave(self):
21  input_file = '/tmp/hello.txt'
22  output_file = os.path.join(tempfile.mkdtemp(), 'hello.wav')
23  with open(input_file, 'w') as f:
24  f.write('Hello World!')
25  cmd = "rosrun aques_talk text2wave -o %s %s" % (output_file, input_file)
26  print("EXECUTING: ", cmd, file=sys.stderr)
27  output = ''
28  status = 0
29  try:
30  output = subprocess.check_output(cmd, shell=True)
31  except subprocess.CalledProcessError as e:
32  status = e.returncode
33  print("AQUESTALK STATUS: %d, OUTPUT: %s" % (status, output), file=sys.stderr)
34  self.assertEqual(status, 0)
35 
36  # check output file
37  self.assertIsFile(output_file)
38 
39 
40 if __name__ == '__main__':
41  import rostest
42  rostest.rosrun("aquestalk", "test_aquestalk", TestAquestalk)


aques_talk
Author(s): AQUEST Corp, ROS package maintained by Kei Okada
autogenerated on Sat Jun 24 2023 02:40:10