arduino-simple-tts

Loading...
Searching...
No Matches
AudioDictionary.h
1#pragma once
2
3#include "SimpleTTSBase.h"
4#include "ext/silence_mp3.h"
5
6namespace simple_tts {
7
13 class AudioDictionary : public AudioDictionaryBase {
14 public:
15 AudioDictionary(AudioDictionaryEntry *dict) { dictionary = dict; }
16 AudioStream *get(const char *word) {
17 if (word==nullptr) return nullptr;
18 Str str(word);
19 AudioDictionaryEntry *e = dictionary;
20 while (e->name != nullptr) {
21 if (str.equalsIgnoreCase(e->name)) {
22 return e->audio;
23 }
24 e++;
25 }
26 return nullptr;
27 }
28
29 protected:
30 AudioDictionaryEntry *dictionary;
31};
32
33// if you define NO_EXAMPLES we do not include any example audio
34#ifndef NO_AUDIO_EXAMPLES
35
36#include "en/all.h"
37
43 AudioDictionaryEntry ExampleAudioDictionaryValues[] = {
44 {"SILENCE", new MemoryStream(silence_mp3, silence_mp3_len)},
45 {"AND", new MemoryStream(and_mp3, and_mp3_len)},
46 {"BILLION", new MemoryStream(billion_mp3, billion_mp3_len)},
47 {"DOT", new MemoryStream(dot_mp3, dot_mp3_len)},
48 {"EIGHT", new MemoryStream(eight_mp3, eight_mp3_len)},
49 {"EIGHTEEN", new MemoryStream(eighteen_mp3, eighteen_mp3_len)},
50 {"EIGHTY", new MemoryStream(eighty_mp3, eighty_mp3_len)},
51 {"ELEVEN", new MemoryStream(eleven_mp3, eleven_mp3_len)},
52 {"FIFTEEN", new MemoryStream(fifteen_mp3, fifteen_mp3_len)},
53 {"FIFTY", new MemoryStream(fifty_mp3, fifty_mp3_len)},
54 {"FIVE", new MemoryStream(five_mp3, five_mp3_len)},
55 {"FOUR", new MemoryStream(four_mp3, four_mp3_len)},
56 {"FOURTEEN", new MemoryStream(fourteen_mp3, fourteen_mp3_len)},
57 {"FORTY", new MemoryStream(forty_mp3, forty_mp3_len)},
58 {"HUNDRED", new MemoryStream(hundred_mp3, hundred_mp3_len)},
59 {"MILLION", new MemoryStream(million_mp3, million_mp3_len)},
60 {"MINUS", new MemoryStream(minus_mp3, minus_mp3_len)},
61 {"NINE", new MemoryStream(nine_mp3, nine_mp3_len)},
62 {"NINETEEN", new MemoryStream(nineteen_mp3, nineteen_mp3_len)},
63 {"NINETY", new MemoryStream(ninety_mp3, ninety_mp3_len)},
64 {"OCLOCK", new MemoryStream(oclock_mp3, oclock_mp3_len)},
65 {"ONE", new MemoryStream(one_mp3, one_mp3_len)},
66 {"SEVEN", new MemoryStream(seven_mp3, seven_mp3_len)},
67 {"SEVENTEEN", new MemoryStream(seventeen_mp3, seventeen_mp3_len)},
68 {"SEVENTY", new MemoryStream(seventy_mp3, seventy_mp3_len)},
69 {"SIX", new MemoryStream(six_mp3, six_mp3_len)},
70 {"SIXTEEN", new MemoryStream(sixteen_mp3, sixteen_mp3_len)},
71 {"SIXTY", new MemoryStream(sixty_mp3, sixty_mp3_len)},
72 {"TEN", new MemoryStream(ten_mp3, ten_mp3_len)},
73 {"THIRTEEN", new MemoryStream(thirteen_mp3, thirteen_mp3_len)},
74 {"THIRTY", new MemoryStream(thirty_mp3, thirty_mp3_len)},
75 {"THOUSAND", new MemoryStream(thousand_mp3, thousand_mp3_len)},
76 {"THREE", new MemoryStream(three_mp3, three_mp3_len)},
77 {"TWELVE", new MemoryStream(twelve_mp3, twelve_mp3_len)},
78 {"TWENTY", new MemoryStream(twenty_mp3, twenty_mp3_len)},
79 {"TWO", new MemoryStream(two_mp3, two_mp3_len)},
80 {"ZERO", new MemoryStream(zero_mp3, zero_mp3_len)},
81 // additional entries to support time
82 {"AM", new MemoryStream(am_mp3, am_mp3_len)},
83 {"HALF", new MemoryStream(half_mp3, half_mp3_len)},
84 {"ITS", new MemoryStream(its_mp3, its_mp3_len)},
85 {"MIDNIGHT", new MemoryStream(midnight_mp3, midnight_mp3_len)},
86 {"NOON", new MemoryStream(noon_mp3, noon_mp3_len)},
87 {"PAST", new MemoryStream(past_mp3, past_mp3_len)},
88 {"PM", new MemoryStream(pm_mp3, pm_mp3_len)},
89 {"QUARTER", new MemoryStream(quarter_mp3, quarter_mp3_len)},
90 {"TO", new MemoryStream(to_mp3, to_mp3_len)},
91 // units
92 {"pound", new MemoryStream(pound_mp3, pound_mp3_len)},
93 {"pounds", new MemoryStream(pounds_mp3, pounds_mp3_len)},
94 {"foot", new MemoryStream(foot_mp3, foot_mp3_len)},
95 {"feet", new MemoryStream(feet_mp3, feet_mp3_len)},
96 {"inch", new MemoryStream(inch_mp3, inch_mp3_len)},
97 {"inches", new MemoryStream(inches_mp3, inches_mp3_len)},
98 {"mile", new MemoryStream(mile_mp3, mile_mp3_len)},
99 {"miles", new MemoryStream(miles_mp3, miles_mp3_len)},
100 {"dollar", new MemoryStream(dollar_mp3, dollar_mp3_len)},
101 {"dollars", new MemoryStream(dollars_mp3, dollars_mp3_len)},
102 {"cent", new MemoryStream(cent_mp3, cent_mp3_len)},
103 {"centi", new MemoryStream(centi_mp3, centi_mp3_len)},
104 {"cents", new MemoryStream(cents_mp3, cents_mp3_len)},
105 {"miles", new MemoryStream(miles_mp3, miles_mp3_len)},
106 {"per", new MemoryStream(per_mp3, per_mp3_len)},
107 {"hour", new MemoryStream(hour_mp3, hour_mp3_len)},
108 {"degrees", new MemoryStream(degrees_mp3, degrees_mp3_len)},
109 {"celcius", new MemoryStream(celcius_mp3, celcius_mp3_len)},
110 {"fahrenheit", new MemoryStream(fahrenheit_mp3, fahrenheit_mp3_len)},
111 {"percent", new MemoryStream(percent_mp3, percent_mp3_len)},
112 {"liter", new MemoryStream(liter_mp3, liter_mp3_len)},
113 {"milli", new MemoryStream(milli_mp3, milli_mp3_len)},
114 {"meter", new MemoryStream(meter_mp3, meter_mp3_len)},
115 {"kilo", new MemoryStream(kilo_mp3, kilo_mp3_len)},
116 {"gram", new MemoryStream(gram_mp3, gram_mp3_len)},
117 {"us", new MemoryStream(us_mp3, us_mp3_len)},
118
119 // must end with nullptr to mark end
120 {nullptr, nullptr}
121
122};
123
124#endif
125
126}
simple_tts::AudioDictionaryBase
Dictionary which provides a Stream of Audio for the indicated word.
Definition: SimpleTTSBase.h:49
simple_tts::AudioDictionary
A dictionary which is based on in memory audio files.
Definition: AudioDictionary.h:13
simple_tts::AudioDictionaryEntry
An Entry for the in Memory Audio Dictionary.
Definition: SimpleTTSBase.h:60