Skip to content

CunningDJ/openai-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openai-tools

A personal workspace for small OpenAI-powered command line tools.

Tools

  • tts: turns .txt and .md files into audio with OpenAI text-to-speech.

Repo Layout

  • Root Google Drive helpers live in utils/.
  • TTS runnable scripts live in tts/cli/.
  • TTS-local helpers live in tts/utils/.

Adding CLI Scripts

New CLI entry files should keep their runnable workflow inside a main() function and only call it when the file is run directly. Use the shared guard from utils/cli.ts:

import { checkIsDirectlyCalledFile } from "../utils/cli";

async function main(): Promise<void> {
  // CLI workflow here.
}

if (checkIsDirectlyCalledFile(import.meta.url)) {
  main().catch((error: unknown) => {
    console.error(error instanceof Error ? error.message : String(error));
    process.exit(1);
  });
}

This keeps CLI modules import-safe for tests or future reuse.

Setup

Install everything from the repo root. npm workspaces install the root utilities and tool packages together:

npm install

Verify Code

Run the full repo check from the root:

npm run verify

This runs TypeScript typechecking and the unit test suite.

Env Setup

Create a top-level .env file:

cp .env.example .env

Then add your OpenAI API key:

OPENAI_API_KEY=your_api_key_here

Google Drive Uploads

Optional Google Drive uploads use OAuth. A plain Google API key cannot upload files to a personal Google Drive.

  1. Enable the Google Drive API.
  2. Configure the OAuth consent screen, keep the app in Testing, and add yourself as a test user.
  3. Create an OAuth client ID with application type Desktop app.
  4. Download the client JSON, rename it to google-oauth-client.json, and put it in the repo root.
  5. Run the setup command and approve the browser consent flow:
npm run setup-gdrive

That creates google-oauth-token.json in the repo root. Both Google OAuth JSON files are gitignored.

GDrive Uploader on a Headless Machine

Run npm run setup-gdrive once on a machine with a browser, then copy both files to the headless repo root:

google-oauth-client.json
google-oauth-token.json

To print the consent URL without opening a browser automatically, use this. The browser still needs to reach the printed localhost callback URL.

GOOGLE_DRIVE_OAUTH_NO_BROWSER=1 npm run setup-gdrive

Use

Run the TTS tool from the repo root:

npm run tts -- my-file.md

Or from inside the tool folder:

cd tts
npm run tts -- my-file.md

See tts/README.md for TTS-specific usage and options.

About

A collection of OpenAI tools I've made

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors