Created
December 29, 2023 23:38
-
-
Save Brandon7CC/29fad35e4d2a5f07693c3990ca4946af to your computer and use it in GitHub Desktop.
📣 Giving Ollama a voice with the macOS `say` command! NOTE: Change to Siri in `System Settings.app` for the best results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function speak_ollama() { | |
if ! command -v ollama &> /dev/null; then | |
echo "Error: ollama is not installed." | |
return 1 | |
fi | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: speak_ollama <file_path> <model>" | |
return 1 | |
fi | |
local file_path="$1" | |
local model="$2" | |
if [ ! -f "$file_path" ]; then | |
echo "Error: File not found at $file_path" | |
return 1 | |
fi | |
local prompt=$(cat "$file_path") | |
local completion=$(ollama run "$model" "$prompt") | |
say "$completion" --progress --rate=180 | |
} |
If you have bluetooth speakers, you may experience words being cut-off. Mac bluetooth sucks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
One liner
curl -sL https://gist.githubusercontent.com/Brandon7CC/29fad35e4d2a5f07693c3990ca4946af/raw/edde21dace26bfd91b43b4e1fa82f4b373fd1689/speak_ollama.sh >> ~/.zshrc && source ~/.zshrc