I used pocketsphinx speech recognition program for speech to text application. I created my own acoustic model in German for some 50 commands. A part of it is to recognize a persons ID. When i say Fahrerkennung, It should wait till you say your four digit ID. Initially i did it with Numbers 1,2,3. After any four numbers are recognized ..It will give output
I have changed my Acoustic model from 1,2,3... to EINS, ZWEI, DREI....(German numbers). That means Instead of direkt 1,2,3 ... we have the word representation of numbers like ONE, TWO, THREE--- we have EINS, ZWEI , DREI in German..
I am confused How to get this similar to what i did here using digits(see below) !! Now they are nomore numbers at the output of hyp, so we will get "EINS DREI VIER FüNF"
I want to only print output if any of the four combinations from the set of Numbers "EINS ZWEI DREI VIER FüNF SECHS SIEBEN ACHT NEUN NULL" is occured and rest(if i say someother command apart from four numbers) should be ignored.It should be done using C programming
Initially the recognized texts are stored in a vriable 'hyp'
else if (strcmp(word, "FAHRERKENNUNG") == 0 &&(token==500))
{
//counter_correct = counter_correct + 1;
token = 496;
printf("Fahrerkennung on process \n");
//printf("token number %d\n", token);
printf("Enter the four digit of your drivers id \n");
}
else if(isdigit(hyp[0])
&& isdigit(hyp[2])
&& isdigit(hyp[4])
&& isdigit(hyp[6])
&& (token==496))
{
counter_correct = counter_correct + 1;
sscanf(hyp,"%d %d %d %d",&Nummer1,&Nummer2,&Nummer3,&Nummer4);
if(Nummer1==0)
{
id = Nummer1*1000+Nummer2*100+Nummer3*10+Nummer4;
printf("The drivers id detected %.4d \n",id);
//printf("%s: %s\n", uttid, hyp);
printf("score %d/%s \n",counter_correct,uttid);
token=500;
}
else
{
id = Nummer1*1000+Nummer2*100+Nummer3*10+Nummer4;
counter_correct = counter_correct + 1;
printf("The drivers id detected %d \n",id);
//printf("%s: %s\n", uttid, hyp);
printf("score %d/%s \n",counter_correct,uttid);
token=500;
}
}
I also thought of doing like this
else if (strcmp(word, "FAHRERKENNUNG") == 0 &&(token==500))
{
//counter_correct = counter_correct + 1;
token = 496;
printf("Fahrerkennung on process \n");
//printf("token number %d\n", token);
printf("Enter the four digit of your drivers id \n");
}
else if((strstr(hyp,"NULL") == 0)
|| (strstr(hyp,"EINS") == 0)
|| (strstr(hyp,"ZWEI") == 0)
|| (strstr(hyp,"DREI") == 0)
|| (strstr(hyp,"VIER") == 0)
|| (strstr(hyp,"FüNF") == 0)
|| (strstr(hyp,"SECHS") == 0)
|| (strstr(hyp,"SIEBEN") == 0)
|| (strstr(hyp,"ACHT") == 0)
|| (strstr(hyp,"NEUN") == 0)
&& (token==496))
{
printf("%s\n",hyp);
token=500;
}
The problem here is after fahrerkennung if i say something which is another command, it is also giving it as a output. I want to only continue the process till we get any four combinations of numbers at output.
Thank you very much.. If you need more clarification ..feel free to ask. Cheers !
I'd suggest to put the parsing in a function:
// Store the strings to look for
const char * digits [] = {"NULL", "EINS", "ZWEI", "DREI", "VIER", "FüNF", "SECHS", "ACHT", "NEUN"};
size_t count_numbers_in_str(char * str)
{
size_t digits_found = 0;
for(size_t i=0; i<10; i++) // i<10: there are 10 elements in digits[]
{
char * tmp = str;
while(1)
{
tmp = strstr(tmp, digits[i]);
if(tmp) // Found a match
{
digits_found++;
// tmp points to the beginning of the found string
// move it 1 step forward to look for a new occurence
tmp++;
}
else // No matches or end of the string
{
break; // Exit while loop
}
}
}
// End of for loop: we looked for all digits in our list
return digits_found;
}
Then call this function every time you want to look for digits. Continue your process only if the function returns 4
ie a combination of four digits have been found in the given string.
[EDIT] Note that this count all the occurrences of a string representation of digit in a given str
. For example, if "SECHS" appears twice, digits_found
will be incremented twice. This process is done for all strings in digits
. Therefore, it can recognize any random combination of these substrings in str
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.