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
31 lines
1000 B
C
31 lines
1000 B
C
#include "utils.h"
|
|
#include <string.h>
|
|
|
|
size_t curl_read_callback_file(void *ptr, size_t size, size_t nmemb,
|
|
void *userdata) {
|
|
struct curl_file_data *data = (struct curl_file_data *)userdata;
|
|
size_t bytes_to_read = size * nmemb;
|
|
return fread(ptr, 1, bytes_to_read, data->file);
|
|
}
|
|
|
|
size_t curl_write_callback_response(void *contents, size_t size, size_t nmemb,
|
|
void *userp) {
|
|
size_t total_size = size * nmemb;
|
|
struct curl_response_data *response = (struct curl_response_data *)userp;
|
|
|
|
// Reallocate buffer to fit new data
|
|
response->data = realloc(response->data, response->size + total_size + 1);
|
|
if (response->data == NULL) {
|
|
return 0; // Error
|
|
}
|
|
|
|
// Copy new data to buffer
|
|
memcpy(&response->data[response->size], contents, total_size);
|
|
response->size += total_size;
|
|
response->data[response->size] = '\0'; // Null terminate
|
|
|
|
printf("read an extra %d bytes of data\n", (int)total_size);
|
|
|
|
return total_size;
|
|
}
|