summaryrefslogtreecommitdiff
path: root/themes/openSUSE/src/speech.inc
blob: ee067085cf50f1b35768dd8614460bf50b2c9657 (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
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Speech related function.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


/.talk_text  0 def
/.talk_sound 1 def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% ( text -- )
%
/speak {
  % skip leading TABs
  { dup 0 get '\x09' eq { 1 add } { exit } ifelse } loop

  /last.spoken xfree
  /last.spoken over strdup def

  dup _speak { pop return } if
  dup __ dup rot ne { _speak } if pop
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Say text.
%
% ( str -- bool )
%
%  str: text
% bool: sound sample found
%
/_speak {
  talk_array {
    dup .talk_text get 2 index eq {
      .talk_sound get wav.playlater
      pop true return
    } {
      pop
    } ifelse
  } forall
  pop
  false
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Load sound samples.
%
% ( -- )
%
/load_talk {
  /talk_file "en.tlk" findfile def

  talk_file .undef eq { return } if

  talk_file getdword 0x692741e8 ne { return } if

  talk_array .undef ne {
    talk_array { free } forall
  } if

  /talk_array xfree

  /talk_array [
    0 1 talk_file 4 add getdword 1 sub {
      [
        exch 8 mul 8 add talk_file add
        dup getdword talk_file add cvs
        exch 4 add getdword talk_file add
      ]
    } for
  ] def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Load sound samples.
%
% ( -- )
%
/load_talk_dialog {
  window.dialog
  dup .title "Just a second..." put
  dup .text "Please wait while speech files are being loaded..." put
  dup window.init window.show

  load_talk
  config.volume sound.setvolume 

  window.done
} def