8870741c3e
* capture audio with alsa * add brainstorm thoughts * use basecamp project for managing this project * add libcurl basic example * write pcm data to file * transcribe audio file with deepgram * transcribe raw audio * hit anthropic API for ai question * create full flow with stt, anthropic, tts, and playback This organizes some components like deepgram into own module, and also allows gets the full flow to work every time we run the program. * organize audio and intelligence modules * organize header files into include directory * docs: add readme * docs: explain future work * docs: add disclaimer about hardcoded audio params
46 lines
1.2 KiB
C
46 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[]) {
|
|
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;
|
|
}
|