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.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user