move from private r&d repo

This commit is contained in:
talksik
2025-07-27 15:06:10 -07:00
commit 974504db14
14 changed files with 693 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef AUDIOCAPTURE_H
#define AUDIOCAPTURE_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#include <alsa/control.h>
#include <alsa/pcm.h>
// NOTE: find this via `arecord -l`
#define ALSA_MIC_HARDWARE_DEVICE "hw:3"
#define ALSA_SPEAKER_HARDWARE_DEVICE "default"
// Captures audio for given seconds, and returns file name that we captured the
// audio into
char *audio_capture(uint seconds);
/* count: how many bytes in the buffer
* returns int: 0 if success, -1 if failure
* NOTE: This function assumes that the audio data is using:
* - linear16 formatting (each sample is 16 bits)
* - one channel (1 sample)
* - with 48000 HZ sampling rate
* Hence, it's 2 bytes per frame.
*/
int audio_play(char *buf, size_t byte_count);
#endif // AUDIOCAPTURE_H
+21
View File
@@ -0,0 +1,21 @@
#ifndef DEEPGRAMCLIENT_H
#define DEEPGRAMCLIENT_H
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
/*
* @param audio_file: must already be opened
* @returns char *: transcript string result. Call must free.
*/
char *dg_transcribe(FILE *audio_file);
/*
* @returns response data. Caller must free the struct AND the data within it.
* TODO: should return custom struct with details about encoding, sample rate, etc.
*/
struct curl_response_data *dg_text_to_speech(char *text);
#endif // DEEPGRAMCLIENT_H
+9
View File
@@ -0,0 +1,9 @@
#ifndef INTELLIGENCE_H
#define INTELLIGENCE_H
#include <stdio.h>
#include <stdlib.h>
char *ai_ask(char *question);
#endif //INTELLIGENCE_H
+24
View File
@@ -0,0 +1,24 @@
#ifndef UTILS_H
#define UTILS_H
#include <stdlib.h>
#include <stdio.h>
struct curl_file_data {
FILE *file;
size_t size;
};
struct curl_response_data {
char *data;
size_t size;
};
// This callback assumes the userdata is `struct file_data`
size_t curl_read_callback_file(void *ptr, size_t size, size_t nmemb, void *userdata);
// This callback assumes that we are aggregating callback data into an allocated response_data struct
size_t curl_write_callback_response(void *contents, size_t size, size_t nmemb,
void *userp);
#endif // UTILS_H