Skip to content

Commit

Permalink
Merge pull request #80 from ajcwebdev/refactor
Browse files Browse the repository at this point in the history
Remove Inquirer Interactive CLI and Python Whisper Dependencies
  • Loading branch information
ajcwebdev authored Dec 26, 2024
2 parents 1ce319b + d9fc5ed commit f34ff7d
Show file tree
Hide file tree
Showing 53 changed files with 928 additions and 2,141 deletions.
2 changes: 1 addition & 1 deletion .github/whisper.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN apt-get update && \
COPY --from=build /app /app

# Ensure that the main executable and scripts have execute permissions
RUN chmod +x /app/build/bin/main && \
RUN chmod +x /app/build/bin/whisper-cli && \
chmod +x /app/models/download-ggml-model.sh

# Set the entrypoint to bash
Expand Down
64 changes: 40 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ The Autoshow workflow includes the following steps:
1. The user provides input (video URL, playlist, RSS feed, or local file).
2. The system downloads the audio (if necessary).
3. Transcription is performed using the selected service.
4. The transcript is processed by the chosen LLM to generate a summary and chapters.
5. Results are saved in markdown format with front matter.
4. A customizable prompt is inserted containing instructions for the contents of the show notes.
5. The transcript is processed by the chosen LLM to generate show notes based on the selected prompts.
6. Results are saved in markdown format with front matter.

### Key Features

Expand All @@ -36,8 +37,6 @@ The Autoshow workflow includes the following steps:
- Command-line interface for easy usage
- *WIP: Node.js server and React frontend*

See [`docs/roadmap.md`](/docs/roadmap.md) for details about current development work and future potential capabilities.

## Setup

