This repository contains two scripts for voice transcription:
voicetotext: A simple script to record audio and save the transcription to a file.live_dictation: A script for live dictation that types as you speak.
To make these scripts runnable from anywhere, symbolic links have been created in /usr/local/bin. You can now run them by name from any terminal.
Dependencies:
- ffmpeg: You'll need ffmpeg installed for audio recording. You can install it with Homebrew:
brew install ffmpeg - whisper.cpp: This project uses
whisper.cppfor transcription. You can install it with Homebrew:brew install whisper-cpp
- Open a terminal window.
- Run the script:
voicetotext
- Start speaking. The script will record your voice.
- Press
Ctrl+Cto stop recording. - The transcribed text will be saved to
/Users/tjm/Desktop/shorttermprojects/output.txt.
- Open a terminal window.
- Run the script:
live_dictation
- Switch to the application where you want to type.
- Start speaking. The script will transcribe your voice in 5-second intervals and type the text into the active window.
- Press
Ctrl+Cin the terminal window to stop the script.
The live_dictation script works in a continuous loop:
- Records Audio: It uses
ffmpegto record 5-second chunks of audio from your default microphone. - Transcribes Audio: The recorded audio is then passed to
whisper-cppfor transcription. - Simulates Keystrokes: The transcribed text is then typed out in the currently active window using AppleScript.
whisper-cpp: command not found: If you see this error, it means thatwhisper-cppis not installed or not in your system's PATH. Make sure you have installed it via Homebrew (brew install whisper-cpp).- No text is being typed: Make sure you have given your terminal application the necessary accessibility permissions to control your computer. You can do this in
System Settings > Privacy & Security > Accessibility.
For a humorous look at the development of this script, please see the making_of.md file.