summaryrefslogtreecommitdiff
path: root/numbers-station.raku
blob: 82a993d3fff7cd90b00655b5ce0929fd818e55dc (plain) (blame)
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
#!/usr/bin/raku

# This is a numbers station script
# It converts letters into numbers and says those numbers
#
# Based on the Major System 
# 0 : s z
# 1 : t d th
# 2 : n
# 3 : m
# 4 : r
# 5 : l
# 6 : ch g sh c
# 7 : k g ch (like, bach the musician) ck
# 8 : f v
# 9 : p b
#   : h j w
#
# This script will need to:
# 1. somehow know the proper puncication of each word ( probably impossible to accurately impliment :(
# 2. convert each word into numbers
# 3. play the sound for each numbers
# 3.1. add a space between each number set

my $audio_location = './audio/';
my $audio_extension = '.wav';
my %numberlist = (1 => <1a 1b 1c>, 2 => <2a 2b 2c>, 3 => <3a 3b 3c>, 4 => <4a 4b 4c>, 5 => <5a 5b 5c>, 6 => <6a 6b 6c>, 7 => <7a 7b 7c>, 8 => <8a 8b 8c>, 9 => <9a 9b 9c>, 0 => <0a 0b 0c>);

my $file = w2n(open('country_roads.txt'));

#say "$audio_location, $audio_extension, " ~ %numberlist{1}[].roll;

# words to number
sub w2n($file) {
	my @n = $file.words;
	for @n <-> $word {
		$word ~~ s :g:i /(ch)|g|(sh)|c/6/;
		$word ~~ s :g:i /s|z/0/;
		$word ~~ s :g:i /t|d|(th)/1/;
		$word ~~ s :g:i /n/2/;
		$word ~~ s :g:i /m/3/;
		$word ~~ s :g:i /r/4/;
		$word ~~ s :g:i /l/5/;
		$word ~~ s :g:i /k|g|ck/7/;
		$word ~~ s :g:i /f|v/8/;
		$word ~~ s :g:i /p|b/9/;
		$word ~~ tr/A..Za..z',//;
		if $word.chars == 1 {
		 	$word = '';
		}
	}
	return @n;
}

print $file ~ "\n";