-
Notifications
You must be signed in to change notification settings - Fork 46
SayKey Developer Guide
This guide will help you set up SayKey on your local machine for development purposes.
- Python 3.10
- Node.js (latest LTS version)
- Git
git clone https://github.com/WenJing95/SayKey.git
cd SayKeycd ./backend
cd CT-Transformer-punctuation
pip install -e .
pip install -r requirements.txtStart the backend server:
python main.py --sense-voice=./sherpa-onnx/model.int8.onnx --tokens=./sherpa-onnx/tokens.txtAfter starting the server, you will see an output like this:
SayKey is running. Hold ctrl+q to start recording, release to recognize.
Important: Ensure the cursor is in the desired input location before using voice typing.
INFO: Uvicorn running on http://localhost:58652 (Press CTRL+C to quit)
Follow the instructions to hold ctrl+q to start recording and release ctrl+q to recognize.
Required Arguments:
-
--tokens: Path to the tokens.txt file needed for the speech recognition model. -
--sense-voice: Path to the SenseVoice model.onnx file.
Optional Arguments:
-
--num-threads: Number of threads (default: 4). -
--microphone-index: Index of the microphone to use. If not specified, the system's default microphone will be used. -
--hotkey: Hotkey combination to start recording (default: ctrl+q). -
--api-port: Port number for the API server (default: 58652). -
--punc-model-dir: Directory path for punctuation model files (default: ./punc-onnx). -
--host: Host address for the API server (default: localhost).
The backend provides several APIs for interaction and configuration. All endpoints can be accessed via HTTP requests to the --api-port (default: 58652).
-
URL:
GET /ping -
Description: Check if the backend server is running.
-
Response:
{ "status": "alive" } -
Example:
curl http://localhost:58652/ping
-
URL:
GET /list_audio_devices -
Description: Retrieve a list of available audio input devices.
-
Response Example:
{ "devices": [ { "index": 0, "name": "Microphone (Realtek High Definition Audio)", "is_current": true }, { "index": 1, "name": "Stereo Mix (Realtek High Definition Audio)", "is_current": false } ] } -
Example:
curl http://localhost:58652/list_audio_devices
-
URL:
POST /set_audio_device -
Description: Set the microphone device by specifying its index.
-
Request Body:
{ "index": 1 } -
Successful Response Example:
{ "status": "success", "message": "success", "device": { "index": 1, "name": "Microphone (Realtek High Definition Audio)" } } -
Example:
curl -X POST http://localhost:58652/set_audio_device \ -H "Content-Type: application/json" \ -d '{"index": 1}'
-
URL:
POST /set_hotkey -
Description: Set the hotkey combination used to start and stop audio recording.
-
Request Body:
{ "hotkey": "ctrl+q" } -
Example:
curl -X POST http://localhost:58652/set_hotkey \ -H "Content-Type: application/json" \ -d '{"hotkey": "ctrl+q"}'
-
URL:
GET /get_hotkey -
Description: Retrieve the current hotkey configuration.
-
Response Example:
{ "hotkey": "ctrl+q" } -
Example:
curl http://localhost:58652/get_hotkey
./build_onefile.batcd ./frontend
npm installBuild and start the frontend:
npm run build
npm startPackage the frontend into an executable:
npm run build
npm run electron:buildTo deploy SayKey, place all files from backend\dist and frontend\release\win-unpacked into the same directory, and run Saykey.exe to start the application.