organize audio and intelligence modules
This commit is contained in:
+42
-2
@@ -1,5 +1,45 @@
|
||||
#include "audio.h"
|
||||
#include "deepgram_client.h"
|
||||
#include "intelligence.h"
|
||||
#include "utils.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
printf("hello world \n");
|
||||
int main(int argc, char *argv[]) {
|
||||
char *capture_audio_file = audio_capture(5);
|
||||
|
||||
// Reopen file for reading and transcribe
|
||||
FILE *file = fopen(capture_audio_file, "rb");
|
||||
if (file != NULL) {
|
||||
char *transcript = dg_transcribe(file);
|
||||
if (transcript) {
|
||||
printf("Transcript: %s\n", transcript);
|
||||
|
||||
char *ai_answer = ai_ask(transcript);
|
||||
if (ai_answer) {
|
||||
printf("AI answer: %s\n", ai_answer);
|
||||
|
||||
struct curl_response_data *tts_response = dg_text_to_speech(ai_answer);
|
||||
int result = audio_play(tts_response->data, tts_response->size);
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "failure in playback");
|
||||
}
|
||||
|
||||
free(tts_response->data);
|
||||
free(tts_response);
|
||||
|
||||
// we have this response data, and buffer within it. we can loop through
|
||||
// it and write the pcm data within it to alsa
|
||||
free(ai_answer);
|
||||
}
|
||||
free(transcript);
|
||||
} else {
|
||||
fprintf(stderr, "unable to get transcript");
|
||||
}
|
||||
fclose(file);
|
||||
} else {
|
||||
fprintf(stderr, "unable to open file for reading\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user