def pronounce_number(number, lang="en-us", places=2, short_scale=True, scientific=False): """ Convert a number to it's spoken equivalent For example, '5' would be 'five' Args: number: the number to pronounce short_scale (bool) : use short (True) or long scale (False) https://en.wikipedia.org/wiki/Names_of_large_numbers scientific (bool) : convert and pronounce in scientific notation Returns: (str): The pronounced number """ lang_lower = str(lang).lower() if lang_lower.startswith("en"): return pronounce_number_en(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_lower.startswith("it"): return pronounce_number_it(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_lower.startswith("fr"): return pronounce_number_fr(number, places=places) elif lang_lower.startswith("de"): return pronounce_number_de(number, places=places) elif lang_lower.startswith("hu"): return pronounce_number_hu(number, places=places) elif lang_lower.startswith("nl"): return pronounce_number_nl(number, places=places) # Default to just returning the numeric value return str(number)
def pronounce_number(number, lang=None, places=2, short_scale=True, scientific=False): """ Convert a number to it's spoken equivalent For example, '5' would be 'five' Args: number: the number to pronounce short_scale (bool) : use short (True) or long scale (False) https://en.wikipedia.org/wiki/Names_of_large_numbers scientific (bool) : convert and pronounce in scientific notation Returns: (str): The pronounced number """ lang_code = get_primary_lang_code(lang) if lang_code == "en": return pronounce_number_en(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_code == "it": return pronounce_number_it(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_code == "es": return pronounce_number_es(number, places=places) elif lang_code == "fr": return pronounce_number_fr(number, places=places) elif lang_code == "de": return pronounce_number_de(number, places=places) elif lang_code == "hu": return pronounce_number_hu(number, places=places) elif lang_code == "nl": return pronounce_number_nl(number, places=places) elif lang_code == "da": return pronounce_number_da(number, places=places) elif lang_code == "pt": return pronounce_number_pt(number, places=places) elif lang_code == "sv": return pronounce_number_sv(number, places=places) # Default to just returning the numeric value return str(number)
def pronounce_number(number, lang=None, places=2, short_scale=True, scientific=False): """ Convert a number to it's spoken equivalent For example, '5' would be 'five' Args: number: the number to pronounce short_scale (bool) : use short (True) or long scale (False) https://en.wikipedia.org/wiki/Names_of_large_numbers scientific (bool) : convert and pronounce in scientific notation Returns: (str): The pronounced number """ lang_code = get_primary_lang_code(lang) if lang_code == "en": return pronounce_number_en(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_code == "it": return pronounce_number_it(number, places=places, short_scale=short_scale, scientific=scientific) elif lang_code == "es": return pronounce_number_es(number, places=places) elif lang_code == "fr": return pronounce_number_fr(number, places=places) elif lang_code == "de": return pronounce_number_de(number, places=places) elif lang_code == "hu": return pronounce_number_hu(number, places=places) elif lang_code == "nl": return pronounce_number_nl(number, places=places) elif lang_code == "da": return pronounce_number_da(number, places=places) elif lang_code == "pt": return pronounce_number_pt(number, places=places) # Default to just returning the numeric value return str(number)