labnotes

Coding with aider

how much can it figure out for you

tags
aider
openai
whisper
promptprogramming
ai

Here's an example of building out an app with aider that records audio, sends it to OpenAI for processing, and shows the result.

Installation

1
2
  # Install aider
  python -m pip install aider-chat

Create a temporary directory and fire up aider

1
2
3
  cd $(mktemp -d)
  echo OPENAI_API_KEY=$(op read 'op://Personal/OpenAI Key/notesPlain') > .env
  dotenvx run -- aider

Chat transcript

Prompt 1: describe the project

create an express app that serves up an html and javascript files. The app uses the media api to record a person talking, and then uses the openai whisper api to convert the spoken text to speech. When the user stops the recording, there's a display that says "processing" and when its done it gets replaced with the text that is spoken. If there's an error it gets displayed in that box. openai needs to have the right file extention so make sure its uploaded in webm and the filename is preserved the example from the openai docs is

const openai = new OpenAI();

async function main() { const transcription = await openai.audio.transcriptions.create({ file: fs.createReadStream("/path/to/file/audio.mp3"), model: "whisper-1", });

Prompt 2: tell me what to copy and paste

what is the npm command i need to run to install of the dependancies?

Run it:

1
  npm install express multer openai

Start the server

1
  dotenvx run -- node app.js

Prompt 3: Got an error, just paste it in

Error: ENOENT: no such file or directory, open 'uploads/audio.webm'

Prompt 4: what sort of madness is it doing

use the webm format

Prompt 5: Restarting this server all the time is a pain

add a script to package.json that watches to see if any of the js files change and restarts the command 'dotenvx run – node app.js'

This is better:

1
2
  npm i nodemon
  npm run dev

Prompt 6: Its just adding to the audio file, making it longer and longer

it seems like when i record something it jsut gets added to the end of the file. when you get the upload have it be in a unique file

Prompt 7: Nope looks like its on the server side

looks like its happening on the client side

fin.

Previously

labnotes

Clerk webhooks

begining the events

tags
clerk
webhooks
nextjs

Next

fragments

rust to wasm to javascript

tags
wasm
rust