diff --git a/devices/esp32/testHTTP.ino b/devices/esp32/testHTTP.ino new file mode 100644 index 0000000..e67e4ff --- /dev/null +++ b/devices/esp32/testHTTP.ino @@ -0,0 +1,80 @@ +#include +#include +#include +#include + +const char* ssid = ">ENTER WIFI NAME>"; // Your WiFi SSID +const char* password = ""; // Your WiFi password + + +// Function to send WAV buffer +void sendWavBuffer(const std::vector& buffer) { + // Ensure we are connected to WiFi. If not, return. + if (WiFi.status() != WL_CONNECTED) { + Serial.println("WiFi is not connected!"); + return; + } + + const char* supabaseUrlEnv = ""; // Use your Supabase URL here + const char* authToken = ""; // Use your Auth Token here + + std::string url = std::string(supabaseUrlEnv) + "/functions/v1/process-audio"; + + WiFiClientSecure client; + client.setInsecure(); // Disables SSL certificate verification + + HTTPClient https; + if (https.begin(client, url.c_str())) { // HTTPS begin + https.addHeader("Authorization", "Bearer " + String(authToken)); + https.addHeader("Content-Type", "audio/wav"); + + // Create a non-const copy of the data from the buffer + size_t bufferSize = buffer.size(); + uint8_t* nonConstBuffer = new uint8_t[bufferSize]; + memcpy(nonConstBuffer, buffer.data(), bufferSize); + + // Use the non-const copy in the POST call + int httpResponseCode = https.POST(nonConstBuffer, bufferSize); + + if (httpResponseCode > 0) { + // If server responds, print response + Serial.printf("HTTP Response code: %d\n", httpResponseCode); + String payload = https.getString(); + Serial.println(payload); + } + else { + Serial.printf("Error on sending POST: %d\n", httpResponseCode); + } + + // Clean up the non-const buffer copy after use + delete[] nonConstBuffer; + + https.end(); // HTTPS end + } + else { + Serial.println("Error in HTTPS connection"); + } + + +} + +void setup() { + Serial.begin(115200); + + // Connect to WiFi + WiFi.begin(ssid, password); + while (WiFi.status() != WL_CONNECTED) { + delay(1000); + Serial.println("Connecting to WiFi.."); + } + Serial.println("Connected to WiFi"); + + // Initialize vector with dummy data for testing + std::vector dummyData(1024, 0); // Example buffer, replace with actual audio data + sendWavBuffer(dummyData); // Send the buffer +} + +void loop() { + // Nothing here +} + diff --git a/devices/esp32/testI2S.ino b/devices/esp32/testI2S.ino new file mode 100755 index 0000000..62b5f36 --- /dev/null +++ b/devices/esp32/testI2S.ino @@ -0,0 +1,27 @@ +#include "I2S.h" + +void setup() { + // Open serial communications and wait for port to open: + // A baud rate of 115200 is used instead of 9600 for a faster data rate + // on non-native USB ports + Serial.begin(115200); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // start I2S at 16 kHz with 16-bits per sample + I2S.setAllPins(-1, 42, 41, -1, -1); + if (!I2S.begin(PDM_MONO_MODE, 16000, 16)) { + Serial.println("Failed to initialize I2S!"); + while (1); // do nothing + } +} + +void loop() { + // read a sample + int sample = I2S.read(); + + if (sample && sample != -1 && sample != 1) { + Serial.println(sample); + } +} diff --git a/devices/raspipico/CMakeLists.txt b/devices/raspipico/CMakeLists.txt deleted file mode 100644 index 0c57217..0000000 --- a/devices/raspipico/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.13) - -# initialize the SDK based on PICO_SDK_PATH -# note: this must happen before project() -include(pico_sdk_import.cmake) - -project(my_project) - -# initialize the Raspberry Pi Pico SDK -pico_sdk_init() - -# rest of your project -add_executable(raspipico - main.c -) - -# Add pico_stdlib library which aggregates commonly used features -target_link_libraries(raspipico pico_stdlib) - -# create map/bin/hex/uf2 file in addition to ELF. -pico_add_extra_outputs(raspipico) diff --git a/devices/raspipico/main.c b/devices/raspipico/main.c deleted file mode 100644 index 11d65bb..0000000 --- a/devices/raspipico/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "pico/stdlib.h" - -int main() -{ - setup_default_uart(); - printf("Hello, world!\n"); - return 0; -} \ No newline at end of file diff --git a/supabase/functions/process-audio/index.ts b/supabase/functions/process-audio/index.ts index 9c9d1f4..6276e99 100644 --- a/supabase/functions/process-audio/index.ts +++ b/supabase/functions/process-audio/index.ts @@ -39,9 +39,17 @@ const processAudio = async (req: Request) => { try { const filenameTimestamp = `adeus_wav_${Date.now()}.wav`; const wavFile = await toFile(arrayBuffer, filenameTimestamp); + + const { data, error } = await supabase.storage + .from("test") + .upload(filenameTimestamp, wavFile); + + if (error) { + console.error("Error uploading file:", error); + } const transcriptResponse = await openaiClient.audio.transcriptions.create({ - file: await toFile(wavFile, filenameTimestamp), + file: wavFile, model: "whisper-1", prompt: 'Listen to the entire audio file, if no audio is detected then respond with "None" ', // These types of prompts dont work well with Whisper -- https://platform.openai.com/docs/guides/speech-to-text/prompting