LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   voice recognition (https://www.linuxquestions.org/questions/programming-9/voice-recognition-375965/)

georgekjolly 10-23-2005 03:07 AM

voice recognition
 
Hi .....,

The program i got after a search in the google is given below.It can only play back the sound that i dictate.

But i need to modify this program so that it could identify the the word i spells and print it on the screen.How it would be possible please help me......

//Program that can play back the sound that we dictate

#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/soundcard.h>

#define LENGTH 3 /* how many seconds of speech to store */
#define RATE 8000 /* the sampling rate */
#define SIZE 8 /* sample size: 8 or 16 bits */
#define CHANNELS 1 /* 1 = mono 2 = stereo */

/* this buffer holds the digitized audio */
unsigned char buf[LENGTH*RATE*SIZE*CHANNELS/8];


int main()
{
int fd;/* sound device file descriptor */
int arg;/* argument for ioctl calls */
int status; /* return status of system calls */

/* open sound device */
fd = open("/dev/dsp", O_RDWR);
if (fd < 0) {
perror("open of /dev/dsp failed");
exit(1);
}

/* set sampling parameters */
arg = SIZE; /* sample size */
status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_BITS ioctl failed");
if (arg != SIZE)
perror("unable to set sample size");

arg = CHANNELS; /* mono or stereo */
status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
if (arg != CHANNELS)
perror("unable to set number of channels");

arg = RATE; /* sampling rate */
status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
if (status == -1)
perror("SOUND_PCM_WRITE_WRITE ioctl failed");

while (1) { /* loop until Control-C */
printf("Say something:\n");
status = read(fd, buf, sizeof(buf)); /* record some sound */
if (status != sizeof(buf))
perror("read wrong number of bytes");
printf("You said:\n");
status = write(fd, buf, sizeof(buf)); /* play it back */
if (status != sizeof(buf))
perror("wrote wrong number of bytes");
/* wait for playback to complete before recording again */
status = ioctl(fd, SOUND_PCM_SYNC, 0);
if (status == -1)
perror("SOUND_PCM_SYNC ioctl failed");
}
}//Program ends here


From george
email: <georgekjolly@yahoo.com>

macemoneta 10-23-2005 11:34 PM

What you have is a simple voice recorder. It sounds like what you are looking for is voice recognition software, like CMU Sphinx. Be aware that it's not really packaged for end users and can require considerable CPU resources.

schneidz 10-25-2005 02:35 PM

what this seems to be is a program used to record from the sound device and immediately echoes it (not the 'echo' command but actually echoes it, ... you know what i mean) to the sound device.

this is prolly some api for voip (interesting).

there would be considerable programming in order to convert this to print speech but it will be buggy (e.g.- i had to yell 'call home' into my phone about 20 times before it registered for voice dial). i assume that most speech recognition software does some type of recording/ compare of some internal database. start with a small dictionary maybe 10 pre-recorded words and program it to 'echo' the correct word to the screen.

does anyone know of an api that can pull metrics on pitch, frequency, and tone?


All times are GMT -5. The time now is 07:26 PM.