Skip to main content

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

  1. Clone the repository (if applicable):
git clone https://github.com/Oaklight/asr2clip.git
cd asr2clip
  1. Install the required Python packages:
pip install -r requirements.txt
  1. Set up your API key:
    • Create a asr2clip.conf file in the root directory of the project or in your ~/.config/ directory. A sample file asr2clip.conf.example is provided.
    • Add your API key to the asr2clip.conf file:
asr_model:
  api_key: "your_api_key_here"
  api_base_url: "https://api.openai.com/v1" # If you need to customize the API URL
  model_name: "whisper-1" # Default model name
  1. Note for Linux users: If you are using pyperclip on Linux, make sure to install xclip or xsel. 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

  1. Run the tool:
python asr2clip.py

Alternatively, if you have made the script executable (chmod +x asr2clip.py), you can run it directly:

./asr2clip.py
  1. 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.
  2. Stop the tool:

    • Press Ctrl+C to stop the tool.

Configuration

You can customize the tool by modifying the config.yaml 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 pyperclip is correctly installed and compatible with your operating system. Linux users need to install xclip or xsel.

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 more 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

asr2clip-0.2.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asr2clip-0.2.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file asr2clip-0.2.0.tar.gz.

File metadata

  • Download URL: asr2clip-0.2.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.20

File hashes

Hashes for asr2clip-0.2.0.tar.gz
Algorithm Hash digest
SHA256 75dbed0815569005cb696a289658c8f28d927c8b52e245d6fee64fa2a3381e83
MD5 574849d0e986819d02d6484750af1194
BLAKE2b-256 afbe4a92382d337a3e9ff3c705bc75f1463098260c5010652a2d93536bdd43c6

See more details on using hashes here.

File details

Details for the file asr2clip-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: asr2clip-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.20

File hashes

Hashes for asr2clip-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d43336cf83de472350019c4323a11836fd0a6cb73b46e188ad44f1f4e9fab1c3
MD5 0ada422c0a057b2dca58ec7be23840bb
BLAKE2b-256 5143ec94db508442ce623ea4f01b0b1669a4e6c7c4ec6153219cc64b8ef85d59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page