arduino-simple-tts
All Classes Functions Variables Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
simple_tts::NumberUnitToText Class Reference

An extension of the Number to Text functionality which supports numbers with units of measures. More...

#include <NumberUnitToText.h>

Inheritance diagram for simple_tts::NumberUnitToText:
simple_tts::SimpleTTSBase

Classes

struct  DecimalInfo
 Units might have different decimals. The decimal system is based on 3. But currencies have usually 2. More...
 

Public Member Functions

 NumberUnitToText (const char *defaultUnit)
 
audio_tools::Vector< const char * > & say (double value, const char *unit=nullptr, int decimals=2)
 converts a real number with a unit to it's text representation
 
audio_tools::Vector< const char * > & say (int64_t wholeNumber, const char *unit=nullptr)
 converts an integer with a unit to it's text representation
 
audio_tools::Vector< const char * > & say (const char *wholeNumber, const char *decimals, const char *unitIn)
 converts a number provided by string components to it's text representation
 
virtual audio_tools::Vector< const char * > & allTexts ()
 Provides all texts.
 
- Public Member Functions inherited from simple_tts::SimpleTTSBase
virtual audio_tools::Vector< const char * > & allTexts ()=0
 
virtual void registerCallback (void(*ptr)(audio_tools::Vector< const char * > words, void *refx), void *ref)
 
void printCSV (Print &out)
 

Protected Member Functions

void add (const char *str)
 
void addAll (audio_tools::Vector< const char * > &words)
 
bool process (const char *unit, bool isOne)
 resolve keys until we end up with final words
 
bool process2 (const char *unit, bool isOne)
 
bool process1 (const char *unit, bool isOne)
 
bool isKey (const char *unit)
 
int idxCombinedUnit (const char *unit)
 
bool processCombinedUnit (int idx, bool isOne)
 
bool processDecimalUnit (int idx, bool isOne)
 
int decimalInfo (const char *unit)
 

Protected Attributes

const char * default_unit = nullptr
 
audio_tools::Vector< const char * > result
 
NumberToText ntt
 
const char * unit_1 [max_unit_1][3]
 
const char * unit2 [max_unit_2][4]
 
const char * unit3 [max_unit_3][2]
 
const DecimalInfo decimal_info [decimal_info_len] = {{"usd", 2}}
 
- Protected Attributes inherited from simple_tts::SimpleTTSBase
void(* callback )(audio_tools::Vector< const char * > word, void *ref) = nullptr
 
void * reference = nullptr
 

Static Protected Attributes

static const int max_unit_1 = 6
 
static const int max_unit_2 = 15
 units that can be constructed by combining words
 
static const int max_unit_3 = 6
 
static const int decimal_info_len = 1
 

Detailed Description

An extension of the Number to Text functionality which supports numbers with units of measures.

Author
Phil Schatzmann

Member Function Documentation

◆ allTexts()

virtual audio_tools::Vector< const char * > & simple_tts::NumberUnitToText::allTexts ( )
inlinevirtual

Provides all texts.

Implements simple_tts::SimpleTTSBase.

Member Data Documentation

◆ unit2

const char* simple_tts::NumberUnitToText::unit2[max_unit_2][4]
protected
Initial value:
= {{"mph", "miles", "per", "hour"},
{"C", "degrees", "celcius", nullptr},
{"F", "degrees", "fahrenheit", nullptr},
{"%", "percent", nullptr, nullptr},
{"lt", "liter", nullptr, nullptr},
{"ml", "milli", "lt", nullptr},
{"gr", "gram", nullptr, nullptr},
{"kg", "kilo", "gr", nullptr},
{"mg", "milli", "gr", nullptr},
{"km", "kilo", "m", nullptr},
{"m", "meter", nullptr, nullptr},
{"cm", "centi", "m", nullptr},
{"mm", "milli", "m", nullptr},
{"u.s.", "us", nullptr, nullptr},
{"usd", "u.s.", "$", nullptr}}

◆ unit3

const char* simple_tts::NumberUnitToText::unit3[max_unit_3][2]
protected
Initial value:
= {{"usd", "¢"}, {"gr", "mg"}, {"kg", "gr"},
{"m", "mm"}, {"km", "m"}, {"lt", "ml"}}

◆ unit_1

const char* simple_tts::NumberUnitToText::unit_1[max_unit_1][3]
protected
Initial value:
= {
{"lb", "pound", "pounds"}, {"ft", "foot", "feet"},
{"in", "inch", "inches"}, {"mi", "mile", "miles"},
{"$", "dollar", "dollars"}, {"¢", "cent", "cents"}}

The documentation for this class was generated from the following file: