Hello. I'm currently developing an IVR system under Asterisk through the Asterisk Gateway Interface (AGI), connecting to a Mysql server using the Mysql C API.
The server returns a ticket number that I have to say to the client, so I developed a TTS (Text To Speech) algorithm to say a specific number (13000) to the client for testing, by using the AGI application Stream File, and playing two sound files back to back, thirteen.gsm and thousand.gsm, so the caller can hear the ticket number "Thirteen Thousand"
The problem is this: on the Asterisk debug console I can see that the Stream File ("thirteen") and Stream File("thousand") functions work, but can hear no sound whatsoever on the softphone. The sound files play fine on other sound players and so do other AGI applications using the Stream File function.

The code below basically copies the number returned by the server (13000 for this test) on the array 'numero', then checks the first and second numbers to be '1' and '3' (I omit the latter since I know they're zero) then play the files through the AGI functions Stream File.
I'm guessing it has to do with being connected to the server while playing files or something.
Any ideas?

while ((row = mysql_fetch_row(res)) != NULL)
	{
		strcpy(prueba[0],row[0]);
		j=strlen(prueba[0]);
		for (i=0; i<j; i++)
		{
			if (prueba[0][i]=='0' || prueba[0][i]=='1' || prueba[0][i]=='2' || prueba[0][i]=='3' || prueba[0][i]=='4' || prueba[0][i]=='5' ||
				prueba[0][i]=='6' || prueba[0][i]=='7' || prueba[0][i]=='8' || prueba[0][i]=='9')
							
			{
				//printf("El string comienza en posicion %i\n",i);
				l=i;
				for (k=i; k<j; k++)
				{
					m=k;					
					if (prueba[0][k]=='\0')
					{
						//printf("El string termina en posicion %i\n",k);
						k=j;	
					}
				}
				i=j;
			}	
		}
		n=m-l;
		int numero[n];	
		//printf("Variable 'numero' tiene %i espacios\n",n+1);
		i=0;
		for (j=l;j<(m+1);j++)
		{			
			numero[i]=prueba[0][j];
			i++;
		}
		/*for (i=0;i<(n+1);i++)
		{	
			printf("%c",numero[i]);
		}*/
		
/*-------------------------------------------------*/
	/*TTS para numero*/
		switch(n+1)
		{	

			/* Ticket de 5 digitos */
			case 5:
				if (numero[0]=='1')
					//printf("prueba\n");					
					UnidadMil(numero[1]);
		
		}
		
	}
void UnidadMil(int unidad)
{
	switch (unidad){
		case '3':
			StreamFile("trece");
			StreamFile("mil");
	}

}
void StreamFile(char *audio)
{
	char line [80];
	setlinebuf(stdout);
	setlinebuf(stderr);
	printf("STREAM FILE %s #""\n", audio); 
	fgets(line,80,stdin);        		 	 
	fputs(line,stderr);			   
	fflush(stdin);
}
jephthah commented: nice to see someone's first post, with properly formatted code. +5

Well, to anyone interested in this particular issue, I was able to solve it.
I simply changed the Stream File command to Exec Playback, which is essentially the same in Asterisk, but control goes over to Asterisk instead of the AGI script, if i recall correctly.

Cheers.

i don't really know what you're talking about, but thanks for posting your solution.

someone will wander across this someday and be helped by it.

:)

Well if you know what Asterisk PBX is, as well as AGI and applications within Asterisk then you'll know what this is about.
I'm guessing since this is a programming forum people will know at least what the MySQL C API is, so I thought someone would know something.
Nonetheless thanks for posting.
I'm marking this as solved since I forgot last time.

actually check this syntax for stream file
printf("STREAM FILE /path of file \"\"\n");
this works in my case u try this ......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.