static switch_status_t pl_say_general_count(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { int in; int x = 0; int places[9] = { 0 }; char sbuf[128] = ""; switch_status_t status; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "SAY: %s\n", tosay); if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { switch_say_file(sh, "digits/%c", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); if (in != 0) { for (x = 8; x >= 0; x--) { int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } switch (say_args->method) { case SSM_COUNTED: case SSM_PRONOUNCED: if ((status = play_group(SSM_PRONOUNCED, say_args->gender, places[8], places[7], places[6], "digits/1000000", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(SSM_PRONOUNCED, say_args->gender, places[5], places[4], places[3], "digits/1000", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(say_args->method, say_args->gender, places[2], places[1], places[0], NULL, sh)) != SWITCH_STATUS_SUCCESS) { return status; } break; default: break; } } else { switch_say_file(sh, "digits/0"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t de_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { int in; int x = 0; int places[9] = { 0 }; char sbuf[128] = ""; switch_status_t status; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { say_file("digits/%c.wav", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); if (in != 0) { /*fills the places-array with tosay(resp. in) from tail to front e.g. 84371 would be places[|1|7|3|4|8|0|0|0|], up to 1 billion minus 1*/ for (x = 8; x >= 0; x--) { int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } switch (say_args->method) { case SSM_COUNTED: case SSM_PRONOUNCED: if ((status = play_group(SSM_PRONOUNCED, say_args->gender, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(SSM_PRONOUNCED, say_args->gender, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(say_args->method, say_args->gender, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) { return status; } break; default: break; } } else { say_file("digits/0.wav"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t es_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { int in; int x = 0; int places[9] = { 0 }; char sbuf[13] = ""; switch_status_t status; if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); if (in != 0) { for (x = 8; x >= 0; x--) { int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } switch (say_args->method) { case SSM_COUNTED: case SSM_PRONOUNCED: if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) { return status; } break; case SSM_ITERATED: { char *p; for (p = tosay; p && *p; p++) { say_file("digits/%c.wav", *p); } } break; default: break; } } else { say_file("digits/0.wav"); } return SWITCH_STATUS_SUCCESS; }
//дописать static switch_status_t ru_say_general_count(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args,say_opt_t *say_opt) { switch_status_t status; cases_t cases; //падеж say_gender_t gender; //тип произношения char sbuf[128] = ""; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { switch_say_file(sh, "digits/%c", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } switch (say_args->type) { case SST_MESSAGES: gender = it; cases = nominativus; break; default: gender = male; cases = nominativus; if (say_opt->gender>0) { gender=say_opt->gender; // //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " opt_gender=%d type=%d cases=%d\n", gender, cases,say_opt->gender); } if (say_opt->cases>0) { cases=say_opt->cases; // //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " opt_gender=%d type=%d cases=%d\n", gender, cases,say_opt->gender); } break; }; //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " opt_gender=%d type=%d cases=%d\n", gender, cases,say_opt->gender); status = ru_say_count(sh, tosay, (say_gender_t)gender, (cases_t)cases); return status; }
static switch_status_t it_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { int in; int places_count = 0; int places[9] = { 0 }; char sbuf[128] = ""; switch_status_t status; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { say_file("digits/%c.wav", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } /* Get in */ in = atoi(tosay); /* Check if number too big */ if (in > 999999999) { /* Fail */ return SWITCH_STATUS_FALSE; } /* Check if number isn't zero */ if (in != 0) { /* Init x to 0 */ places_count = 0; /* Loop until in is greater than zero */ do { /* Get last digit */ places[places_count] = in % 10; /* Drop last digit */ in = in / 10; } while (in > 0 && ++places_count > 0 /* fake check to put in while */ ); switch (say_args->method) { case SSM_COUNTED: case SSM_PRONOUNCED: /* Check for milions */ if (places_count > 5) { /* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */ if (places[6] == 1 && places[7] == 0 && places[8] == 0) { say_file("digits/un.wav"); say_file("digits/million.wav"); } else { /* Play millions group (digits/million.wav should be digits/millions.wav) */ if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } } } /* Check for thousands */ if (places_count > 2) { if (places[3] == 1 && places[4] == 0 && places[5] == 0) { say_file("digits/thousand.wav"); } else { /* Play thousand group */ if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) { return status; } } } /* Play last group */ if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) { return status; } break; default: break; } } else { say_file("digits/0.wav"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t ru_say_count(switch_say_file_handle_t *sh, char *tosay, say_gender_t gender, cases_t cases) { int in; int x = 0; int places[9] = { 0 }; char sbuf[13] = ""; int in_; switch_status_t status; //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say_count %s! gender=%d causes=%d\n", tosay,gender,cases); if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); in_ = in; if (in != 0) { for (x = 8; x >= 0; x--) { int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } //миллионы if (places[8] || places[7] || places[6]) { if ((in_ % 1000000 > 0) && (matrix[cases][gender].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа if ((status = play_group(male, nominativus, places[8], places[7], places[6], million, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6], status); return status; } } else { // иначе произнести в нужном падеже if ((status = play_group(gender, cases, places[8], places[7], places[6], million, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6], status); return status; } } } //тысячи if (places[5] || places[4] || places[3]) { if ((in_ % 1000 > 0) && (matrix[cases][gender].all != 1)) { // если поле миллионов есть цифры поизнести как числительое именительного падежа if ((status = play_group(male, nominativus, places[5], places[4], places[3], thousand, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3], status); return status; } } else { // иначе произнести в нужном падеже if ((status = play_group(gender, cases, places[5], places[4], places[3], thousand, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3], status); return status; } } } // сотни if ((status = play_group(gender, cases, places[2], places[1], places[0], empty, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3], status); return status; } } else { if ((status = play_group(gender, cases, places[2], places[1], places[0], zero, sh)) != SWITCH_STATUS_SUCCESS) { //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d other!\n", places[2], places[1], places[0]); return status; } } return SWITCH_STATUS_SUCCESS; }
static switch_status_t th_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { int in; char sbuf[128] = ""; char digits[11]; int i; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { say_file("digits/%c.wav", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); if (in != 0) { snprintf(digits, sizeof(digits), "%10.10d", in); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n", digits); switch (say_args->method) { case SSM_COUNTED: say_file("digits/ordinal.wav"); /* Fall through */ case SSM_PRONOUNCED: for (i = 0; i <= 9; i++) { switch (i) { case 0: /* Billions column */ if (digits[i] != '0') { if (digits[i] != '1') say_file("digits/%c.wav", digits[i]); say_file("digits/10.wav"); } break; case 1: /* Hundred millions columns */ if (digits[i] != '0') say_file("digits/%c.wav", digits[i]); if (memcmp(digits, "00", 2) != 0) say_file("digits/100000000.wav"); break; case 2: /* ten Millions column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); say_file("digits/10000000.wav"); } break; case 3: /* Millions column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); say_file("digits/1000000.wav"); } break; case 4: /* Hundred thousands column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); if (memcmp(digits + 2, "00000", 4) != 0) say_file("digits/100000.wav"); } break; case 5: /* Ten thousands column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); if (memcmp(digits + 2, "0000", 4) != 0) say_file("digits/10000.wav"); } break; case 6: /* Ten millions or thousands column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); say_file("digits/1000.wav"); } break; case 7: /* hundreds column */ if (digits[i] != '0') { say_file("digits/%c.wav", digits[i]); say_file("digits/100.wav"); } break; case 8: /* Tens column */ if (digits[i] != '0') { if (digits[i] == '2') { say_file("digits/20.wav"); break; } if (digits[i] == '1') { say_file("digits/10.wav"); break; } if (digits[i] != '1' || memcmp(digits, "00000000", 8) != 0) { say_file("digits/%c.wav", digits[i]); } } if (digits[8] != '0') say_file("digits/10.wav"); break; case 9: /* Units column */ if (digits[9] == '1') { if (digits[8] != '0') { say_file("digits/ed.wav", digits[i]); } else { say_file("digits/%c.wav", digits[i]); } break; } if (digits[9] != '0') say_file("digits/%c.wav", digits[i]); break; } } break; default: break; } } else { say_file("digits/0.wav"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t sin_say_general_count(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { int in; int x = 0; int places[9] = { 0 }; char sbuf[128] = ""; switch_status_t status; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { switch_say_file(sh, "digits/%c", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 9) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } in = atoi(tosay); if (in != 0) { for (x = 8; x >= 0; x--) { int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } switch (say_args->method) { case SSM_PRONOUNCED_YEAR: { int num = atoi(tosay); int a = num / 100; int b = num % 100; if (!b || !(a % 10)) { say_num(sh, num, SSM_PRONOUNCED); return SWITCH_STATUS_SUCCESS; } say_num(sh, a, SSM_PRONOUNCED); say_num(sh, b, SSM_PRONOUNCED); return SWITCH_STATUS_SUCCESS; } break; case SSM_COUNTED: case SSM_PRONOUNCED: if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/s_million", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if(places[2] == 0 && places[1] == 0 && places[0] == 0) { if ((status = play_group1(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/s_i-thousand", sh)) != SWITCH_STATUS_SUCCESS) { return status; } } else { if ((status = play_group1(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/s_k-thousand", sh)) != SWITCH_STATUS_SUCCESS) { return status; } } if ((status = play_group2(say_args->method, places[2], places[1], places[0], NULL, sh)) != SWITCH_STATUS_SUCCESS) { return status; } break; default: break; } } else { switch_say_file(sh, "digits/0"); } return SWITCH_STATUS_SUCCESS; }
static switch_status_t vi_say_general_count(switch_say_file_handle_t *sh, char *tosay, switch_say_args_t *say_args) { double in; //int in; int x = 0; int places[12] = { 0 }; char sbuf[128] = ""; char *f1,*f2; int fi1; switch_status_t status; if (say_args->method == SSM_ITERATED) { if ((tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1))) { char *p; for (p = tosay; p && *p; p++) { switch_say_file(sh, "digits/%c", *p); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } return SWITCH_STATUS_SUCCESS; } //Xu ly cac so co phan thap phan if (!(f1 = strdup(tosay))) { abort(); } f2 = strchr(f1, '.'); if(f2) { *f2++ = '\0'; fi1= atoi(f1); //itoa(fi1,tosay,10); sprintf(tosay, "%d", fi1); } if (!(tosay = switch_strip_commas(tosay, sbuf, sizeof(sbuf)-1)) || strlen(tosay) > 12) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n"); return SWITCH_STATUS_GENERR; } //in = atoi(tosay); in = atof(tosay); if (in != 0) { for (x = 12; x >= 0; x--) { double num = (double) pow(10, x); //int num = (int) pow(10, x); if ((places[(uint32_t) x] = in / num)) { in -= places[(uint32_t) x] * num; } } switch (say_args->method) { case SSM_PRONOUNCED_YEAR: { int num = atoi(tosay); int a = num / 100; int b = num % 100; if (!b || !(a % 10)) { say_num(sh, num, SSM_PRONOUNCED); return SWITCH_STATUS_SUCCESS; } say_num(sh, a, SSM_PRONOUNCED); say_num(sh, b, SSM_PRONOUNCED); return SWITCH_STATUS_SUCCESS; } break; case SSM_COUNTED: case SSM_PRONOUNCED: if ((status = play_group(SSM_PRONOUNCED, places[11], places[10], places[9], "digits/billion", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand", sh)) != SWITCH_STATUS_SUCCESS) { return status; } if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, sh)) != SWITCH_STATUS_SUCCESS) { return status; } //Doc phan thap phan if(f2){ switch_say_file(sh, "digits/dot"); say_num(sh, atoi(f2), say_args->method); } break; default: break; } } else { switch_say_file(sh, "digits/0"); } return SWITCH_STATUS_SUCCESS; }