diff --git a/audio_generator/slownik.php b/audio_generator/slownik.php index 06bae8c..3fc7153 100755 --- a/audio_generator/slownik.php +++ b/audio_generator/slownik.php @@ -147,12 +147,17 @@ $slownik_wszystkie = array( array('Średnia wartość dobowa'), array('mikrosjiwerta'), array('na godzinę'), + array('jedna'), + array('dwie'), array('setna'), array('setne'), array('setnych'), array('dziesiąta'), array('dziesiąte'), array('dziesiątych'), + array('tysięczna'), + array('tysięczne'), + array('tysięcznych'), /* * * diff --git a/pl_google/dwie.ogg b/pl_google/dwie.ogg new file mode 100644 index 0000000..0327c44 Binary files /dev/null and b/pl_google/dwie.ogg differ diff --git a/pl_google/jedna.ogg b/pl_google/jedna.ogg new file mode 100644 index 0000000..3c53dba Binary files /dev/null and b/pl_google/jedna.ogg differ diff --git a/pl_google/pl_google.py b/pl_google/pl_google.py index 2a8d21a..c1aa8a8 100755 --- a/pl_google/pl_google.py +++ b/pl_google/pl_google.py @@ -78,13 +78,21 @@ class PLGoogle(SR0WXLanguage): pass @remove_accents - def read_number(self, value, units=None): + def read_number(self, value, units=None, isFraction=None): """Converts numbers to text.""" if units is None: retval = pyliczba.lslownie(abs(value)) else: retval = pyliczba.cosslownie(abs(value), units) + if isFraction: + if value % 1 == 0 and retval.startswith(u("jeden ")): + retval = retval.replace(u("jeden "), u("jedna ")) + if value % 2 == 0 and retval.startswith(u("dwa ")): + retval = retval.replace(u("dwa "), u("dwie ")) + if value % 10 % 2 == 0: + retval = retval.replace(u("dwa "), u("dwie ")) + if retval.startswith(u("jeden tysiąc")): retval = retval.replace(u("jeden tysiąc"), u("tysiąc")) if value < 0: @@ -142,21 +150,30 @@ class PLGoogle(SR0WXLanguage): @remove_accents def read_decimal(self, value): + deg1000 = [ + u("tysie_czna"), + u("tysie_czne"), + u("tysie_cznych") + ] + deg100 = [ u("setna"), u("setne"), - u("setnych"), + u("setnych"), ] deg10 = [ u("dziesia_ta"), u("dziesia_te"), - u("dziesia_tych"), + u("dziesia_tych"), ] - if value >= 10: - return read_number(value, deg100) + + if (value % 100 == 0 and value >= 100): + return read_number( value / 100, deg10, True) + elif (value % 10 == 0 and value > 9 ): + return read_number( value / 10, deg100, True) else: - return read_number(value, deg10) + return read_number(value, deg1000, True) @remove_accents def read_direction(self, value, short=False): diff --git a/pl_google/tysie_czna.ogg b/pl_google/tysie_czna.ogg new file mode 100644 index 0000000..cf71832 Binary files /dev/null and b/pl_google/tysie_czna.ogg differ diff --git a/pl_google/tysie_czne.ogg b/pl_google/tysie_czne.ogg new file mode 100644 index 0000000..db11505 Binary files /dev/null and b/pl_google/tysie_czne.ogg differ diff --git a/pl_google/tysie_cznych.ogg b/pl_google/tysie_cznych.ogg new file mode 100644 index 0000000..e825a9e Binary files /dev/null and b/pl_google/tysie_cznych.ogg differ diff --git a/pl_google_male/dwie.ogg b/pl_google_male/dwie.ogg new file mode 100644 index 0000000..023d5af Binary files /dev/null and b/pl_google_male/dwie.ogg differ diff --git a/pl_google_male/jedna.ogg b/pl_google_male/jedna.ogg new file mode 100644 index 0000000..360c921 Binary files /dev/null and b/pl_google_male/jedna.ogg differ diff --git a/pl_google_male/pl_google.py b/pl_google_male/pl_google.py index 2a8d21a..3116165 100755 --- a/pl_google_male/pl_google.py +++ b/pl_google_male/pl_google.py @@ -78,13 +78,21 @@ class PLGoogle(SR0WXLanguage): pass @remove_accents - def read_number(self, value, units=None): + def read_number(self, value, units=None, isFraction=None): """Converts numbers to text.""" if units is None: retval = pyliczba.lslownie(abs(value)) else: retval = pyliczba.cosslownie(abs(value), units) + if isFraction: + if value % 1 == 0 and retval.startswith(u("jeden ")): + retval = retval.replace(u("jeden "), u("jedna ")) + if value % 2 == 0 and retval.startswith(u("dwa ")): + retval = retval.replace(u("dwa "), u("dwie ")) + if value % 10 % 2 == 0: + retval = retval.replace(u("dwa "), u("dwie ")) + if retval.startswith(u("jeden tysiąc")): retval = retval.replace(u("jeden tysiąc"), u("tysiąc")) if value < 0: @@ -142,21 +150,30 @@ class PLGoogle(SR0WXLanguage): @remove_accents def read_decimal(self, value): + deg1000 = [ + u("tysie_czna"), + u("tysie_czne"), + u("tysie_cznych") + ] + deg100 = [ u("setna"), u("setne"), - u("setnych"), + u("setnych"), ] deg10 = [ u("dziesia_ta"), u("dziesia_te"), - u("dziesia_tych"), + u("dziesia_tych"), ] - if value >= 10: - return read_number(value, deg100) + + if (value % 100 == 0 and value >= 100): + return read_number( value / 100, deg10, True) + elif (value % 10 == 0 and value > 9 ): + return read_number( value / 10, deg100, True) else: - return read_number(value, deg10) + return read_number(value, deg1000, True) @remove_accents def read_direction(self, value, short=False): @@ -340,3 +357,4 @@ read_direction = pl.read_direction read_datetime = pl.read_datetime read_callsign = pl.read_callsign + diff --git a/pl_google_male/tysie_czna.ogg b/pl_google_male/tysie_czna.ogg new file mode 100644 index 0000000..31865cc Binary files /dev/null and b/pl_google_male/tysie_czna.ogg differ diff --git a/pl_google_male/tysie_czne.ogg b/pl_google_male/tysie_czne.ogg new file mode 100644 index 0000000..a42dd82 Binary files /dev/null and b/pl_google_male/tysie_czne.ogg differ diff --git a/pl_google_male/tysie_cznych.ogg b/pl_google_male/tysie_cznych.ogg new file mode 100644 index 0000000..bdefb2c Binary files /dev/null and b/pl_google_male/tysie_cznych.ogg differ diff --git a/radioactive_sq9atk.py b/radioactive_sq9atk.py index a4e688e..d028720 100755 --- a/radioactive_sq9atk.py +++ b/radioactive_sq9atk.py @@ -77,8 +77,8 @@ class RadioactiveSq9atk(SR0WXModule): self.__logger.info("::: Przetwarzam dane...\n") data = self.getSensorData(html) - msvCurrent = int(float(data['current'])*100) - msvAverage = int(float(data['average'])*100) + msvCurrent = int(float(data['current'])*1000) + msvAverage = int(float(data['average'])*1000) averageValue = " ".join(["wartos_c__aktualna",self.__language.read_decimal( msvCurrent )+" ","mikrosjiwerta","na_godzine_"]) currentValue = " ".join(["s_rednia_wartos_c__dobowa",self.__language.read_decimal( msvAverage )+" ","mikrosjiwerta","na_godzine_"])