Skip to content

Commit

Permalink
Merge pull request #118 from ajcwebdev/next
Browse files Browse the repository at this point in the history
Update Setup Script, `--runLLM `, `--llmCost`, `--transcriptCost` options
  • Loading branch information
ajcwebdev authored Jan 27, 2025
2 parents a62ae3c + 52bba4c commit 8ad8b5e
Show file tree
Hide file tree
Showing 44 changed files with 2,136 additions and 1,575 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ Autoshow automates the processing of audio and video content from various source

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).
1. The user provides a content input (video URL, playlist, RSS feed, or local file) and front matter is created based on the content's metadata.
2. The audio is downloaded (if necessary).
3. Transcription is performed using the selected service.
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 Down
23 changes: 23 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
- [Process All Videos from a YouTube Channel](#process-all-videos-from-a-youtube-channel)
- [Process Podcast RSS Feed](#process-podcast-rss-feed)
- [Transcription Options](#transcription-options)
- [Get Transcription Cost](#get-transcription-cost)
- [Whisper](#whisper)
- [Deepgram](#deepgram)
- [Assembly](#assembly)
- [Language Model (LLM) Options](#language-model-llm-options)
- [Run Only LLM Process Step](#run-only-llm-process-step)
- [Get LLM Cost](#get-llm-cost)
- [Ollama Local Models](#ollama-local-models)
- [OpenAI ChatGPT Models](#openai-chatgpt-models)
- [Anthropic Claude Models](#anthropic-claude-models)
Expand Down Expand Up @@ -260,6 +263,13 @@ npm run as -- \

## Transcription Options

### Get Transcription Cost

```bash
npm run as -- --transcriptCost "content/audio.mp3" --deepgram
npm run as -- --transcriptCost "content/audio.mp3" --assembly
```

### Whisper

If neither the `--deepgram` or `--assembly` option is included for transcription, `autoshow` will default to running the largest Whisper.cpp model. To configure the size of the Whisper model, use the `--model` option and select one of the following:
Expand Down Expand Up @@ -359,6 +369,19 @@ For each model available for each provider, I have collected the following detai
- Cost of input and output tokens per million tokens.
- Some model providers also offer a Batch API with input/output tokens at half the price.

### Run Only LLM Process Step

```bash
npm run as -- --runLLM "content/audio-prompt.md" --chatgpt
```

### Get LLM Cost

```bash
npm run as -- --llmCost "content/audio-prompt.md" --chatgpt
npm run as -- --llmCost "content/audio-prompt.md" --claude
```

### Ollama Local Models

```bash
Expand Down
685 changes: 343 additions & 342 deletions package-lock.json

Large diffs are not rendered by default.

236 changes: 172 additions & 64 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,86 +1,194 @@
#!/bin/bash
#!/usr/bin/env bash
# scripts/setup.sh

# Function to check if a command exists
# ------------------------------------------------------------------------------
# A single script to set up your environment on macOS (brew) or Linux (apt).
# Installs yt-dlp, ffmpeg, and ollama if they are missing, plus sets up whisper.cpp.
# ------------------------------------------------------------------------------

# ------------------------------------------------------------------------------
# 1. OS DETECTION
# ------------------------------------------------------------------------------
IS_MAC=false
IS_LINUX=false

case "$OSTYPE" in
darwin*)
IS_MAC=true
;;
linux*)
IS_LINUX=true
;;
*)
echo "Unsupported OS: $OSTYPE"
echo "Please install dependencies manually."
exit 1
;;
esac

# ------------------------------------------------------------------------------
# 2. HELPER FUNCTIONS
# ------------------------------------------------------------------------------

# Check if a command is available
command_exists() {
command -v "$1" >/dev/null 2>&1
command -v "$1" &>/dev/null
}

# Check if .env file exists
if [ -f ".env" ]; then
echo ".env file already exists. Skipping copy of .env.example."
else
echo ".env file does not exist. Copying .env.example to .env."
cp .env.example .env
fi
# Ensure Homebrew on macOS
ensure_homebrew() {
if ! command_exists brew; then
echo "Homebrew is not installed on your system."
echo "Please install Homebrew from https://brew.sh/ then rerun this script."
exit 1
fi
}

# Check if yt-dlp is installed, if not, provide installation instructions
if ! command_exists yt-dlp; then
echo "yt-dlp could not be found, refer to installation instructions here:"
echo "https://github.com/yt-dlp/yt-dlp/wiki/Installation"
else
echo "yt-dlp is already installed."
fi
# Ensure apt on Linux
ensure_apt() {
if ! command_exists apt-get; then
echo "This script requires apt-get, but it was not found."
echo "Please install dependencies manually, or add logic for your package manager."
exit 1
fi
}

# Install package if missing (macOS)
install_if_missing_brew() {
local pkg=$1
if ! command_exists "$pkg"; then
echo "$pkg not found. Installing with Homebrew..."
brew install "$pkg"
else
echo "$pkg is already installed."
fi
}

# Install package if missing (Linux/apt)
install_if_missing_apt() {
local pkg=$1
if ! command_exists "$pkg"; then
echo "$pkg not found. Installing with apt-get..."
sudo apt-get update -y
sudo apt-get install -y "$pkg"
else
echo "$pkg is already installed."
fi
}

# Function to check if Ollama server is running
# Check if Ollama server is running
check_ollama_server() {
if curl -s "http://127.0.0.1:11434" &> /dev/null; then
echo "Ollama server is already running."
else
echo "Ollama server is not running. Starting Ollama server..."
ollama serve > ollama.log 2>&1 &
OLLAMA_PID=$!
echo "Ollama server started with PID $OLLAMA_PID"
sleep 5
fi
if curl -s "http://127.0.0.1:11434" &> /dev/null; then
echo "Ollama server is already running."
else
echo "Ollama server is not running. Starting Ollama server..."
ollama serve > ollama.log 2>&1 &
OLLAMA_PID=$!
echo "Ollama server started with PID $OLLAMA_PID"
# Allow server a few seconds to initialize
sleep 5
fi
}

# Function to check if a model is available, and pull it if not
# Check if a model is available, and pull it if not
check_and_pull_model() {
local model=$1
if ollama list | grep -q "$model"; then
echo "Model $model is already available."
else
echo "Model $model is not available. Pulling the model..."
ollama pull "$model"
fi
local model=$1
if ollama list | grep -q "$model"; then
echo "Model '$model' is already available."
else
echo "Model '$model' is not available. Pulling the model..."
ollama pull "$model"
fi
}

# Check if Ollama is installed
if ! command_exists ollama; then
echo "Ollama is not installed, refer to installation instructions here:"
echo "https://github.com/ollama/ollama"
# ------------------------------------------------------------------------------
# 3. INSTALL DEPENDENCIES (yt-dlp, ffmpeg, ollama)
# ------------------------------------------------------------------------------

# On macOS, make sure Homebrew is installed and install packages
if [ "$IS_MAC" = true ]; then
ensure_homebrew
BREW_PACKAGES=("yt-dlp" "ffmpeg" "ollama")
for pkg in "${BREW_PACKAGES[@]}"; do
install_if_missing_brew "$pkg"
done
fi

# On Linux, we’ll assume apt and install packages
if [ "$IS_LINUX" = true ]; then
ensure_apt

# There's no official apt package for "ollama" at the time of writing.

APT_PACKAGES=("yt-dlp" "ffmpeg")
for pkg in "${APT_PACKAGES[@]}"; do
install_if_missing_apt "$pkg"
done

# Check if Ollama is installed
if ! command_exists ollama; then
echo "Ollama is not installed. There's no official apt package yet."
echo "Please follow instructions here: https://github.com/jmorganca/ollama"
echo "After installing Ollama, re-run this script."
exit 1
else
echo "Ollama is already installed."
fi
fi

# ------------------------------------------------------------------------------
# 4. SETUP .ENV
# ------------------------------------------------------------------------------
if [ -f ".env" ]; then
echo ""
echo ".env file already exists. Skipping copy of .env.example."
echo ""
else
echo "Ollama is installed."

# Check if Ollama server is running
check_ollama_server

# Check and pull required models
check_and_pull_model "llama3.2:1b" && check_and_pull_model "qwen2.5:0.5b"
echo ""
echo ".env file does not exist. Copying .env.example to .env."
echo ""
cp .env.example .env
fi

# ------------------------------------------------------------------------------
# 5. OLLAMA SERVER AND MODELS
# ------------------------------------------------------------------------------
# If Ollama is installed, let's start the server and pull models
if command_exists ollama; then
check_ollama_server
# check_and_pull_model "llama3.2:1b"
check_and_pull_model "qwen2.5:0.5b"
fi

# Install npm dependencies
npm i
# ------------------------------------------------------------------------------
# 6. NPM DEPENDENCIES
# ------------------------------------------------------------------------------
echo ""
echo "Installing npm dependencies..."
echo ""
npm install

# Check if whisper.cpp directory exists
# ------------------------------------------------------------------------------
# 7. WHISPER.CPP SETUP
# ------------------------------------------------------------------------------
if [ -d "whisper.cpp" ]; then
echo "whisper.cpp directory already exists. Skipping clone and setup."
echo "whisper.cpp directory already exists. Skipping clone and setup."
else
echo "Cloning whisper.cpp repository..."
git clone https://github.com/ggerganov/whisper.cpp.git
# Download whisper models
echo "Downloading whisper models..."
bash ./whisper.cpp/models/download-ggml-model.sh tiny
bash ./whisper.cpp/models/download-ggml-model.sh base
bash ./whisper.cpp/models/download-ggml-model.sh large-v3-turbo
# Compile whisper.cpp
echo "Compiling whisper.cpp..."
cmake -B whisper.cpp/build -S whisper.cpp
cmake --build whisper.cpp/build --config Release
rm -rf whisper.cpp/.git
echo "Cloning whisper.cpp repository..."
git clone https://github.com/ggerganov/whisper.cpp.git

echo "Downloading whisper models..."
bash ./whisper.cpp/models/download-ggml-model.sh tiny
bash ./whisper.cpp/models/download-ggml-model.sh base
bash ./whisper.cpp/models/download-ggml-model.sh large-v3-turbo

echo "Compiling whisper.cpp..."
cmake -B whisper.cpp/build -S whisper.cpp
cmake --build whisper.cpp/build --config Release

# Optionally remove .git folder to keep workspace clean
rm -rf whisper.cpp/.git
fi

echo ""
echo "Setup completed successfully!"
Loading

0 comments on commit 8ad8b5e

Please sign in to comment.