Metadata-Version: 2.4
Name: whistle-type
Version: 0.1.1
Summary: Press F12, speak and paste with local transcription
Author: BlazingBanana Ltd
License-Expression: LicenseRef-Proprietary
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.24
Requires-Dist: PySide6-Essentials<7,>=6.6
Requires-Dist: python-xlib<1,>=0.33; sys_platform == "linux"
Requires-Dist: pynput<2,>=1.8.1; sys_platform == "win32" or sys_platform == "darwin"
Requires-Dist: platformdirs<5,>=4
Requires-Dist: certifi>=2024.2.2
Requires-Dist: sherpa-onnx==1.13.4
Requires-Dist: sherpa-onnx-core==1.13.4
Requires-Dist: sounddevice<1,>=0.5
Requires-Dist: soxr<2,>=1.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.9; extra == "dev"
Provides-Extra: build
Requires-Dist: pyinstaller<7,>=6.16; extra == "build"
Requires-Dist: pillow<13,>=11; extra == "build"

# Whistle Type

Press **F12**, speak, then press **F12** again. Whistle Type transcribes on your
computer and pastes into the field you're typing in.

It runs in the system tray. The menu shows the current status, Settings and Quit.
It uses your system's default microphone and records until you press the shortcut again.

## Install the app

| Platform | Package | Setup |
| --- | --- | --- |
| Windows 10/11, x64 | `.exe` installer | Run the installer, then open Whistle Type from Start. |
| macOS 13 or newer, Apple Silicon | `.dmg` | Drag Whistle Type into Applications and open it. |
| Ubuntu 22.04 or newer, x64, X11 | `.deb` | Run `sudo apt install ./whistle-type_0.1.1_amd64.deb`, then open Whistle Type. |

The app runs in the notification area on Windows, the menu bar on macOS and the
system tray on Linux. Python is included in each package. Linux needs an X11
session; Wayland is not supported yet.

On macOS, allow **Accessibility** in System Settings > Privacy & Security, then
reopen the app. Allow **Microphone** access when you first record. If macOS also
asks for Input Monitoring, allow it for Whistle Type. If your keyboard uses F12
for volume, use **Fn+F12** or enable standard function keys in Keyboard settings.

The Windows app runs as your normal user. Applications running as administrator
may block automatic paste; the transcript remains on the clipboard.

## Settings

Open **Settings** from the tray menu:

- **Recording shortcut**: click it, then press a key or key combination. F12 is
  the default. The shortcut is paused while Settings is open so you can change it.
- **Press Enter after pasting**: off by default. When enabled, the app pastes the
  transcript, then presses Enter. This can send a message or run a command in
  the app you are using.
- **Transcribe while recording**: off by default. Process phrases in the
  background as you speak, then finish the remaining speech and paste once
  when you stop. Leave it off to transcribe the whole recording as before.

Choose **Save** to apply the settings and keep them for the next launch. A shortcut
conflict on Linux leaves the previous settings intact. Some keys and shortcuts
are reserved by the operating system. Modifier keys need a second key.

Enter is sent only after automatic paste succeeds, while the same window still
has focus and no keys are held. Text left for manual paste is never submitted.
Settings are available when dictation is idle; finish a recording before changing them.

