Skip to main content

asr2clip -- Speech-to-Text Clipboard Tool

PyPI version GitHub version License

中文

This tool is designed to recognize speech in real-time, convert it to text, and automatically copy the text to the system clipboard. The tool leverages API services for speech recognition and uses Python libraries for audio capture and clipboard management.

TL;DR

pip install asr2clip       # Install the package
asr2clip --edit            # Create/edit config file
asr2clip --test            # Test your configuration
asr2clip                   # Start recording and transcribing

Prerequisites

Before you begin, ensure you have the following ready:

  • Python 3.8 or higher: The tool is written in Python, so you'll need Python installed on your system.
  • API Key: You will need an API key from a speech recognition service (e.g., OpenAI/Whisper API or a compatible ASR API, such as FunAudioLLM/SenseVoiceSmall at siliconflow or xinference).

System Dependencies

Dependency Purpose Linux macOS Windows
ffmpeg Audio format conversion apt install ffmpeg brew install ffmpeg Download
PortAudio Audio recording apt install libportaudio2 brew install portaudio Included with sounddevice
Clipboard Copy to clipboard apt install xclip (X11) or wl-clipboard (Wayland) Built-in Built-in

Installation

Option 1: Install via pip or pipx (Recommended)

# Install using pip
pip install asr2clip

# Or install using pipx (recommended for isolated environments)
pipx install asr2clip

# Upgrade to latest version
pip install --upgrade asr2clip

Option 2: Install from source

git clone https://github.com/Oaklight/asr2clip.git
cd asr2clip
pip install -e .

Configuration

Quick Setup

The easiest way to configure asr2clip is using the built-in editor:

asr2clip --edit  # Opens config file in your default editor

This will create a config file at ~/.config/asr2clip.conf if it doesn't exist.

Configuration File

The configuration file uses YAML format:

api_base_url: "https://api.openai.com/v1/"  # or other compatible API base URL
api_key: "YOUR_API_KEY"                     # api key for the platform
model_name: "whisper-1"                     # or other compatible model
# quiet: false                              # optional, disable logging
# audio_device: "pulse"                     # optional, audio input device

Config file locations (searched in order):

  1. ./asr2clip.conf (current directory)
  2. ~/.config/asr2clip.conf

Test Your Configuration

Before using the tool, verify your setup:

asr2clip --test

This will check:

  • ✓ Clipboard support
  • ✓ Audio device functionality
  • ✓ API connection

Audio Device Selection

If the default audio device doesn't work, list available devices and select one:

asr2clip --list_devices    # List all audio input devices
asr2clip --device pulse    # Use specific device

Or add to your config file:

audio_device: "pulse"  # or device index like 12

Usage

Basic Usage

asr2clip                   # Record until Ctrl+C, transcribe, copy to clipboard
asr2clip -d 10             # Record for 10 seconds
asr2clip -i audio.mp3      # Transcribe an audio file

CLI Options

usage: asr2clip [-h] [-v] [-c CONFIG] [-d DURATION] [--stdin] [-i INPUT] [-q]
                [--generate_config] [-o OUTPUT] [--test] [--list_devices]
                [--device DEVICE] [-e]

Real-time speech recognizer that copies transcribed text to the clipboard.

options:
  -h, --help            show this help message and exit
  -v, --version         Show program version and exit.
  -c CONFIG, --config CONFIG
                        Path to the configuration file. Default is
                        'asr2clip.conf'.
  -d DURATION, --duration DURATION
                        Duration to record (seconds). If not specified,
                        recording continues until Ctrl+C.
  --stdin               Read audio data from stdin instead of recording.
  -i INPUT, --input INPUT
                        Path to the input audio file to transcribe.
  -q, --quiet           Disable logging.
  --generate_config     Print the template configuration file and exit.
  -o OUTPUT, --output OUTPUT
                        Path to the output file. If not specified, output will
                        be copied to the clipboard. Use '-' for stdout.
  --test                Test the full configuration (API, audio device,
                        clipboard) and exit.
  --list_devices        List available audio input devices and exit.
  --device DEVICE       Audio input device (name or index). Overrides config
                        file setting.
  -e, --edit            Open the configuration file in the system's default
                        editor.

Examples

# Record for 5 seconds
asr2clip --duration 5

# Transcribe an audio file
asr2clip --input recording.mp3

# Output to stdout instead of clipboard
asr2clip --output -

# Pipe audio data
cat audio.wav | asr2clip --stdin --output -

# Use specific audio device
asr2clip --device pulse

Troubleshooting

Problem Solution
Audio not captured Run asr2clip --list_devices and select a working device
Clipboard not working Install xclip (X11) or wl-clipboard (Wayland)
API errors Check your API key and endpoint in config
Silent audio Try a different audio device with --device

Run asr2clip --test to diagnose issues.

Contributing

If you would like to contribute to this project, please fork the repository and submit a pull request. We welcome any improvements or new features!

License

This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for details.

Metadata

Release files for asr2clip 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asr2clip 0.3.7
File Size Uploaded
asr2clip-0.3.7.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asr2clip 0.3.7
File Interpreter ABI Platform
asr2clip-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 46.2 kB

Release files / asr2clip-0.3.7.tar.gz

Download URL asr2clip-0.3.7.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1f3f4d1042b1699c3ff403553e74ff2da3822013e2822f28902ce1c0095a4325
BLAKE2b-256 checksum
How to use checksums
9f19a3b71c9c49d44e6c1c9d127fdf8addffa9044ed67e337a4b58c87ee7c820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release files / asr2clip-0.3.7-py3-none-any.whl

Download URL asr2clip-0.3.7-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e619e87d6fa072b19ea9710f280869d32b3c555bdd5177e952da16ff4d562e1
BLAKE2b-256 checksum
How to use checksums
b4a07831cf6ea125ef27a7da58668fbc74ae6a9a89a5eb805a1948a287e0d934
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page