Index: say.c =================================================================== --- say.c (revision 209626) +++ say.c (working copy) @@ -350,6 +350,7 @@ static int ast_say_number_full_hu(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); static int ast_say_number_full_th(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); static int ast_say_number_full_ur(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd); +static int ast_say_number_full_vi(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); /* Forward declarations of language specific variants of ast_say_enumeration_full */ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd); @@ -496,6 +497,8 @@ return ast_say_number_full_zh(chan, num, ints, language, audiofd, ctrlfd); } else if (!strncasecmp(language, "ur", 2)) { /* Urdu syntax */ return ast_say_number_full_ur(chan, num, ints, language, options, audiofd, ctrlfd); + } else if (!strncasecmp(language, "vi", 2)) { /* Vietnamese syntax */ + return ast_say_number_full_vi(chan, num, ints, language, audiofd, ctrlfd); } /* Default to english */ @@ -2612,6 +2615,105 @@ return res; } +/*! \brief ast_say_number_full_vi: Vietnamese syntax */ +/*! \brief additional files: + 5l.gsm (nham) + 0-hundred.gsm (0 tram) + 0-hundred-odd.gsm (0 tram le) + + where 'n' from 1 to 9 +*/ + +static int ast_say_number_full_vi(struct ast_channel *chan, int num, const char *ints, const char *language, int audiofd, int ctrlfd) +{ + int res = 0; + int playh = 0; + int playoh = 0; + int playohz = 0; + int playz = 0; + int playl = 0; + char fn[256] = ""; + if (!num) + return ast_say_digits_full(chan, 0, ints, language, audiofd, ctrlfd); + while (!res && (num || playh)) { + if (num < 0) { + ast_copy_string(fn, "digits/minus", sizeof(fn)); + if ( num > INT_MIN ) { + num = -num; + } else { + num = 0; + } + } else if (playl) { + ast_copy_string(fn, "digits/5l", sizeof(fn)); + playl = 0; + num = 0; + } else if (playh) { + ast_copy_string(fn, "digits/hundred", sizeof(fn)); + playh = 0; + } else if (playz) { + ast_copy_string(fn, "digits/odd", sizeof(fn)); + playz = 0; + } else if (playoh) { + ast_copy_string(fn, "digits/0-hundred", sizeof(fn)); + playoh = 0; + } else if (playohz) { + ast_copy_string(fn, "digits/0-hundred-odd", sizeof(fn)); + playohz = 0; + } else if (num < 20) { + snprintf(fn, sizeof(fn), "digits/%d", num); + num = 0; + } else if (num < 100) { + snprintf(fn, sizeof(fn), "digits/%d", (num /10) * 10); + num %= 10; + if (num == 5) playl++; + } else { + if (num < 1000){ + snprintf(fn, sizeof(fn), "digits/%d", (num/100)); + num %= 100; + if (num && (num < 10)){ + playz ++; /* 907 = 9 + hundred + odd + 7 */ + playh++; + } else { + playh++; /* just like English */ + } + } else { + if (num < 1000000) { /* 1,000,000 */ + res = ast_say_number_full_vi(chan, num / 1000, ints, language, audiofd, ctrlfd); + if (res) + return res; + num %= 1000; + snprintf(fn, sizeof(fn), "digits/thousand"); + if (num && (num < 10)){ + playohz ++; /* 1003 = 1 + thousand + 0 + hundred + odd + 3 */ + } else if (num && (num < 100)){ + playoh ++; /* 1024 = 1 + thousand + 0 + hundred + 20 + 4 */ + } + } else { + if (num < 1000000000) { /* 1,000,000,000 */ + res = ast_say_number_full_vi(chan, num / 1000000, ints, language, audiofd, ctrlfd); + if (res) + return res; + num %= 1000000; + ast_copy_string(fn, "digits/million", sizeof(fn)); + } else { + res = -1; + } + } + } + } + if (!res) { + if (!ast_streamfile(chan, fn, language)) { + if ((audiofd > -1) && (ctrlfd > -1)) + res = ast_waitstream_full(chan, ints, audiofd, ctrlfd); + else + res = ast_waitstream(chan, ints); + } + ast_stopstream(chan); + } + } + return res; +} + /*! \brief ast_say_enumeration_full: call language-specific functions */ /* Called from AGI */ static int say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)