The optional live mode uses Sherpa-ONNX's existing Silero VAD and Parakeet
components, following its [VAD and non-streaming ASR example](https://github.com/k2-fsa/sherpa-onnx/blob/master/python-api-examples/vad-with-non-streaming-asr.py).
SoXR resamples microphone audio continuously. Live mode groups at least eight
seconds of audio before splitting at a pause, preserving more sentence context.
It includes a short margin after detected speech and rechecks a short final
ending together with the preceding block. Uninterrupted speech is capped at
30 seconds per segment. If a detected speech block returns no text, the app
retries the complete recording. Live mode can reduce the wait after stopping,
but words and punctuation can differ from transcribing the complete recording.
It does not type partial text into other apps.

First use downloads a verified 629 KiB Silero speech detector from the upstream
Sherpa-ONNX release into the app's model folder. Later uses work offline. If live
processing fails, the app transcribes the original recording using the standard
path. The detector and live worker are only used when this setting is enabled.

## Run from source

Python 3.10 or newer is required. On Ubuntu or Debian, install PortAudio with
`sudo apt install libportaudio2`. Development builds on Windows and macOS use
the same platform-specific shortcut handling as the packaged apps.

From this repository:

```bash
cd apps/whistle-type
uv run whistle-type
```

Or use pip:

```bash
python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/whistle-type
```

On Windows, replace `.venv/bin` with `.venv/Scripts`. On macOS, source runs need
Accessibility permission for the terminal or Python process that launches them.

Wait for the tray notification saying it's ready, click a text field and use F12.
The chosen shortcut is reserved while Whistle Type is running, including in
browsers. Holding it down counts as one press. Choose **Quit Whistle Type** in
the tray menu to release it.

The app pastes with Ctrl+V on Windows, Command+V on macOS and Shift+Insert on
Linux. Linux also receives the text in its primary selection for terminal paste.
If you switch windows during transcription or are still holding a key, the app
leaves the text copied for you to paste yourself. Applications that don't accept
the platform's paste shortcut need a manual paste.

## Speech model

Whistle Type uses the same Parakeet v3 int8 model as Whistle Notes and Enterprise.
In this checkout it reuses the Enterprise model. It also looks in the installed
Notes and Subtitles model directories.

If no model is available, the first launch downloads a verified 465 MiB archive
to the application data folder:

- Windows: `%LOCALAPPDATA%/whistle-type/models`.
- macOS: `~/Library/Application Support/whistle-type/models`.
- Linux: `~/.local/share/whistle-type/models` (or `$XDG_DATA_HOME/whistle-type/models`).

The installed model takes about 640 MiB. Later launches work offline. The model
is kept in memory while the app runs so dictation can start immediately.

To choose an existing copy:

```bash
uv run whistle-type --model-dir /path/to/sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8
```

`WHISTLE_TYPE_MODEL_DIR` sets the same option. The directory needs
`encoder.int8.onnx`, `decoder.int8.onnx`, `joiner.int8.onnx` and `tokens.txt`.

Audio stays in memory and is discarded after transcription. The app does not
save recordings or transcript history. Text is left on the clipboard; a desktop
clipboard manager may keep its own history.

## Check

```bash
uv run --extra dev pytest -q
uv run --extra dev ruff check .
```

The tests cover recording failures, busy presses, empty results, clipboard
delivery, focus changes, shortcut capture, saved settings, optional Enter, live
recording, cancellation, final audio delivery, fallback to standard transcription,
quitting and model download validation. Tests use an
offscreen Qt platform and do not capture your microphone or send keys to your
desktop.

## Build installers

Build on the target operating system with Python 3.12:

```bash
uv sync --python 3.12 --extra dev --extra build
uv run --extra build python scripts/build.py
```

The installer is written to `dist/`. Windows also needs Inno Setup 6. macOS needs
Xcode command line tools. Linux needs `dpkg-deb` and the desktop libraries listed
in the workflow. A local Linux package declares the build machine's minimum
glibc version; the release workflow builds on Ubuntu 22.04 for broader compatibility.

Every bundle runs a smoke check outside the source folder. It loads Qt,
PortAudio, sherpa-onnx, SoXR, the native shortcut backend, TLS certificates and the
app icon. It does not request microphone or Accessibility permission during CI.
Physical microphone, permission prompts and paste into other apps still need
checking on the native desktop before a public release.

## Release

The [desktop workflow](../../.github/workflows/whistle-type-desktop-build.yml)
tests and builds Linux x64, Windows x64 and macOS arm64 installers. Main and
manual builds save unsigned review artifacts in GitHub Actions. The manual
`signed_review` option signs and notarises review installers without publishing
to the download service. Use those candidates for native acceptance checks. A push of
`whistle-type-v0.1.1` must match the version in `pyproject.toml` and enables release
signing and publication:

- The Windows app and installer are signed with the existing Whistle signing service.
- The macOS app and DMG are signed, notarised and stapled using the existing Mac runner.
- Installers are uploaded under `whistle-type/versions/0.1.1/`.
- Only after all 3 builds succeed, the release helper promotes the installers to
  `whistle-type/latest/` and publishes `whistle-type/versions.json`.

Signing or notarisation failures stop publication. The speech model is downloaded
on first launch, keeping the installers smaller and allowing existing Whistle
model copies to be reused.

Whistle Type is made by BlazingBanana Ltd.