`scripts/setup.sh` checks to ensure a `.env` file exists, Node dependencies are installed, and the `whisper.cpp` repository is cloned and built. Run the script with the `setup` script in `package.json`.
Expand Down Expand Up @@ -103,30 +102,27 @@ Example commands for all available CLI options can be found in [`docs/examples.m

- Main Entry Points (`src/cli`)
- `commander.ts`: Defines the command-line interface using Commander
- `interactive.ts`: Defines the interactive terminal interface using Inquirer

- Command Processors (`src/commands`)
- `process-file.ts`: Handles local audio/video file processing
- `process-video.ts`: Handles single YouTube video processing
- `process-urls.ts`: Processes videos from a list of URLs in a file
- `process-playlist.ts`: Processes all videos in a YouTube playlist
- `process-channel.ts`: Processes all videos from a YouTube channel
- `process-rss.ts`: Processes podcast RSS feeds

- Utility Functions (`src/utils`)
- `generate-markdown.ts`: Creates initial markdown files with metadata
- `download-audio.ts`: Downloads audio from YouTube videos
- `run-transcription.ts`: Manages the transcription process
- `run-llm.ts`: Handles LLM processing for summarization and chapter generation
- `clean-up-files.ts`: Removes temporary files after processing
- `logging.ts`: Reusable Chalk functions for logging colors
- `validate-option.ts`: Functions for validating CLI options and handling errors

- Process Commands (`src/process-commands`)
- `file.ts`: Handles local audio/video file processing
- `video.ts`: Handles single YouTube video processing
- `urls.ts`: Processes videos from a list of URLs in a file
- `playlist.ts`: Processes all videos in a YouTube playlist
- `channel.ts`: Processes all videos from a YouTube channel
- `rss.ts`: Processes podcast RSS feeds

- Process Steps (`src/process-steps`)
- Step 1 - `generate-markdown.ts` creates initial markdown file with metadata
- Step 2 - `download-audio.ts` downloads audio from YouTube videos
- Step 3 - `run-transcription.ts` manages the transcription process
- Step 4 - `select-prompt.ts` defines the prompt structure for summarization and chapter generation
- Step 5 - `run-llm.ts` handles LLM processing for selected prompts
- Step 6 - `clean-up-files.ts` removes temporary files after processing

- Transcription Services (`src/transcription`)
- `whisper.ts`: Uses Whisper.cpp, openai-whisper, or whisper-diarization for transcription
- `deepgram.ts`: Integrates Deepgram transcription service
- `assembly.ts`: Integrates AssemblyAI transcription service
- `transcription-utils.ts`: Transcript formatting functions

- Language Models (`src/llms`)
- `ollama.ts`: Integrations Ollama's locally available models
Expand All @@ -138,7 +134,27 @@ Example commands for all available CLI options can be found in [`docs/examples.m
- `fireworks.ts`: Integrates Fireworks's open source models
- `together.ts`: Integrates Together's open source models
- `groq.ts`: Integrates Groq's open source models
- `prompt.ts`: Defines the prompt structure for summarization and chapter generation

- Utility Files (`src/utils`)
- `logging.ts`: Reusable Chalk functions for logging colors
- `validate-option.ts`: Functions for validating CLI options and handling errors
- `format-transcript.ts`: Transcript formatting functions
- `globals.ts`: Globally defined variables and constants

- Types (`src/types`)
- `process.ts`: Types for `commander.ts` and files in `process-commands` directory
- `llms.ts`: Types for `run-llm.ts` process step and files in `llms` directory
- `transcription.ts`: Types for `run-transcription.ts` process step and files in `transcription` directory

- Server (`src/server`)
- `index.ts`: Initializes Fastify server with CORS support and defines API endpoints
- `db.ts`: Sets up SQLite database connection and schema for storing show notes
- API Routes (`src/server/routes`)
- `process.ts`: Handles different types of media processing requests (video, playlist, RSS, etc.)
- `show-note.ts`: Retrieves individual show notes from the database by ID
- `show-notes.ts`: Fetches all show notes from the database, ordered by date
- Server Utilities (`src/server/utils`)
- `req-to-opts.ts`: Maps API request data to processing options for LLM and transcription services

## Contributors

Expand Down
22 changes: 1 addition & 21 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,26 +570,6 @@ npm run as -- \
--whisperDocker base
```

### Whisper Python

Use the original [`openai/whisper`](https://github.com/openai/whisper) Python library with the newly released [`turbo`](https://github.com/openai/whisper/discussions/2363) model:

```bash
npm run as -- \
--file "content/audio.mp3" \
--whisperPython turbo
```

### Whisper Diarization

Use [`whisper-diarization`](https://github.com/MahmoudAshraf97/whisper-diarization) to provide speaker labels:

```bash
npm run as -- \
--file "content/audio.mp3" \
--whisperDiarization tiny
```

### Deepgram

Create a `.env` file and set API key as demonstrated in `.env.example` for `DEEPGRAM_API_KEY`.
Expand Down Expand Up @@ -713,7 +693,7 @@ docker history autoshow-autoshow:latest
docker history autoshow-whisper:latest
```

Replace `as` with `docker` to run most other commands explained in this document. Does not support all options at this time, notably `--whisperPython` and `--whisperDiarization`.
Replace `as` with `docker` to run most other commands explained in this document.

```bash
npm run docker -- \
Expand Down
78 changes: 18 additions & 60 deletions docs/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ A list of scripts in Autoshow's `package.json` along with explanations for what

- [Setup Scripts](#setup-scripts)
- [`setup`](#setup)
- [`setup-python`](#setup-python)
- [`setup-docker`](#setup-docker)
- [`setup-all`](#setup-all)
- [Base, Main, and Serve Commands](#base,-main,-and-serve-commands)
Expand Down Expand Up @@ -42,24 +41,12 @@ A list of scripts in Autoshow's `package.json` along with explanations for what

### `setup`

Executes the `setup.sh` bash script located in the `./scripts/` directory.

- Initializes the project by installing necessary dependencies and performing initial configuration tasks.
Executes the `setup.sh` bash script located in the `./scripts/` directory. Initializes the project by installing necessary dependencies and performing initial configuration tasks.

```json
"setup": "bash ./scripts/setup.sh"
```

### `setup-python`

Runs the `setup-python.sh` bash script from the `./scripts/` directory.

- Sets up the Python environment, installing any Python dependencies required by the project.

```json
"setup-python": "bash ./scripts/setup-python.sh"
```

### `setup-docker`

Prepares the Docker environment without starting the containers.
Expand All @@ -78,11 +65,10 @@ Prepares the Docker environment without starting the containers.
Runs all setup scripts sequentially to fully initialize the project.

- `npm run setup`: Initializes the project.
- `npm run setup-python`: Sets up the Python environment.
- `npm run setup-docker`: Prepares the Docker environment.

```json
"setup-all": "npm run setup && npm run setup-python && npm run setup-docker"
"setup-all": "npm run setup && npm run setup-docker"
```

## Base, Main, and Serve Commands
Expand All @@ -101,19 +87,16 @@ Sets up a base command for running TypeScript files using `tsx`, a TypeScript ex

### `as`

Executes the main command-line interface (CLI) application.

- Runs `src/cli/commander.ts` using `tsx` with the base options defined in `tsx:base`.
Executes the main command-line interface (CLI) application. Runs `src/cli/commander.ts` using `tsx` with the base options defined in `tsx:base`.

```json
"as": "npm run tsx:base -- src/cli/commander.ts"
```

### `serve`

Starts the server in watch mode, recompiling on changes.
Starts the server in watch mode, recompiling on changes. Runs `src/server/index.ts`, the server entry point.

- Runs `src/server/index.ts`, the server entry point.
- `--watch`: Enables watch mode.
- `--experimental-sqlite`: Enables experimental SQLite features.

Expand All @@ -125,60 +108,47 @@ Starts the server in watch mode, recompiling on changes.

### `video`

Processes a single YouTube video using the CLI.

- Runs the main CLI script with the `--video` option.
Processes a single YouTube video using the CLI. Runs the main CLI script with the `--video` option.

```json
"video": "npm run as -- --video"
```

### `urls`

Processes a list of YouTube URLs from a file.

- Runs the CLI with the `--urls` option.
Processes a list of YouTube URLs from a file. Runs the CLI with the `--urls` option.

```json
"urls": "npm run as -- --urls"
```

### `playlist`

Processes all videos in a YouTube playlist.

- Runs the CLI with the `--playlist` option.
Processes all videos in a YouTube playlist. Runs the CLI with the `--playlist` option.

```json
"playlist": "npm run as -- --playlist"
```

### `file`

Processes a local audio or video file.

- Runs the CLI with the `--file` option.
Processes a local audio or video file. Runs the CLI with the `--file` option.

```json
"file": "npm run as -- --file"
```

### `rss`

Processes a podcast RSS feed.

- Runs the CLI with the `--rss` option.
Processes a podcast RSS feed. Runs the CLI with the `--rss` option.

```json
"rss": "npm run as -- --rss"
```

### `info`

Generates JSON files containing metadata information.

- Runs the CLI with the `--info` option.
- Useful for retrieving information without processing the content.
Generates JSON files containing metadata information. Runs the CLI with the `--info` option which is useful for retrieving information without processing the content.

```json
"info": "npm run as -- --info"
Expand All @@ -188,71 +158,59 @@ Generates JSON files containing metadata information.

### `test-local`

Runs local unit tests.

- Executes `test/local.test.ts` using `tsx` in test mode.
Runs local unit tests. Executes `test/local.test.ts` using `tsx` in test mode.

```json
"test-local": "tsx --test test/local.test.ts"
```

### `test-docker`

Runs tests related to Docker services.

- Executes `test/docker.test.ts` to verify Docker integrations.
Runs tests related to Docker services. Executes `test/docker.test.ts` to verify Docker integrations.

```json
"test-docker": "tsx --test test/docker.test.ts"
```

### `test-services`

Tests external services and APIs used by the application.

- Runs `test/services.test.ts` to ensure service integrations are functioning.
Tests external services and APIs used by the application. Runs `test/services.test.ts` to ensure service integrations are functioning.

```json
"test-services": "tsx --test test/services.test.ts"
```

### `test-all`

Runs all test suites sequentially. Test runs include:
Runs all tests including:

- Local tests.
- Service integration tests.
- Docker-related tests.

```json
"test-all": "npm run test-local && npm run test-services && npm run test-docker"
"test-all": "tsx --test test/all.test.ts"
```

### `t`

Alias for the `test-local` script.

- Provides a shorthand command for running local tests.
Alias for the `test-local` script. Provides a shorthand command for running local tests.

```json
"t": "npm run test-local"
```

### `test-server-local`

Tests the local server functionality.

- Runs `src/server/tests/fetch-local.ts` using `tsx`.
Tests the local server functionality. Runs `src/server/tests/fetch-local.ts` using `tsx`.

```json
"test-server-local": "npm run tsx:base -- src/server/tests/fetch-local.ts"
```

### `test-server-all`

Tests all server functionalities.

- Runs `src/server/tests/fetch-all.ts` using `tsx`.
Tests all server functionalities. Runs `src/server/tests/fetch-all.ts` using `tsx`.

```json
"test-server-all": "npm run tsx:base -- src/server/tests/fetch-all.ts"
Expand Down
Loading

0 comments on commit f34ff7d

Please sign in to comment.