had a stab at my incorrect pointer code
[bcl.git] / speech_sd.c
blob4a43f95adcd3042839e94ccb3b2b7597b2723b08
1 #include "bcl.h"
2 #include <libspeechd.h>
3 #include <stdio.h>
5 SPDConnection * spd;
6 int myrate = 0;
7 int myvoice;
8 char *voices[8] = {"male1","male2","male3","female1","female2","female3","child_male","child_female"};
9 int speaking=0;
11 void mycallback(size_t a, size_t b, SPDNotificationType state) {
12 speaking=0;
15 void initSpeech() {
16 spd = spd_open("bcllib",NULL,NULL,SPD_MODE_THREADED);
17 spd->callback_end=spd->callback_cancel=mycallback;
18 spd_set_notification_on(spd,SPD_END);
19 myrate = 50;
20 myvoice=0;
21 spd_set_voice_rate(spd,myrate);
22 spd_set_synthesis_voice(spd,voices[myvoice]);
25 void terminateSpeech() {
26 spd_close(spd);
29 void speak(char * text, int flags) {
30 speaking=1;
31 if (flags&SPEAK_INTERRUPTING)
32 spd_cancel(spd);
33 spd_say(spd,SPD_MESSAGE,text);
34 if (flags&SPEAK_BLOCKING)
35 while (isSpeaking()) {
36 pumpEvents();
37 delay(20);
41 int getSpeechRate() {
42 return myrate;
45 void setSpeechRate(int rate) {
46 myrate = rate;
47 spd_set_voice_rate(spd,myrate);
50 int getSpeechVoice() {
51 return myvoice;
54 void setSpeechVoice(int voice) {
55 myvoice = voice;
56 spd_set_synthesis_voice(spd,voices[myvoice]);
59 int isSpeaking() {
60 return speaking;
63 void stopSpeech() {
64 spd_cancel(spd);