Menu

is posible translate text numbers in numbers?

Help
Pablo
2011-06-09
2012-09-22
  • Pablo

    Pablo - 2011-06-09

    Hi my question is the next.

    when i speak and pocketsphinx return the hyp, it is like that:

    robot move head up five degrees
    

    ok, i need that:

    robot move head up 5 degrees
    

    it is posible convert

    five in 5??

    i am ussing fsg like this:

    #JSGF V1.0;
    
        grammar gram;
        public <gram> = [<rob>] <order> | [<rob>] <order> <location> <side> <quantity>;
    
    <rob> = robot
    ;
    
    <order> =  move 
            | greetings
            | hello
            | hi
            | goodbye
            | bye
    ;
    
    <location> = walking
            | head
            | turning
    ;
    <side> = left 
            | right
            | up
            | down
    ;
    
    <quantity> = <zerodigit>| <digit>| <below20>| <tens> [<digit>];
    
    <zerodigit> = zero 
            | oh
    ;
    
    <digit> = one 
            | two
            | three 
            | four  
            | five 
            | six   
            | seven 
            | eight 
            | nine
    ;
    <below20> = ten 
            | eleven 
            | twelve 
            | thirteen 
            | fourteen  
            | fifteen 
            | sixteen 
            | seventeen 
            | eighteen 
            | nineteen
    ;
    <tens> = twenty 
            | thirty
            | forty 
            | fifty 
            | sixty
            | seventy
            | eighty
            | ninety
    ;
    
    <unit> =  step
            | steps 
            | degrees
    ;
    
     
  • Nickolay V. Shmyrev

    Hello

    You need to write your own postprocessing code that will do that. For example
    it might be fifty seven or seventy eight. You need to analyze the text and
    convert it to 57 or 78.

     
  • Pablo

    Pablo - 2011-06-10

    But..... I have proces 100 numbers?? like that?
    I suppose that cadena have the text number

    if (strcmp(cadena[4], "five") == 0)
        strcmp(cadena[4], "5");
    

    really?
    with all numbers?

    this is insane, there must be something to translate the text number in
    number. Something like that, if you want the number, the grammar (fsg) looks
    like that:

    <digit> = one%1 | two%2 | three%3 | four%4 | five%5 | six%6 | seven%7 | eight%8 | nine%9 ;
    

    This isn't work, i need some help please, any idea?

     
  • Pranav Jawale

    Pranav Jawale - 2011-06-10

    I haven't used pocketsphinx but in sphinx you can write dictionary words which
    are actually numbers, as long as they precede with an underscore. e.g. _5 ,
    _58

    You can strip off _ from decoder output to get what you want.

     
  • Pablo

    Pablo - 2011-06-10

    So thanks!! I don't know that.

    I try and coment soon :D

     
  • Nickolay V. Shmyrev

    this is insane,

    It depends how you will implement this. Reasonable implementation shouldn't
    take more than 100 lines of code

    there must be something to translate the text number in number.

    Yes, but nobody contributed this part yet

    as long as they precede with an underscore. e.g. _5 , _58 You can strip off
    _ from decoder output to get what you want.

    This will not work great with things like "fifty eigth" which will be "_50 _8"
    and you need a postprocessing anyway.

     
  • Nickolay V. Shmyrev

    For example how is it done in real dialog systems you can check Olympus

    http://wiki.speech.cs.cmu.edu/olympus/index.php/DateTime

    Which has all functionality implemented. The only issue is that it's a huge
    software package doing many things beside the specified task.

     
  • Pablo

    Pablo - 2011-06-14

    hi! I try to write

    <digit> = one_1
    | two_2
    | three_3
    ...
    ;
    But it doesn't work :( </digit>

    ERROR: "fsg_search.c", line 332: The word '_1' is missing in the dictionary

    and, I am working on one robot calls HOAP-3 and I havn't more free space to
    install Olympus,

    what must I do?

    Any ideas?? Please help me!!! :(

     
  • Pranav Jawale

    Pranav Jawale - 2011-06-14

    Hi,

    Words in FSG need to exactly match with words in dictionary, otherwise such
    errors will come. Which words are there in your dictionary?

     
  • Pablo

    Pablo - 2011-06-14

    well, in the dic I have this:

    turtle.dic

    match with the default dic:

    a                              AH
    a(2)                           EY
    and                            AE N T
    and(2)                         AH N T
    are                            AA R
    are(2)                         ER
    around                         ER AW N
    around(2)                      ER AW N T
    backward                       B AE K W ER T
    backwards                      B AE K W ER D Z
    bye                            B AY
    centimeter                     S EH N T AH M IY T ER
    centimeters                    S EH N T AH M IY T ER Z
    chase                          CH EY S
    color                          K AH L ER
    color(2)                       K AO L ER
    degrees                        D IH G R IY Z
    display                        D IH S P L EY
    do                             D UW
    doing                          D UW IH NG
    eight                          EY T
    eighteen                       EY T IY N
    eighty                         EY T IY
    eleven                         AH L EH V AH N
    eleven(2)                      IY L EH V AH N
    exit                           EH G Z AH T
    exit(2)                        EH K S AH T
    explore                        IH K S P L AO R
    fifteen                        F IH F T IY N
    fifty                          F IH F T IY
    find                           F AY N T
    finish                         F IH N IH SH
    five                           F AY V
    forty                          F AO R T IY
    forward                        F AO R W ER T
    four                           F AO R
    fourteen                       F AO R T IY N
    go                             G OW
    grey                           G R EY
    guard                          G AA R T
    half                           HH AE F
    hall                           HH AO L
    hallway                        HH AO L W EY
    halt                           HH AO L T
    hello                          HH AH L OW
    hello(2)                       HH EH L OW
    home                           HH OW M
    hundred                        HH AH N ER T
    hundred(2)                     HH AH N D ER T
    hundred(3)                     HH AH N D R AH T
    kevin                          K EH V IH N
    lab                            L AE T
    left                           L EH F T
    listening                      L IH S AH N IH NG
    listening(2)                   L IH S N IH NG
    lost                           L AO S T
    meter                          M IY T ER
    meters                         M IY T ER Z
    minus                          M AY N AH S
    nine                           N AY N
    nineteen                       N AY N T IY N
    ninety                         N AY N T IY
    office                         AO F AH S
    one                            HH W AH N
    one(2)                         W AH N
    person                         P ER S AH N
    quarter                        K AO R T ER
    quarter(2)                     K W AO R T ER
    quarters                       K W AO R T ER Z
    quit                           K W IH T
    ready                          R EH D IY
    reid                           R IY T
    right                          R AY T
    roboman                        R AA B AH M AH N
    room                           R UW M
    rotate                         R OW T EY T
    say                            S EY
    sebastian                      S AH B AE S CH AH N
    seven                          S EH V AH N
    seventeen                      S EH V AH N T IY N
    seventy                        S EH V AH N IY
    seventy(2)                     S EH V AH N T IY
    six                            S IH K S
    sixteen                        S IH K S T IY N
    sixteen(2)                     S IH K S T IY N
    sixty                          S IH K S T IY
    stop                           S T AA T
    ten                            T EH N
    the                            DH AH
    the(2)                         DH AH
    the(3)                         DH IY
    then                           DH EH N
    thirteen                       TH ER T IY N
    thirty                         TH ER T IY
    three                          TH R IY
    to                             T AH
    to(2)                          T IH
    to(3)                          T UW
    tom                            T AA M
    turn                           T ER N
    twelve                         T W EH L V
    twenty                         T W EH N IY
    twenty(2)                      T W EH N T IY
    two                            T UW
    understand                     AH N D ER S T AE N T
    wander                         W AA N D ER
    what                           HH W AH T
    what(2)                        W AH T
    window                         W IH N D OW
    you                            Y UW
    

    do you recomend that I must change??

    I only want to reconoce this sentences:

    robot hello
    robot goodbye
    robot move turning right <number> degrees
    robot move turning left <number> degrees
    robot move walking forward <number> steps
    robot move walking backward <number> steps
    robot move head up <number> degrees
    robot move head down <number> degrees
    robot move head right <number> degrees
    robot move head left <number> degrees
    

    only this and always in this order, Sometimes auto-recognition has wrong hyp
    like:
    hello robot five bye step
    or something like that and I can't fix.

    What must I do to improve the accuracy?

    Now, I program the translation of the numbers like that:

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #define FILAS 10
    
    int delunoalnueve(char* cadena);
    
    int main()
    {
        char *t1,frase[50];
        char cadena[FILAS][50],orden[50];
        int j,k,i=0,f=0,numero,valor;
        const char hyp[]="move turning ninety five degrees";
    
    
        for(f=0;f<i;f++)
        {
            sprintf(cadena[f],"%s","\0");
        }
        i=0;
        for ( t1 = strtok((char*)hyp," ");t1 != NULL;t1 = strtok(NULL, " ") )
        {
            printf("t1:%s\n",t1);
            sscanf(t1, "%s", cadena[i]);
            i++;
        }
        for (f=0; f<i; f++)
        {
            printf("cadena:%s\n", cadena[f]);
        }
    
        for(f=0;f<i;f++)
        {
            valor=delunoalnueve(cadena[f]);
            if(valor != 0)
            {
                numero=valor;
                break;
            }
            else if(strcmp(cadena[f],"ten") == 0){
                numero=10;
                break;
            }
            else if(strcmp(cadena[f],"eleven") == 0){
                numero=11;
                break;
            }
            else if(strcmp(cadena[f],"twelve") == 0){
                numero=12;
                break;
            }
            else if(strcmp(cadena[f],"fourteen") == 0){
                numero=14;
                break;
            }
            else if(strcmp(cadena[f],"fifteen") == 0){
                numero=15;
                break;
            }
            else if(strcmp(cadena[f],"sixteen") == 0){
                numero=16;
                break;
            }
            else if(strcmp(cadena[f],"seventeen") == 0){
                numero=17;
                break;
            }
            else if(strcmp(cadena[f],"eighteen") == 0){
                numero=18;
                break;
            }
            else if(strcmp(cadena[f],"nineteen") == 0){
                numero=19;
                break;
            }
            else if(strcmp(cadena[f],"twenty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0)
                {
                    numero=20+valor;
                    break;
                }
                else
                {
                    numero=20;
                    break;
                }
            }
            else if(strcmp(cadena[f],"thirty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0)
                {
                    numero=30+valor;
                    break;
                }
                else
                {
                    numero=30;
                    break;
                }
            }
            else if(strcmp(cadena[f],"fourty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=40+valor;
                    break;
                }
                else
                {
                    numero=40;
                    break;
                }
            }
            else if(strcmp(cadena[f],"fifty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=50+valor;
                    break;
                }
                else
                {
                    numero=50;
                    break;
                }
            }
            else if(strcmp(cadena[f],"sixty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=60+valor;
                    break;
                }
                else
                {
                    numero=60;
                    break;
                }
            }
            else if(strcmp(cadena[f],"seventy") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=70+valor;
                    break;
                }
                else
                {
                    numero=70;
                    break;
                }
            }
            else if(strcmp(cadena[f],"eighty") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=80+valor;
                    break;
                }
                else
                {
                    numero=80;
                    break;
                }
            }
            else if(strcmp(cadena[f],"ninety") == 0){
                valor=delunoalnueve(cadena[f+1]);
                if (valor != 0){
                    numero=90+valor;
                    break;
                }
                else
                {
                    numero=90;
                    break;
                }
            }
        }
        sprintf(orden, "%s %i %s","MOVE TURNING LEFT", numero,"DEGREES\n");
        printf("%s",orden);
    /*
        for(j=0;j<=10;j++)
        {
            printf("\n");
            for(k=0;k<50;k++){
                printf("%i ",cadena[k][j]);
            }
            printf("\n");
    
        }
        for(j=0;j<=10;j++)
        {
            printf("\n");
            for(k=0;k<50;k++){
                printf("%s ",&cadena[k][j]);
            }
        }
        for(j=0;j<=10;j++)
        {
            printf("\n");
            for(k=0;k<50;k++){
                printf("%s ",*cadena);
            }
        }*/
    }
    
    
    
    int delunoalnueve(char* cadena)
    {
        if(strcmp(cadena,"one") == 0)
            return 1;
        else if(strcmp(cadena,"two") == 0)
            return 2;
        else if(strcmp(cadena,"three") == 0)
            return 3;
        else if(strcmp(cadena,"four") == 0)
            return 4;
        else if(strcmp(cadena,"five") == 0)
            return 5;
        else if(strcmp(cadena,"six") == 0)
            return 6;
        else if(strcmp(cadena,"seven") == 0)
            return 7;
        else if(strcmp(cadena,"eight") == 0)
            return 8;
        else if(strcmp(cadena,"nine") == 0)
            return 9;
        else
            return 0;
    }
    

    if someone like it, take it, It works fine.

     
  • Pablo

    Pablo - 2011-06-14

    ups, I have this in my program, It is weird to run?

    config = cmd_ln_init(NULL, ps_args(), TRUE,
    "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k",
    "-lm", MODELDIR "/lm/en/turtle.DMP",
    "-jsgf","/usr/share/pocketsphinx/grammar/HoapGrammar.jsgf",NULL);

    I don't have .dic indeed.

    I must load?? or with my jsgf run?

    #JSGF V1.0;
    
        grammar gram;
        public <gram> = [<rob>] <order> | [<rob>] <order> <location> <side> <quantity>;
    
    <rob> = robot
    ;
    
    <order> =  move 
            | greetings
            | hello
            | hi
            | goodbye
            | bye
    ;
    
    <location> = walking
            | head
            | turning
    ;
    <side> = left 
            | right
            | up
            | down
            | forward
            | backward
    ;
    
    <quantity> = <zerodigit>| <digit>| <below20>| <tens> [<digit>];
    
    <zerodigit> = zero 
            | oh
    ;
    
    <digit> = one 
            | two
            | three 
            | four  
            | five 
            | six   
            | seven 
            | eight 
            | nine
    ;
    <below20> = ten 
            | eleven 
            | twelve 
            | thirteen 
            | fourteen  
            | fifteen 
            | sixteen 
            | seventeen 
            | eighteen 
            | nineteen
    ;
    <tens> = twenty 
            | thirty
            | forty 
            | fifty 
            | sixty
            | seventy
            | eighty
            | ninety
    ;
    
    <unit> =  step
            | steps 
            | degrees
    ;
    
     
  • Nickolay V. Shmyrev

    "-lm", MODELDIR "/lm/en/turtle.DMP",
    "-jsgf","/usr/share/pocketsphinx/grammar/HoapGrammar.jsgf"

    You need to specify either language model or jsgf grammar. There is no sense
    to specify both. Remove

    "-lm", MODELDIR "/lm/en/turtle.DMP"

    part

    You need to specify a dictionary

    To improve accuracy you need to measure it first, you can find some
    information on that in the tutorial

    http://cmusphinx.sourceforge.net/wiki/tutorialam

    Now, I program the translation of the numbers like that:

    This is a nice piece of code, it would be cool to make it a part of
    pocketsphinx. Can you make a patch for pocketsphinx?

     

Log in to post a comment.