47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
#include "audio.h"
|
|
#include "deepgram_client.h"
|
|
#include "intelligence.h"
|
|
#include "utils.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
uint num_seconds = 5;
|
|
char *capture_audio_file = audio_capture(num_seconds);
|
|
|
|
// 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;
|
|
}
|