source: rrlib_speech_synthesis/test/test_voices.cpp @ 10:6754b7b7f17b

13.10
Last change on this file since 10:6754b7b7f17b was 10:6754b7b7f17b, checked in by Michael Arndt <m_arndt@…>, 7 years ago

Add #ifdefs to be able to run the test_voices program if not all backends are available.

File size: 3.7 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    rrlib/speech_synthesis/test/test_voices.cpp
23 *
24 * \author  Tobias Föhst
25 *
26 * \date    2013-07-15
27 *
28 */
29//----------------------------------------------------------------------
30
31//----------------------------------------------------------------------
32// External includes (system with <>, local with "")
33//----------------------------------------------------------------------
34
35#include <string>
36#include <thread>
37#include <unistd.h>
38
39//----------------------------------------------------------------------
40// Internal includes with ""
41//----------------------------------------------------------------------
42#include "rrlib/speech_synthesis/voices.h"
43
44//----------------------------------------------------------------------
45// Debugging
46//----------------------------------------------------------------------
47#include <cassert>
48
49//----------------------------------------------------------------------
50// Namespace usage
51//----------------------------------------------------------------------
52
53//----------------------------------------------------------------------
54// Forward declarations / typedefs / enums
55//----------------------------------------------------------------------
56
57//----------------------------------------------------------------------
58// Const values
59//----------------------------------------------------------------------
60
61//----------------------------------------------------------------------
62// Implementation
63//----------------------------------------------------------------------
64
65
66void Run()
67{
68#ifdef _LIB_RRLIB_SPEECH_SYNTHESIS_ESPEAK_PRESENT_
69  rrlib::speech_synthesis::tVoice *espeak_default = rrlib::speech_synthesis::tVoiceFactory::Instance().Create("espeak", "default");
70  for (unsigned int i = 1; i < 10; ++i)
71  {
72    std::string text = "Speaking from thread 2: line number " + std::to_string(i);
73    espeak_default->Say(text);
74    sleep(1);
75  }
76#endif
77}
78
79
80int main(int argc, char* argv[])
81{
82
83#ifdef _LIB_RRLIB_SPEECH_SYNTHESIS_FESTIVAL_PRESENT_
84  rrlib::speech_synthesis::tVoice *festival_kal = rrlib::speech_synthesis::tVoiceFactory::Instance().Create("festival", "kal_diphone");
85  rrlib::speech_synthesis::tVoice *festival_don = rrlib::speech_synthesis::tVoiceFactory::Instance().Create("festival", "don_diphone");
86#endif
87#ifdef _LIB_RRLIB_SPEECH_SYNTHESIS_ESPEAK_PRESENT_
88  rrlib::speech_synthesis::tVoice *espeak_mb_en1 = rrlib::speech_synthesis::tVoiceFactory::Instance().Create("espeak", "mb-en1");
89#endif
90
91  std::thread thread2(Run);
92
93  for (unsigned int i = 1; i < 10; ++i)
94  {
95    std::string text = "Speaking from thread 1: line number " + std::to_string(i);
96#ifdef _LIB_RRLIB_SPEECH_SYNTHESIS_FESTIVAL_PRESENT_
97    festival_kal->Say(text);
98    festival_don->Say(text);
99#endif
100#ifdef _LIB_RRLIB_SPEECH_SYNTHESIS_ESPEAK_PRESENT_
101    espeak_mb_en1->Say(text);
102#endif
103    sleep(1);
104  }
105
106  thread2.join();
107
108  sleep(30);
109
110  return 0;
111}
Note: See TracBrowser for help on using the repository browser.