summaryrefslogtreecommitdiffstats
path: root/kttsd/kttsd/kttsd.cpp
blob: ce7757e7de90678f29228c82f6676727535fddce (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
/***************************************************** vim:set ts=4 sw=4 sts=4:
  KTTSD main class
  -------------------
  Copyright:
  (C) 2002-2003 by José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org>
  (C) 2003-2004 by Olaf Schmidt <ojschmidt@kde.org>
  (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
  -------------------
  Original author: José Pablo Ezequiel "Pupeno" Fernández
  Current Maintainer: Gary Cramblitt <garycramblitt@comcast.net>
 ******************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; version 2 of the License.               *
 *                                                                         *
 ***************************************************************************/

// TQt includes.
#include <tqcstring.h>
#include <tqclipboard.h>
#include <tqtextstream.h>
#include <tqtextcodec.h>
#include <tqfile.h>

// KDE includes.
#include <kdebug.h>
#include <kapplication.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kfiledialog.h>
#include <dcopclient.h>
#include <knotifyclient.h>
#include <krun.h>
#include <kaboutdata.h>

// KTTS includes.
#include "notify.h"
#include "kttsd.h"

/**
* This is the "main" module of KTTSD.  It performs the following functions:
* - Creates and destroys SpeechData and Speaker objects.
* - Receives DCOP calls and dispatches them to SpeechData and Speaker.
* - Receives signals from SpeechData and Speaker and converts them to DCOP signals.
*
* Note that most of the real tts work occurs in Speaker.
*/

KTTSD::KTTSD(const TQCString& objId, TQObject *parent, const char *name) :
    DCOPObject(objId),
    TQObject(parent, name)
{
    // kdDebug() << "KTTSD::KTTSD Running" << endl;
    m_speaker = 0;
    m_talkerMgr = 0;
    m_speechData = 0;
    ready();
}

/*
* Create and initialize the SpeechData object.
*/
bool KTTSD::initializeSpeechData()
{
    // Create speechData object.
    if (!m_speechData)
    {
        m_speechData = new SpeechData();
        connect (m_speechData, TQT_SIGNAL(textSet(const TQCString&, const uint)), 
            this, TQT_SLOT(slotTextSet(const TQCString&, const uint)));
        connect (m_speechData, TQT_SIGNAL(textAppended(const TQCString&, const uint, const int)),
            this, TQT_SLOT(slotTextAppended(const TQCString&, const uint, const int)));
        connect (m_speechData, TQT_SIGNAL(textRemoved(const TQCString&, const uint)), 
            this, TQT_SLOT(slotTextRemoved(const TQCString&, const uint)));

        // Hook KNotify signal.
        if (!connectDCOPSignal(0, 0, 
            "notifySignal(TQString,TQString,TQString,TQString,TQString,int,int,int,int)",
            "notificationSignal(TQString,TQString,TQString,TQString,TQString,int,int,int,int)",
            false)) kdDebug() << "KTTSD:initializeSpeechData: connectDCOPSignal for knotify failed" << endl;
    }
    // Load configuration.
    m_speechData->readConfig();

    return true;
}

/*
* Create and initialize the TalkerMgr object.
*/
bool KTTSD::initializeTalkerMgr()
{
    if (!m_talkerMgr)
    {
        if (!m_speechData) initializeSpeechData();

        m_talkerMgr = new TalkerMgr(this, "kttsdtalkermgr");
        int load = m_talkerMgr->loadPlugIns(m_speechData->config);
        // If no Talkers configured, try to autoconfigure one, first in the user's
        // desktop language, but if that fails, fallback to English.
        if (load < 0)
        {
            TQString languageCode = KGlobal::locale()->language();
            if (m_talkerMgr->autoconfigureTalker(languageCode, m_speechData->config))
                load = m_talkerMgr->loadPlugIns(m_speechData->config);
            else
            {
                if (m_talkerMgr->autoconfigureTalker("en", m_speechData->config))
                    load = m_talkerMgr->loadPlugIns(m_speechData->config);
            }
        }
        if (load < 0)
        {
            // TODO: Would really like to eliminate ALL GUI stuff from kttsd.  Find
            // a better way to do this.
            delete m_speaker;
            m_speaker = 0;
            delete m_talkerMgr;
            m_talkerMgr = 0;
            delete m_speechData;
            m_speechData = 0;
            kdDebug() << "KTTSD::initializeTalkerMgr: no Talkers have been configured." << endl;
            // Ask if user would like to run configuration dialog, but don't bug user unnecessarily.
            TQString dontAskConfigureKTTS = "DontAskConfigureKTTS";
            KMessageBox::ButtonCode msgResult;
            if (KMessageBox::shouldBeShownYesNo(dontAskConfigureKTTS, msgResult))
            {
                if (KMessageBox::questionYesNo(
                    0,
                    i18n("KTTS has not yet been configured.  At least one Talker must be configured.  "
                        "Would you like to configure it now?"),
                    i18n("KTTS Not Configured"),
                    i18n("Configure"),
                    i18n("Do Not Configure"),
                    dontAskConfigureKTTS) == KMessageBox::Yes) msgResult = KMessageBox::Yes;
            }
            if (msgResult == KMessageBox::Yes) showDialog();
            return false;
        }
    }
    m_speechData->setTalkerMgr(m_talkerMgr);
    return true;
}

/*
* Create and initialize the Speaker object.
*/
bool KTTSD::initializeSpeaker()
{
    // kdDebug() << "KTTSD::initializeSpeaker: Instantiating Speaker" << endl;

    if (!m_talkerMgr) initializeTalkerMgr();

    // Create speaker object and load plug ins, checking for the return
    m_speaker = new Speaker(m_speechData, m_talkerMgr);
    connect (m_speaker, TQT_SIGNAL(textStarted(const TQCString&, const uint)), 
        this, TQT_SLOT(slotTextStarted(const TQCString&, const uint)));
    connect (m_speaker, TQT_SIGNAL(textFinished(const TQCString&, const uint)), 
        this, TQT_SLOT(slotTextFinished(const TQCString&, const uint)));
    connect (m_speaker, TQT_SIGNAL(textResumed(const TQCString&, const uint)), 
        this, TQT_SLOT(slotTextResumed(const TQCString&, const uint)));
    connect (m_speaker, TQT_SIGNAL(sentenceStarted(TQString, TQString, const TQCString&, const uint, const uint)),
        this, TQT_SLOT(slotSentenceStarted(TQString, TQString, const TQCString&, const uint, const uint)));
    connect (m_speaker, TQT_SIGNAL(sentenceFinished(const TQCString&, const uint, const uint)), this,
        TQT_SLOT(slotSentenceFinished(const TQCString&, const uint, const uint)));
    connect (m_speaker, TQT_SIGNAL(textStopped(const TQCString&, const uint)), 
        this, TQT_SLOT(slotTextStopped(const TQCString&, const uint)));
    connect (m_speaker, TQT_SIGNAL(textPaused(const TQCString&, const uint)), 
        this, TQT_SLOT(slotTextPaused(const TQCString&, const uint)));

    return true;
}

/**
 * Destructor
 * Terminate speaker thread
 */
KTTSD::~KTTSD(){
    kdDebug() << "KTTSD::~KTTSD:: Stopping KTTSD service" << endl;
    if (m_speaker) m_speaker->requestExit();
    delete m_speaker;
    delete m_talkerMgr;
    delete m_speechData;
    kdDebug() << "KTTSD::~KTTSD: Emitting DCOP signal kttsdExiting()" << endl;
    kttsdExiting();
}

/***** DCOP exported functions *****/

/**
* Determine whether the currently-configured speech plugin supports a speech markup language.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
* @param markupType     The kttsd code for the desired speech markup language.
* @return               True if the plugin currently configured for the indicated
*                       talker supports the indicated speech markup language.
* @see kttsdMarkupType
*/
bool KTTSD::supportsMarkup(const TQString& talker /*=NULL*/, const uint markupType /*=0*/) const
{
    if (markupType == KSpeech::mtHtml)
    {
        if (!m_speechData) return false;
        return m_speechData->supportsHTML;
    }
    if (markupType != KSpeech::mtSsml) return false;
    if (!m_talkerMgr) return false;
    return m_talkerMgr->supportsMarkup(fixNullString(talker), markupType);
}

/**
* Determine whether the currently-configured speech plugin supports markers in speech markup.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
* @return               True if the plugin currently configured for the indicated
*                       talker supports markers.
* TODO: Waiting on plugin API.
*/
bool KTTSD::supportsMarkers(const TQString& /*talker=NULL*/) const { return false; }

/**
* Say a message as soon as possible, interrupting any other speech in progress.
* IMPORTANT: This method is reserved for use by Screen Readers and should not be used
* by any other applications.
* @param msg            The message to be spoken.
* @param talker         Code for the to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
*
* If an existing Screen Reader output is in progress, it is stopped and discarded and
* replaced with this new message.
*/
void KTTSD::sayScreenReaderOutput(const TQString &msg, const TQString &talker /*=NULL*/)
{
    if (!m_speaker) return;
    m_speechData->setScreenReaderOutput(msg, fixNullString(talker), getAppId());
    m_speaker->doUtterances();
}

/**
* Say a warning.  The warning will be spoken when the current sentence
* stops speaking and takes precedence over Messages and regular text.  Warnings should only
* be used for high-priority messages requiring immediate user attention, such as
* "WARNING. CPU is overheating."
* @param warning        The warning to be spoken.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
*/
void KTTSD::sayWarning(const TQString &warning, const TQString &talker /*=NULL*/){
    // kdDebug() << "KTTSD::sayWarning: Running" << endl;
    if (!m_speaker) return;
    kdDebug() << "KTTSD::sayWarning: Adding '" << warning << "' to warning queue." << endl;
    m_speechData->enqueueWarning(warning, fixNullString(talker), getAppId());
    m_speaker->doUtterances();
}

/**
* Say a message.  The message will be spoken when the current sentence stops speaking
* but after any warnings have been spoken.
* Messages should be used for one-shot messages that can't wait for
* normal text messages to stop speaking, such as "You have mail.".
* @param message        The message to be spoken.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
*                       If no talker has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
*/
void KTTSD::sayMessage(const TQString &message, const TQString &talker /*=NULL*/)
{
    // kdDebug() << "KTTSD::sayMessage: Running" << endl;
    if (!m_speaker) return;
    kdDebug() << "KTTSD::sayMessage: Adding '" << message << "' to message queue." << endl;
    m_speechData->enqueueMessage(message, fixNullString(talker), getAppId());
    m_speaker->doUtterances();
}

/**
* Sets the GREP pattern that will be used as the sentence delimiter.
* @param delimiter      A valid GREP pattern.
*
* The default sentence delimiter is
    @verbatim
        ([\\.\\?\\!\\:\\;])\\s
    @endverbatim
*
* Note that backward slashes must be escaped.
*
* Changing the sentence delimiter does not affect other applications.
* @see sentenceparsing
*/
void KTTSD::setSentenceDelimiter(const TQString &delimiter)
{
    if (!m_speaker) return;
    m_speechData->setSentenceDelimiter(fixNullString(delimiter), getAppId());
}

/**
* Queue a text job.  Does not start speaking the text.
* @param text           The message to be spoken.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default plugin.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
* @return               Job number.
*
* Plain text is parsed into individual sentences using the current sentence delimiter.
* Call @ref setSentenceDelimiter to change the sentence delimiter prior to calling setText.
* Call @ref getTextCount to retrieve the sentence count after calling setText.
*
* The text may contain speech mark language, such as Sable, JSML, or SMML,
* provided that the speech plugin/engine support it.  In this case,
* sentence parsing follows the semantics of the markup language.
*
* Call @ref startText to mark the job as speakable and if the
* job is the first speakable job in the queue, speaking will begin.
* @see getTextCount
* @see startText
*/
uint KTTSD::setText(const TQString &text, const TQString &talker /*=NULL*/)
{
    // kdDebug() << "KTTSD::setText: Running" << endl;
    if (!m_speaker) return 0;
    // kdDebug() << "KTTSD::setText: Setting text: '" << text << "'" << endl;
    uint jobNum = m_speechData->setText(text, fixNullString(talker), getAppId());
    return jobNum;
}

/**
* Say a plain text job.  This is a convenience method that
* combines @ref setText and @ref startText into a single call.
* @param text           The message to be spoken.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default plugin.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
* @return               Job number.
*
* Plain text is parsed into individual sentences using the current sentence delimiter.
* Call @ref setSentenceDelimiter to change the sentence delimiter prior to
* calling setText.
* Call @ref getTextCount to retrieve the sentence count after calling setText.
*
* The text may contain speech mark language, such as Sable, JSML, or SSML,
* provided that the speech plugin/engine support it.  In this case,
* sentence parsing follows the semantics of the markup language.
*
* The job is marked speakable.
* If there are other speakable jobs preceeding this one in the queue,
* those jobs continue speaking and when finished, this job will begin speaking.
* If there are no other speakable jobs preceeding this one, it begins speaking.
*
* @see getTextCount
*
* @since KDE 3.5
*/
uint KTTSD::sayText(const TQString &text, const TQString &talker)
{
    uint jobNum = setText(text, talker);
    if (jobNum) startText(jobNum);
    return jobNum;
}

/**
* Adds another part to a text job.  Does not start speaking the text.
* (thread safe)
* @param text           The message to be spoken.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application,
*                       but if no such job, applies to the last job queued by any application.
* @return               Part number for the added part.  Parts are numbered starting at 1.
*
* The text is parsed into individual sentences.  Call getTextCount to retrieve
* the sentence count.  Call startText to mark the job as speakable and if the
* job is the first speakable job in the queue, speaking will begin.
* @see setText.
* @see startText.
*/
int KTTSD::appendText(const TQString &text, const uint jobNum /*=0*/)
{
    if (!m_speaker) return 0;
    return m_speechData->appendText(text, applyDefaultJobNum(jobNum), getAppId());
}

/**
* Queue a text job from the contents of a file.  Does not start speaking the text.
* @param filename       Full path to the file to be spoken.  May be a URL.
* @param talker         Code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
* @param encoding       Name of the encoding to use when reading the file.  If
*                       NULL or Empty, uses default stream encoding.
* @return               Job number.  0 if an error occurs.
*
* Plain text is parsed into individual sentences using the current sentence delimiter.
* Call @ref setSentenceDelimiter to change the sentence delimiter prior to calling setText.
* Call @ref getTextCount to retrieve the sentence count after calling setText.
*
* The text may contain speech mark language, such as Sable, JSML, or SMML,
* provided that the speech plugin/engine support it.  In this case,
* sentence parsing follows the semantics of the markup language.
*
* Call @ref startText to mark the job as speakable and if the
* job is the first speakable job in the queue, speaking will begin.
* @see getTextCount
* @see startText
*/
uint KTTSD::setFile(const TQString &filename, const TQString &talker /*=NULL*/,
    const TQString &encoding /*=NULL*/)
{
    // kdDebug() << "KTTSD::setFile: Running" << endl;
    if (!m_speaker) return 0;
    TQFile file(filename);
    uint jobNum = 0;
    if ( file.open(IO_ReadOnly) )
    {
        TQTextStream stream(&file);
        TQString enc = fixNullString(encoding);
        if (!enc.isEmpty())
        {
            TQTextCodec* codec = TQTextCodec::codecForName(enc.latin1());
            if (codec) stream.setCodec(codec);
        }
        jobNum = m_speechData->setText(stream.read(), fixNullString(talker), getAppId());
        file.close();
    }
    return jobNum;
}

/**
* Get the number of sentences in a text job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
* @return               The number of sentences in the job.  -1 if no such job.
*
* The sentences of a job are given sequence numbers from 1 to the number returned by this
* method.  The sequence numbers are emitted in the @ref sentenceStarted and
* @ref sentenceFinished signals.
*/
int KTTSD::getTextCount(const uint jobNum /*=0*/)
{
    if (!m_speaker) return -1;
    return m_speechData->getTextCount(applyDefaultJobNum(jobNum));
}

/**
* Get the job number of the current text job.
* @return               Job number of the current text job. 0 if no jobs.
*
* Note that the current job may not be speaking. See @ref isSpeakingText.
* @see getTextJobState.
* @see isSpeakingText
*/
uint KTTSD::getCurrentTextJob()
{
    if (!m_speaker) return 0;
    return m_speaker->getCurrentTextJob();
}

/**
* Get the number of jobs in the text job queue.
* @return               Number of text jobs in the queue.  0 if none.
*/
uint KTTSD::getTextJobCount()
{
    if (!m_speaker) return 0;
    return m_speechData->getTextJobCount();
}

/**
* Get a comma-separated list of text job numbers in the queue.
* @return               Comma-separated list of text job numbers in the queue.
*/
TQString KTTSD::getTextJobNumbers()
{
    if (!m_speaker) return TQString();
    return m_speechData->getTextJobNumbers();
}

/**
* Get the state of a text job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
* @return               State of the job. -1 if invalid job number.
*
* @see kttsdJobState
*/
int KTTSD::getTextJobState(const uint jobNum /*=0*/)
{
    if (!m_speaker) return -1;
    return m_speechData->getTextJobState(applyDefaultJobNum(jobNum));
}

/**
* Get information about a text job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
* @return               A TQDataStream containing information about the job.
*                       Blank if no such job.
*
* The stream contains the following elements:
*   - int state         Job state.
*   - TQCString appId    DCOP senderId of the application that requested the speech job.
*   - TQString talker    Language code in which to speak the text.
*   - int seq           Current sentence being spoken.  Sentences are numbered starting at 1.
*   - int sentenceCount Total number of sentences in the job.
*
* The following sample code will decode the stream:
    @verbatim
    TQByteArray jobInfo = getTextJobInfo(jobNum);
    TQDataStream stream(jobInfo, IO_ReadOnly);
    int state;
    TQCString appId;
    TQString talker;
    int seq;
    int sentenceCount;
    stream >> state;
    stream >> appId;
    stream >> talker;
    stream >> seq;
    stream >> sentenceCount;
    @endverbatim
*/
TQByteArray KTTSD::getTextJobInfo(const uint jobNum /*=0*/)
{
    return m_speechData->getTextJobInfo(applyDefaultJobNum(jobNum));
}

/**
* Given a Talker Code, returns the Talker ID of the talker that would speak
* a text job with that Talker Code.
* @param talkerCode     Talker Code.
* @return               Talker ID of the talker that would speak the text job.
*/
TQString KTTSD::talkerCodeToTalkerId(const TQString& talkerCode)
{
    if (!m_talkerMgr) return TQString();
    return m_talkerMgr->talkerCodeToTalkerId(fixNullString(talkerCode));
}

/**
* Return a sentence of a job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
* @param seq            Sequence number of the sentence.
* @return               The specified sentence in the specified job.  If no such
*                       job or sentence, returns "".
*/
TQString KTTSD::getTextJobSentence(const uint jobNum /*=0*/, const uint seq /*=1*/)
{
    return m_speechData->getTextJobSentence(applyDefaultJobNum(jobNum), seq);
}

/**
* Determine if kttsd is currently speaking any text jobs.
* @return               True if currently speaking any text jobs.
*/
bool KTTSD::isSpeakingText() const
{
    if (!m_speaker) return false;
    return m_speaker->isSpeakingText();
}

/**
* Remove a text job from the queue.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* The job is deleted from the queue and the @ref textRemoved signal is emitted.
*
* If there is another job in the text queue, and it is marked speakable,
* that job begins speaking.
*/
void KTTSD::removeText(const uint jobNum /*=0*/)
{
    kdDebug() << "KTTSD::removeText: Running" << endl;
    if (!m_speaker) return;
    m_speaker->removeText(applyDefaultJobNum(jobNum));
}

/**
* Start a text job at the beginning.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* Rewinds the job to the beginning.
*
* The job is marked speakable.
* If there are other speakable jobs preceeding this one in the queue,
* those jobs continue speaking and when finished, this job will begin speaking.
* If there are no other speakable jobs preceeding this one, it begins speaking.
*
* The @ref textStarted signal is emitted when the text job begins speaking.
* When all the sentences of the job have been spoken, the job is marked for deletion from
* the text queue and the @ref textFinished signal is emitted.
*/
void KTTSD::startText(const uint jobNum /*=0*/)
{
    kdDebug() << "KTTSD::startText: Running" << endl;
    if (!m_speaker) return;
    // Determine if we are starting speech.
    bool startingSpeech = !isSpeakingText();
    uint jNum = applyDefaultJobNum(jobNum);
    m_speaker->startText(jNum);
    // If this has started speech output, determine whether to autostart KTTSMgr.
    if (startingSpeech)
    {
        if (m_speechData->autoStartManager)
        {
            // Do not start KTTSMgr unless at least 5 sentences are queued.
            if (getTextCount(jNum) > 4)
            {
                TQString cmd = "kttsmgr --systray";
                if (m_speechData->autoExitManager) cmd.append(" --autoexit");
                // Notice this fails if KTTSMgr is already running, which is what we want.
                KRun::runCommand(cmd);
            }
        }
    }
}

/**
* Stop a text job and rewind to the beginning.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* The job is marked not speakable and will not be speakable until @ref startText or @ref resumeText
* is called.
*
* If there are speaking jobs preceeding this one in the queue, they continue speaking.
* If the job is currently speaking, the @ref textStopped signal is emitted and the job stops speaking.
* Depending upon the speech engine and plugin used, speeking may not stop immediately
* (it might finish the current sentence).
*/
void KTTSD::stopText(const uint jobNum /*=0*/)
{
    kdDebug() << "KTTSD::stopText: Running" << endl;
    if (!m_speaker) return;
    m_speaker->stopText(applyDefaultJobNum(jobNum));
}

/**
* Pause a text job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* The job is marked as paused and will not be speakable until @ref resumeText or
* @ref startText is called.
*
* If there are speaking jobs preceeding this one in the queue, they continue speaking.
* If the job is currently speaking, the @ref textPaused signal is emitted and the job stops speaking.
* Depending upon the speech engine and plugin used, speeking may not stop immediately
* (it might finish the current sentence).
* @see resumeText
*/
void KTTSD::pauseText(const uint jobNum /*=0*/)
{
    kdDebug() << "KTTSD::pauseText: Running" << endl;
    if (!m_speaker) return;
    m_speaker->pauseText(applyDefaultJobNum(jobNum));
}

/**
* Start or resume a text job where it was paused.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* The job is marked speakable.
*
* If the job is currently speaking, or is waiting to be spoken (speakable 
* state), the resumeText() call is ignored.
*
* If the job is currently queued, or is finished, it is the same as calling
* @ref startText .
*
* If there are speaking jobs preceeding this one in the queue, those jobs continue speaking and,
* when finished this job will begin speaking where it left off.
*
* The @ref textResumed signal is emitted when the job resumes.
* @see pauseText
*/
void KTTSD::resumeText(const uint jobNum /*=0*/)
{
    kdDebug() << "KTTSD::resumeText: Running" << endl;
    if (!m_speaker) return;
    m_speaker->resumeText(applyDefaultJobNum(jobNum));
}

/**
* Get a list of the talkers configured in KTTS.
* @return               A TQStringList of fully-specified talker codes, one
*                       for each talker user has configured.
*
* @see talkers
*/
TQStringList KTTSD::getTalkers()
{
    if (!m_talkerMgr) return TQStringList();
    return m_talkerMgr->getTalkers();
}

/**
* Change the talker for a text job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
* @param talker         New code for the talker to do the speaking.  Example "en".
*                       If NULL, defaults to the user's default talker.
*                       If no plugin has been configured for the specified Talker code,
*                       defaults to the closest matching talker.
*/
void KTTSD::changeTextTalker(const TQString &talker, uint jobNum)
{
    m_speechData->changeTextTalker(fixNullString(talker), applyDefaultJobNum(jobNum));
}

/**
* Get the user's default talker.
* @return               A fully-specified talker code.
*
* @see talkers
* @see getTalkers
*/
TQString KTTSD::userDefaultTalker()
{
    if (!m_talkerMgr) return TQString();
    return m_talkerMgr->userDefaultTalker();
}

/**
* Move a text job down in the queue so that it is spoken later.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application.
*
* If the job is currently speaking, it is paused.
* If the next job in the queue is speakable, it begins speaking.
*/
void KTTSD::moveTextLater(const uint jobNum /*=0*/)
{
    if (!m_speaker) return;
    m_speaker->moveTextLater(applyDefaultJobNum(jobNum));
}

/**
* Jump to the first sentence of a specified part of a text job.
* @param partNum        Part number of the part to jump to.  Parts are numbered starting at 1.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application,
*                       but if no such job, applies to the last job queued by any application.
* @return               Part number of the part actually jumped to.
*
* If partNum is greater than the number of parts in the job, jumps to last part.
* If partNum is 0, does nothing and returns the current part number.
* If no such job, does nothing and returns 0.
* Does not affect the current speaking/not-speaking state of the job.
*/
int KTTSD::jumpToTextPart(const int partNum, const uint jobNum /*=0*/)
{
    if (!m_speaker) return 0;
    return m_speaker->jumpToTextPart(partNum, applyDefaultJobNum(jobNum));
}

/**
* Advance or rewind N sentences in a text job.
* @param n              Number of sentences to advance (positive) or rewind (negative) in the job.
* @param jobNum         Job number of the text job.
*                       If zero, applies to the last job queued by the application,
*                       but if no such job, applies to the last job queued by any application.
* @return               Sequence number of the sentence actually moved to.  Sequence numbers
*                       are numbered starting at 1.
*
* If no such job, does nothing and returns 0.
* If n is zero, returns the current sequence number of the job.
* Does not affect the current speaking/not-speaking state of the job.
*/
uint KTTSD::moveRelTextSentence(const int n, const uint jobNum /*=0*/)
{
    if (!m_speaker) return 0;
    return m_speaker->moveRelTextSentence(n, applyDefaultJobNum(jobNum));
}

/**
* Add the clipboard contents to the text queue and begin speaking it.
*/
void KTTSD::speakClipboard()
{
    // Get the clipboard object.
    TQClipboard *cb = kapp->clipboard();

    // Copy text from the clipboard.
    TQString text = cb->text();

    // Speak it.
    if ( !text.isNull() ) 
    {
        setText(text);
        startText();
    }
}

/**
* Displays the %KTTS Manager dialog.  In this dialog, the user may backup or skip forward in
* any text job by sentence or paragraph, rewind jobs, pause or resume jobs, or
* delete jobs.
*/
void KTTSD::showDialog()
{
    KRun::runCommand("kttsmgr");
}

/**
* Stop the service.
*/
void KTTSD::kttsdExit()
{
    stopText();
    kdDebug() << "KTTSD::kttsdExit: Emitting DCOP signal kttsdExiting()" << endl;
    kttsdExiting();
    kapp->quit();
}

/**
* Re-start %KTTSD.
*/
void KTTSD::reinit()
{
    // Restart ourself.
    kdDebug() << "KTTSD::reinit: Running" << endl;
    if (m_speaker)
    {
        kdDebug() << "KTTSD::reinit: Stopping KTTSD service" << endl;
        if (m_speaker->isSpeakingText()) pauseText();
        m_speaker->requestExit();
    }
    delete m_speaker;
    m_speaker = 0;
    delete m_talkerMgr;
    m_talkerMgr = 0;
    ready();
}

/**
* Return KTTSD daemon version number.
*/
TQString KTTSD::version() { return kapp->aboutData()->version(); }

/*
* Checks if KTTSD is ready to speak and at least one talker is configured.
* If not, user is prompted to display the configuration dialog.
*/
bool KTTSD::ready()
{
    if (m_speaker) return true;
    kdDebug() << "KTTSD::ready: Starting KTTSD service" << endl;
    if (!initializeSpeechData()) return false;
    if (!initializeTalkerMgr()) return false;
    if (!initializeSpeaker()) return false;
    m_speaker->doUtterances();
    kdDebug() << "KTTSD::ready: Emitting DCOP signal kttsdStarted()" << endl;
    kttsdStarted();
    return true;
}

void KTTSD::configCommitted() {
    if (m_speaker) reinit();
}

/**
* This signal is emitted by KNotify when a notification event occurs.
*    ds << event << fromApp << text << sound << file << present << level
*       << winId << eventId;
* default_presentation contains these ORed events: None=0, Sound=1, Messagebox=2, Logfile=4, Stderr=8,
* PassivePopup=16, Execute=32, Taskbar=64
*/
void KTTSD::notificationSignal( const TQString& event, const TQString& fromApp,
    const TQString &text, const TQString& sound, const TQString& /*file*/,
    const int present, const int /*level*/, const int /*windId*/, const int /*eventId*/)
{
    if (!m_speaker) return;
    // kdDebug() << "KTTSD:notificationSignal: event: " << event << " fromApp: " << fromApp << 
    //     " text: " << text << " sound: " << sound << " file: " << file << " present: " << present <<
    //    " level: " << level << " windId: " << windId << " eventId: " << eventId << endl;
    if ( m_speechData->notify )
        if ( !m_speechData->notifyExcludeEventsWithSound || sound.isEmpty() )
        {
            bool found = false;
            NotifyOptions notifyOptions;
            TQString msg;
            TQString talker;
            // Check for app-specific action.
            if ( m_speechData->notifyAppMap.contains( fromApp ) )
            {
                NotifyEventMap notifyEventMap = m_speechData->notifyAppMap[ fromApp ];
                if ( notifyEventMap.contains( event ) )
                {
                    found = true;
                    notifyOptions = notifyEventMap[ event ];
                } else {
                    // Check for app-specific default.
                    if ( notifyEventMap.contains( "default" ) )
                    {
                        found = true;
                        notifyOptions = notifyEventMap[ "default" ];
                        notifyOptions.eventName = TQString();
                    }
                }
            }
            // If no app-specific action, try default.
            if ( !found )
            {
                switch ( m_speechData->notifyDefaultPresent )
                {
                    case NotifyPresent::None:
                        found = false;
                        break;
                    case NotifyPresent::Dialog:
                        found = (
                            (present & KNotifyClient::Messagebox)
                            &&
                            !(present & KNotifyClient::PassivePopup)
                            );
                        break;
                    case NotifyPresent::Passive:
                        found = (
                            !(present & KNotifyClient::Messagebox)
                            &&
                            (present & KNotifyClient::PassivePopup)
                            );
                        break;
                    case NotifyPresent::DialogAndPassive:
                        found = (
                            (present & KNotifyClient::Messagebox)
                            &&
                            (present & KNotifyClient::PassivePopup)
                            );
                        break;
                    case NotifyPresent::All:
                        found = true;
                        break;
                }
                if ( found )
                    notifyOptions = m_speechData->notifyDefaultOptions;
            }
            if ( found )
            {
                int action = notifyOptions.action;
                talker = notifyOptions.talker;
                switch ( action )
                {
                    case NotifyAction::DoNotSpeak:
                        break;
                    case NotifyAction::SpeakEventName:
                        if (notifyOptions.eventName.isEmpty())
                            msg = NotifyEvent::getEventName( fromApp, event );
                        else
                            msg = notifyOptions.eventName;
                        break;
                    case NotifyAction::SpeakMsg:
                        msg = text;
                        break;
                    case NotifyAction::SpeakCustom:
                        msg = notifyOptions.customMsg;
                        msg.replace( "%a", fromApp );
                        msg.replace( "%m", text );
                        if ( msg.contains( "%e" ) )
                        {
                            if ( notifyOptions.eventName.isEmpty() )
                                msg.replace( "%e", NotifyEvent::getEventName( fromApp, event ) );
                            else
                                msg.replace( "%e", notifyOptions.eventName );
                        }
                        break;
                }
            }
            // Queue msg if we should speak something.
            if ( !msg.isEmpty() )
            {
                TQString fromApps = fromApp + ",knotify";
                m_speechData->enqueueMessage( msg, talker, fromApps.utf8() );
                m_speaker->doUtterances();
            }
        }
}

// Slots for the speaker object
void KTTSD::slotSentenceStarted(TQString, TQString, const TQCString& appId, 
    const uint jobNum, const uint seq) {
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotSentenceStarted: Emitting DCOP signal sentenceStarted with appId " << appId << " job number " << jobNum << "  seq number " << seq << endl;
    sentenceStarted(appId, jobNum, seq);
}

void KTTSD::slotSentenceFinished(const TQCString& appId, const uint jobNum, const uint seq){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotSentenceFinished: Emitting DCOP signal sentenceFinished with appId " << appId << " job number " << jobNum << "  seq number " << seq << endl;
    sentenceFinished(appId, jobNum, seq);
}

// Slots for the speechData and speaker objects.
void KTTSD::slotTextStarted(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextStarted: Emitting DCOP signal textStarted with appId " << appId << " job number " << jobNum << endl;
    textStarted(appId, jobNum);
}

void KTTSD::slotTextFinished(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextFinished: Emitting DCOP signal textFinished with appId " << appId << " job number " << jobNum << endl;
    textFinished(appId, jobNum);
}

void KTTSD::slotTextStopped(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextStopped: Emitting DCOP signal textStopped with appId " << appId << " job number " << jobNum << endl;
    textStopped(appId, jobNum);
}

void KTTSD::slotTextPaused(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextPaused: Emitting DCOP signal textPaused with appId " << appId << " job number " << jobNum << endl;
    textPaused(appId, jobNum);
}

void KTTSD::slotTextResumed(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextResumed: Emitting DCOP signal textResumed with appId " << appId << " job number " << jobNum << endl;
    textResumed(appId, jobNum);
}

//void KTTSD::slotTextSet(const TQCString& appId, const uint jobNum){
void KTTSD::slotTextSet(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextSet: Emitting DCOP signal textSet with appId " << appId << " job number " << jobNum << endl;
    textSet(appId, jobNum);
}

void KTTSD::slotTextAppended(const TQCString& appId, const uint jobNum, const int partNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextAppended: Emitting DCOP signal textAppended with appId " <<
        appId << " job number " << jobNum << " part number " << partNum << endl;
    textAppended(appId, jobNum, partNum);
}

void KTTSD::slotTextRemoved(const TQCString& appId, const uint jobNum){
    // Emit DCOP signal.
    kdDebug() << "KTTSD::slotTextRemoved: Emitting DCOP signal textRemoved with appId " << appId << " job number " << jobNum << endl;
    textRemoved(appId, jobNum);
}

/**
 * Returns the senderId (appId) of the DCOP application that called us.
 * @return              The DCOP sendId of calling application.
 */
const TQCString KTTSD::getAppId()
{
    DCOPClient* client = callingDcopClient();
    TQCString appId;
    if (client) appId = client->senderId();
    return appId;
}

/**
* If a job number is 0, returns the default job number for a command.
* Returns the job number of the last job queued by the application, or if
* no such job, the current job number.
* @return                Default job number.  0 if no such job.
*/
uint KTTSD::applyDefaultJobNum(const uint jobNum)
{
    uint jNum = jobNum;
    if (!jNum)
    {
        jNum = m_speechData->findAJobNumByAppId(getAppId());
        if (!jNum) jNum = getCurrentTextJob();
        if (!jNum) jNum = m_speechData->findAJobNumByAppId(0);
    }
    return jNum;
}

/*
* Fixes a string argument passed in via dcop.
* If NULL or "0" return TQString().
*/
TQString KTTSD::fixNullString(const TQString &talker) const
{
    if (!talker) return TQString();
    if (talker == "0") return TQString();
    return talker;
}

// kspeech is obsolete.  Applications should use KSpeech instead.

// Constructor.
kspeech::kspeech(const TQCString& objId, TQObject *parent, const char *name) :
    DCOPObject(objId),
    TQObject(parent, name),
    m_kttsd("KSpeech")
{
}

// Destructor.
kspeech::~kspeech() { }

// Delegate all DCOP methods to KTTSD object.
/*virtual*/ bool kspeech::supportsMarkup(const TQString &talker, uint markupType) const
            { return m_kttsd.supportsMarkup(talker, markupType); }
/*virtual*/ bool kspeech::supportsMarkers(const TQString &talker) const
            { return m_kttsd.supportsMarkers(talker); }
/*virtual*/ ASYNC kspeech::sayScreenReaderOutput(const TQString &msg, const TQString &talker)
            { m_kttsd.sayScreenReaderOutput(msg, talker); }
/*virtual*/ ASYNC kspeech::sayWarning(const TQString &warning, const TQString &talker)
            { m_kttsd.sayWarning(warning, talker); }
/*virtual*/ ASYNC kspeech::sayMessage(const TQString &message, const TQString &talker)
            { m_kttsd.sayMessage(message, talker); }
/*virtual*/ ASYNC kspeech::setSentenceDelimiter(const TQString &delimiter)
            { m_kttsd.setSentenceDelimiter(delimiter); }
/*virtual*/ uint kspeech::setText(const TQString &text, const TQString &talker)
            { return m_kttsd.setText(text, talker); }
/*virtual*/ uint kspeech::sayText(const TQString &text, const TQString &talker)
            { return m_kttsd.sayText(text, talker); }
/*virtual*/ int kspeech::appendText(const TQString &text, uint jobNum)
            { return m_kttsd.appendText(text, jobNum); }
/*virtual*/ uint kspeech::setFile(const TQString &filename, const TQString &talker,
                        const TQString& encoding)
            { return m_kttsd.setFile(filename, talker, encoding); }
/*virtual*/ int kspeech::getTextCount(uint jobNum)
            { return m_kttsd.getTextCount(jobNum); }
/*virtual*/ uint kspeech::getCurrentTextJob()
            { return m_kttsd.getCurrentTextJob(); }
/*virtual*/ uint kspeech::getTextJobCount()
            { return m_kttsd.getTextJobCount(); }
/*virtual*/ TQString kspeech::getTextJobNumbers()
            { return m_kttsd.getTextJobNumbers(); }
/*virtual*/ int kspeech::getTextJobState(uint jobNum)
            { return m_kttsd.getTextJobState(jobNum); }
/*virtual*/ TQByteArray kspeech::getTextJobInfo(uint jobNum)
            { return m_kttsd.getTextJobInfo(jobNum); }
/*virtual*/ TQString kspeech::talkerCodeToTalkerId(const TQString& talkerCode)
            { return m_kttsd.talkerCodeToTalkerId(talkerCode); }
/*virtual*/ TQString kspeech::getTextJobSentence(uint jobNum, uint seq)
            { return m_kttsd.getTextJobSentence(jobNum, seq); }
/*virtual*/ bool kspeech::isSpeakingText() const
            { return m_kttsd.isSpeakingText(); }
/*virtual*/ ASYNC kspeech::removeText(uint jobNum)
            { m_kttsd.removeText(jobNum); }
/*virtual*/ ASYNC kspeech::startText(uint jobNum)
            { m_kttsd.startText(jobNum); }
/*virtual*/ ASYNC kspeech::stopText(uint jobNum)
            { m_kttsd.stopText(jobNum); }
/*virtual*/ ASYNC kspeech::pauseText(uint jobNum)
            { m_kttsd.pauseText(jobNum); }
/*virtual*/ ASYNC kspeech::resumeText(uint jobNum)
            { m_kttsd.resumeText(jobNum); }
/*virtual*/ TQStringList kspeech::getTalkers()
            { return m_kttsd.getTalkers(); }
/*virtual*/ ASYNC kspeech::changeTextTalker(const TQString &talker, uint jobNum )
            { m_kttsd.changeTextTalker(talker, jobNum); }
/*virtual*/ TQString kspeech::userDefaultTalker()
            { return m_kttsd.userDefaultTalker(); }
/*virtual*/ ASYNC kspeech::moveTextLater(uint jobNum)
            { m_kttsd.moveTextLater(jobNum); }
/*virtual*/ int kspeech::jumpToTextPart(int partNum, uint jobNum)
            { return m_kttsd.jumpToTextPart(partNum, jobNum); }
/*virtual*/ uint kspeech::moveRelTextSentence(int n, uint jobNum)
            { return m_kttsd.moveRelTextSentence(n, jobNum); }
/*virtual*/ ASYNC kspeech::speakClipboard()
            { m_kttsd.speakClipboard(); }
/*virtual*/ void kspeech::showDialog()
            { m_kttsd.showDialog(); }
/*virtual*/ void kspeech::kttsdExit()
            { m_kttsd.kttsdExit(); }
/*virtual*/ void kspeech::reinit()
            { m_kttsd.reinit(); }
/*virtual*/ TQString kspeech::version()
            { return m_kttsd.version(); }

#include "kttsd.moc"