forked from datalad/datalad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcast2narration
More file actions
executable file
·71 lines (62 loc) · 2.07 KB
/
cast2narration
File metadata and controls
executable file
·71 lines (62 loc) · 2.07 KB
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
#!/bin/bash
#
# This helper executes a screencast script. It expects an xterm window to be up and
# running (or fails otherwise). This player is ignorant regarding the actual setup
# of the terminal session running in the xterm window, it just feeds that window
# via a keyboard input simulation, while generating text-to-speech output
# according to the script
#
# Usage: play_script <scriptfile>
#
# Note: If a script is written in way that paths are deterministic and identical
# across the running script and the scripted terminal session, this script
# can also be used to implement tests. Scripts are executed in a bash session
# with -u and -e flags active. However, this would only work of the sessions
# run on the same system, and not, for example, the demo in docker container.
set -u -e
#
# http://www.festvox.org/docs/manual-2.4.0/festival_10.html#Sable-example
#
#The boy saw the girl <BREAK/> in the park with the telescope. Good morning <BREAK /> My name is Stuart, which is spelled
#<RATE SPEED="-40%">
#<SAYAS MODE="literal">stuart</SAYAS> </RATE>
#though some people pronounce it
#<PRON SUB="stoo art">stuart</PRON>. My telephone number
#is <SAYAS MODE="literal">2787</SAYAS>.
#
#I used to work in <PRON SUB="Buckloo">Buccleuch</PRON> Place,
#but no one can pronounce that.
# shortcut for making xdotool find the right window
xdt="xdotool search --classname xterm windowactivate"
# need a tempfile for feeding festival
tts_file=$(mktemp).sable
# cleanup on exit
trap "rm -f $tts_file" EXIT
function say()
{
cat << EOT > $tts_file
<?xml version="1.0"?>
<!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN" "Sable.v0_2.dtd" []>
<SABLE>
<SPEAKER NAME="cmu_us_slt_arctic_hts">
$(echo "$1" | sed -e 's/datalad/data-lad/g')
</SPEAKER>
</SABLE>
EOT
festival --tts $tts_file
}
function type () {
$xdt type --delay 25 --window %@ "$1"
}
function key () {
$xdt key --window %@ $*
}
function sleep () {
xdotool sleep $1
}
function execute () {
$xdt sleep 0.5 key --window %@ Return
}
# make sure the target xterm is up and running
$xdt --sync sleep 0.2
. $1