A real-time speech-to-text clipboard tool.
Project description
asr2clip -- Speech-to-Text Clipboard Tool
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.
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). Make sure you have the necessary credentials.
Installation
Option 1: Install via pip or pipx
You can install asr2clip directly from PyPI using pip or pipx:
# Install using pip
pip install asr2clip
# Alternatively, install using pipx (recommended for isolated environments)
pipx install asr2clip
Option 2: Install from source
- Clone the repository (if applicable):
git clone https://github.com/Oaklight/asr2clip.git
cd asr2clip
- Install the required Python packages:
pip install -r requirements.txt
Option 3: Install using Conda
If you are using Conda, you can create an environment using the provided environment.yaml file:
conda env create -f environment.yaml
conda activate asr
- Set up your API key:
- Create a
asr2clip.conffile in the root directory of the project or in your~/.config/directory. A sample fileasr2clip.conf.exampleis provided. - Add your API key to the
asr2clip.conffile in YAML format:
- Create a
api_key: your_api_key_here
api_base_url: https://api.openai.com/v1
model_name: whisper-1
- Note for Linux users:
If you are using
pyperclipon Linux, make sure to installxcliporxsel. You can install them using the following commands:
sudo apt-get install xsel # Basic clipboard functionality
sudo apt-get install xclip # More advanced functionality
Usage
- Run the tool:
asr2clip
-
Start speaking:
- The tool will start capturing audio from your microphone.
- It will send the audio to the API for speech recognition.
- The recognized text will be automatically copied to your system clipboard.
-
Stop the tool:
- Press
Ctrl+Cto stop the tool.
- Press
Additional Options
- Transcribe from a file:
You can transcribe an audio file directly by specifying the file path. The tool supports any audio format that
pydubcan handle (e.g., MP3, WAV, FLAC, AAC):
asr2clip --input /path/to/audio/file.mp3
- Read audio data from stdin: You can also pipe audio data directly into the tool:
cat /path/to/audio/file.wav | asr2clip --stdin
- Set recording duration: You can specify the duration of the recording in seconds:
asr2clip --duration 10
Configuration
You can customize the tool by modifying the asr2clip.conf file. For example, you can change the API endpoint, audio sampling rate, or other parameters depending on the API service you are using.
Example
$ ./asr2clip.py --duration 5
Recording for 5 seconds...
Recording complete.
Transcribing audio...
Transcribed Text:
-----------------
1,2,3,3,2,1. This is the English test.
The transcribed text has been copied to the clipboard.
Troubleshooting
- Audio not captured: Ensure your microphone is properly connected and configured.
- API errors: Check your API key and ensure you have sufficient credits or permissions.
- Clipboard issues: Ensure
pyperclipis correctly installed and compatible with your operating system. Linux users need to installxcliporxsel.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asr2clip-0.3.5.tar.gz.
File metadata
- Download URL: asr2clip-0.3.5.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65b1987eb21521b9c7c83691c12f5b2d27db186af4e42b3e2b445134e712a494
|
|
| MD5 |
6d59db073f0fd3832e01b9898f765661
|
|
| BLAKE2b-256 |
42c031ec419849796fc5049320d1ae06c5981f4176159942946dddac4320b7ee
|
File details
Details for the file asr2clip-0.3.5-py3-none-any.whl.
File metadata
- Download URL: asr2clip-0.3.5-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4adff07705b3de4421364418ee7f1edc1b72ac31f02f15e13c1c19e995b86f4c
|
|
| MD5 |
fa09c6e4aa58004ec6c843d486c5be87
|
|
| BLAKE2b-256 |
9bc0bc44dfcf4972de33eee396ed1bb80777bcb2990ddd318a4c1066c938b1b1
|