Browse Source

comentários e redução de arryas

master
Rodgger 2 years ago
parent
commit
6ae37008c9
  1. 19
      Makefile
  2. 5
      agi.c
  3. 5
      agi_c.h
  4. 25
      speech.c

19
Makefile

@ -1,9 +1,7 @@
## Compilar speech simplesip
##
##
##
##
###############################
## Compilar speech simplesip ##
## copyright Simples Ip ##
###############################
CC=gcc
CFLAGS=-Wall -W
@ -15,13 +13,14 @@ agi.o\
base64.o
speech-recog.agi_c: $(OBJ)
$(CC) -o $@ $^ $(LIBS)
@echo "\nBinário: speech-recog.agi_c"
@$(CC) -o $@ $^ $(LIBS)
@echo "make -> compila\nmake clean -> limpa objetos\n\nPrograma gerado: speech-recog.agi_c"
$(DIR_OBJ)%.o: $(DIR_SRC)%.c
$(CC) -c -o $@ $< $(CFLAGS)
@$(CC) -c -Werror -o $@ $< $(CFLAGS)
clean:
rm *.o
@rm -f *.o
@echo "objetos apagados"

5
agi.c

@ -1,3 +1,8 @@
/*
* Copyright (c) 2022 Simples Ip, All rights reserved.
* Author: Ródgger Bruno <rodgger.silva@simplesip.com.br>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

5
agi_c.h

@ -1,3 +1,8 @@
/*
* Copyright (c) 2022 Simples Ip, All rights reserved.
* Author: Ródgger Bruno <rodgger.silva@simplesip.com.br>
*/
#ifndef AGI_H
#define AGI_H 1

25
speech.c

@ -1,5 +1,10 @@
/*
* Copyright (c) 2022 Simples Ip, All rights reserved.
* Author: Ródgger Bruno <rodgger.silva@simplesip.com.br>
*/
#define _POSIX_C_SOURCE 199309
#include <time.h>
//#include <time.h>
#include "agi_c.h"
#include <stdio.h>
#include <stdlib.h>
@ -11,6 +16,8 @@
#include <curl/curl.h>
#include <jansson.h>
#include <errno.h>
#include <signal.h>
#define GOOGLE_KEY "AIzaSyBxwBNxj9qKoG_U9bH9eLouzfhRtr6AdWc"
@ -37,10 +44,11 @@ char beep[10];
char uniqueid[30];
char samplerate[ 32 ]; // samplerate do audio
char pro_filter[ 10 ]; // esconder os palavrões no texto, exemplo: f*****
char flac[4096];
char flac[128];
char name_audio[100];
int fd_tmpaudio;
//prototype
int define_variable( char *variable, char *value );
int bin_flac( );
@ -52,8 +60,10 @@ struct response_google *send_network( s_agi_parameter *param_agi, struct b_audi
int copy_to_struct( struct b_audio *b_flac, char *str, size_t p );
char *http_content(CURL *curl, struct b_audio *b_flac);
size_t response_curl(void *contents, size_t size, size_t nmemb, void *userp);
static void sigHandler(int sig);
int main(){
s_agi_parameter *param_agi = NULL;
s_agi_return *response = NULL;
@ -79,6 +89,7 @@ int main(){
response = agi_command( "ANSWER \n" );
if( response->result != 0 ){
AGI_NORESPONSE( "VERBOSE \"Falha resposta do canal. script terminado\" \n" );
exit(-1);
}
}
@ -347,9 +358,9 @@ int covert_flac( ){
struct b_audio * get_audio_bytes(){
char command_base64[4096];
char command_base64[256];
/* converter flac em base64 */
snprintf(command_base64, 4096, "base64 %s.flac -w 0 > %s.base64", name_audio, name_audio);
snprintf(command_base64, 256, "base64 %s.flac -w 0 > %s.base64", name_audio, name_audio);
/* verfica se tem erros na conversão */
if(system( command_base64 ) != 0){
@ -358,8 +369,8 @@ struct b_audio * get_audio_bytes(){
}
FILE *fd_base64;
char full_path_name_base64[ 4096 ];
snprintf(full_path_name_base64, 4096, "%s.base64", name_audio);
char full_path_name_base64[ 256 ];
snprintf(full_path_name_base64, 256, "%s.base64", name_audio);
fd_base64 = fopen( full_path_name_base64, "r");
if(fd_base64 == NULL){
AGI_NORESPONSE("VERBOSE \"Não pode abrir o arquivo %s.base64\"\n", name_audio);
@ -490,6 +501,7 @@ size_t response_curl(void *contents, size_t size, size_t nmemb, void *userp){
memcpy(&(mem->response[mem->size]), contents, realsize);
mem->size += realsize;
mem->response[mem->size] = 0;
return realsize;
}
@ -539,4 +551,3 @@ char *http_content(CURL *curl, struct b_audio *b_flac){
return content;
}

Loading…
Cancel
Save