-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathespeak.pl
160 lines (146 loc) · 3.52 KB
/
espeak.pl
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
use strict;
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);
use Irssi;
$VERSION = '0.2';
%IRSSI = (
authors => 'Richard Molitor',
contact => '[email protected]',
name => 'espeak',
description => 'This script provides'.
'text to speech functionality'.
'via espeak',
license => 'MIT',
);
my $espeak_args = " -v de -s 140 ";
my $subs = {
'_' => ' Unterstrich ',
'ä' => 'ae',
'äu' => 'eu',
'ö' => 'oe',
'ü' => 'ue',
'ß' => 'ss',
'\'' => ' ',
'/' => ' ',
'"' => ' ',
# '\?' => '\\?'
};
my $chan_subs = {
'\#' => '',
'\&' => ''
};
my $speech_subs = {
# general
';' => ' Semikolon ',
'\(' => ' ',
'\)' => ' ',
#'\(' => ' Klammer auf ',
#'\)' => ' Klammer zu ',
'#' => ' Raute ',
'\|' => ' Paip ',
'\+' => ' Plus ',
'\-' => ' Minus ',
'€' => ' Euro ',
'd\.h\.' => ' das heisst ',
'[^a-z]mom|^mom$' => ' Moment ',
'@' => ' aet ',
'=' => ' gleich ',
'\*' => ' Sternchen ',
'kA' => ' keine Ahnung ',
'KA' => ' Karlsruhe ',
'(^|[^a-z])k([^a-zA-Z]|$)' => ' key ',
'(^|[^a-z])hi([^a-z]|$)' => ' hai ',
'\.de' => ' D E ',
'vll[t]*' => ' vielleicht ',
'19\d{2}([^0-9]|$)' => ' neunzehnhundert ',
# dirty hacks to convert German to English
'nice' => 'nais',
'user' => 'juser',
'bool' => 'bul',
# the not so dirty 'remove-all-smilies' part
':\)' => '',
':-\)' => '',
'XD' => '',
'xD' => '',
':D' => '',
':-D' => '',
':P' => '',
':/' => '',
':-/' => '',
':\\\\' => '',
':-\\\\' => ''
};
my $nick_subs = {
'n0nsense' => 'nonsens',
'McManiaC' => 'mecmeyniac',
'w33z4l' => 'wiesal',
'LucY' => 'luhssi',
'anoobis' => 'anubis',
'bugfeed' => 'bagfied',
'm0l0t0ph' => 'toff',
'cereal' => 'ssiriel',
'root' => 'rut',
'JJ' => 'jehi jehi',
'\|' => '',
'_' => ' '
};
sub _cleaner {
$_ = shift;
while ( my($key, $value) = each %$subs) {
s/$key/$value/g;
}
/([\w\d\ \.\:\;\,\!\$\%\&\*\^\'\=]*)/;
return $1;
}
sub _chan_cleaner {
$_ = shift;
while ( my($key, $value) = each %$chan_subs) {
s/$key/$value/g;
}
&_cleaner($_);
}
sub _speech_cleaner {
$_ = shift;
while ( my($key, $value) = each %$speech_subs) {
s/$key/$value/g;
}
&_cleaner($_);
&_nick_cleaner($_);
}
sub _nick_cleaner {
$_ = shift;
while ( my($key, $value) = each %$nick_subs) {
s/$key/$value/g;
}
&_cleaner($_);
}
sub _privmsg {
# $data = "nick/#channel :text"
my ($server, $data, $nick, $address) = @_;
my ($target, $text) = split(/ :/, $data, 2);
my $nick_c = &_nick_cleaner($nick);
my $text_c = &_speech_cleaner($text);
my $target_c = &_chan_cleaner($target);
if (length($text_c) > 0) {
if (substr ($text,-1,1) eq '?') {
system("flock $ENV{'HOME'}/.irssi/scripts/.espeak.lock ".
"-c \'espeak $espeak_args \"$nick_c".
" fragt $text_c\"\' &");
}
else {
system("flock $ENV{'HOME'}/.irssi/scripts/.espeak.lock ".
"-c \'espeak $espeak_args \"$nick_c".
" sagt $text_c\"\' &");
}
}
}
sub _join {
my ($server, $channel, $nick, $address) = @_;
my $channel_c = &_chan_cleaner($channel);
my $nick_c = &_nick_cleaner($nick);
#print("$nick_c joined");
#system("espeak $espeak_args \"$nick_c".
#" hat $channel_c betreten.\" &");
}
signal_add("event privmsg", "_privmsg");
signal_add("message join", "_join");