Skip to main content

Integrate OpenAI speech-to-text Whisper with your keyboard

Project description

whisper-keyboard

Video demo: https://www.youtube.com/watch?v=VnFtVR72jM4&feature=youtu.be

Smulate keyboard typing with voice commands on your computer. Use the power of OpenAI's Whisper.

Start the wkey listener. Keep a button pressed (by default: right ctrl) and speak. Your voice will be recoded locally. When the button is released, your command will be transcribed via Whisper and the text will be streamed to your keyboard.

You can use your voice to write anywhere.

You will incur costs for Whisper API. Currently, it costs $0.36 for 1 hour of transcription.

Setup

Install the package.

pip install wkey

You will need to set two environment variables:

  • OPENAI_API_KEY: your personal OpenAI API key. You can get it by signing up here: https://platform.openai.com/
  • WKEY: the keyboard key you want to use to start recording. By default, it is set to right ctrl. You can use any key. Note that Mac and Windows might have different key codes. You can run fkey to find the code of the key you want to use.

You can set the environment variables in your shell:

export OPENAI_API_KEY=<your key>
export WKEY=ctrl_r

Run wkey in a terminal window to start listening.

If there are issues, check the additional requirements.

Additional requirements

Requirements differ depending on your OS.

Ubuntu

You will need to install the portaudio library.

sudo apt-get install portaudio19-dev 

Mac

You will need to authorize your terminal to use the microphone and keyboard. Go to System Settings > Privacy and Security. Then:

  • Select Microphone and authorize your terminal.
  • Select Accessibility and authorize your terminal.

Restart the terminal for the changes to take effect.

Note that this might entail security risks.

Windows

Haven't tested it on Windows yet. If you do, please let me know how it goes.

Security risks

This script creates a recording with your microphone and sends the audio to the Whisper API. The Whisper API response will be automatically streamed to your keyboard and executed there. This might entail security risks. Use at your own risk.

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

wkey-0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

wkey-0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file wkey-0.2.tar.gz.

File metadata

  • Download URL: wkey-0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for wkey-0.2.tar.gz
Algorithm Hash digest
SHA256 b9b4d61e0a684a7b4d68c1c316fb63f4bd026dff2b943bdead26e34cc4e87a18
MD5 8922034d7dfefc93df12378b16db2f35
BLAKE2b-256 5906b80383fb66e81a323d7da16159a06ef16eb1d6653e0f98e02ca9735db809

See more details on using hashes here.

File details

Details for the file wkey-0.2-py3-none-any.whl.

File metadata

  • Download URL: wkey-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for wkey-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7dfe4442270a3572547992ec664f7aa65c547e6fcffadda4bb633455b16b91ed
MD5 994e80daedee1b9d94c47df33f1d1847
BLAKE2b-256 8bb2f952e9dbd4e99e3a91f09b8071c760ded03e68c333aa8ccb3147bb8a0eca

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