speech
Loading...
Searching...
No Matches
speech.h
1/*
2 * Copyright (C) 2014 iCub Facility
3 * Authors: Ali Paikan
4 * CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
5 */
6
7
8#include <yarp/dev/DeviceDriver.h>
9#include <yarp/os/Thread.h>
10#include <yarp/os/Stamp.h>
11#include <yarp/os/Property.h>
12#include <yarp/os/RpcServer.h>
13#include <yarp/os/ResourceFinder.h>
14#include <yarp/dev/PolyDriver.h>
15
16#include <string>
17#include <vector>
18
19#include <Speech_IDL.h>
20
21#include <picoapi.h>
22#include <picoapid.h>
23#include <picoos.h>
24
25namespace yarp{
26 namespace dev{
27 class Speech;
28 }
29}
30
31
32
33/****************************************************************
34 * @brief The yarp::dev::Speech class
35 */
36class yarp::dev::Speech : public yarp::dev::DeviceDriver,
37 public yarp::os::Thread,
38 public Speech_IDL {
39
40public:
41 Speech();
42 ~Speech();
43
44 // Device Driver interface
45 virtual bool open(yarp::os::Searchable &config);
46 virtual bool close();
47
48 // Speech_IDL
49 virtual bool setLanguage(const std::string& language);
50 virtual std::vector<std::string> getSupportedLang();
51 virtual bool say(const std::string& text);
52 virtual bool setSpeed(const int16_t speed);
53 virtual bool setPitch(const int16_t pitch);
54 virtual int16_t getSpeed();
55 virtual int16_t getPitch();
56 virtual bool play();
57 virtual bool pause();
58 virtual bool stop();
59
60private:
61 virtual bool threadInit();
62 virtual void run();
63 virtual void threadRelease();
64
65private:
71 const std::string renderSpeech(const std::string& text);
72 bool playWav(const std::string& filename);
73 void releasePico();
74private:
75 yarp::os::Property config;
76 yarp::os::RpcServer rpcPort;
77 std::string language;
78 std::string pcmDevice;
79 int pitch, speed;
80 std::vector<std::string> supportedLangs;
81
82private: // picotts
83 /* adapation layer global variables */
84 void * picoMemArea;
85 pico_System picoSystem;
86 pico_Resource picoTaResource;
87 pico_Resource picoSgResource;
88 pico_Resource picoUtppResource;
89 pico_Engine picoEngine;
90 pico_Char * picoTaFileName;
91 pico_Char * picoSgFileName;
92 pico_Char * picoUtppFileName;
93 pico_Char * picoTaResourceName;
94 pico_Char * picoSgResourceName;
95 pico_Char * picoUtppResourceName;
96 int picoSynthAbort;
97 yarp::os::ResourceFinder lingwareRF;
98};
Speech_IDL.
Definition Speech_IDL.h:16
virtual bool say(const std::string &text)
render and play the speech
virtual std::vector< std::string > getSupportedLang()
get the available languages
virtual int16_t getPitch()
get the speech pitch
virtual int16_t getSpeed()
get the speech speed
virtual bool setPitch(const int16_t pitch)
set the speech pitch
virtual bool play()
play the previously rendered or paused speech
virtual bool setLanguage(const std::string &language)
set the speech langauge
virtual bool stop()
stop playing the current speech
virtual bool setSpeed(const int16_t speed)
set the speech speed
virtual bool pause()
pause the current speech