ALEPH HUB
/EN
提交
← 返回
m
Communityprompt

macOS Voice Input App (One-Shot Prompt)

一条 Claude Code 提示词,一次性生成完整的 macOS 菜单栏语音输入法应用(Swift)——按住 Fn 流式听写、RMS 驱动的胶囊 HUD、绕过中文输入法的剪贴板注入,以及对转写文本的保守 LLM 纠错。这就是 yetone 语音输入法应用的「源代码」:整个 app 由这一份规格生成。

概览安全

yetone 的语音输入法把提示词当作源代码:README 就是一条 `claude -p` 调用,其规格直接生成整个 app。提示词是精确的 7 点构建指令——Fn 键 CGEvent tap 并抑制 emoji 选择器、默认 zh-CN 的 Apple Speech 流式转写并支持菜单栏切换语言、无边框 NSPanel/NSVisualEffectView 胶囊窗(实时 RMS 波形 + 弹性转写标签)、临时切到 ASCII 输入源以防中文输入法拦截 Cmd+V 的剪贴板粘贴注入、OpenAI 兼容的保守纠错、配置 API 端点的设置界面,以及经 SwiftPM 打包为签名 .app 的 LSUIElement 形态。可作为「提示词驱动、一次成形」app 生成的参考规格,或改造成你自己的听写工具。

Please implement a macOS menu-bar voice input app (Swift, macOS 14+) with the following requirements:

1. Hold the Fn key to record, release to inject the transcribed text into the currently focused input field. Use streaming transcription (Apple Speech Recognition framework) as preferred approach. Monitor Fn key globally via CGEvent tap, suppressing the Fn event to prevent triggering the emoji picker.
2. Default language must be Simplified Chinese (zh-CN), ensuring Chinese input recognition works out of the box. Also provide language switching options in the menu bar (English, Simplified Chinese, Traditional Chinese, Japanese, Korean). Language selection is stored in UserDefaults.
3. While recording, display an elegant frameless capsule-shaped floating window centered at the bottom of the screen — no traffic lights or titlebar. Use NSPanel (nonactivatingPanel) + NSVisualEffectView (.hudWindow material), sufficient height (56px, corner radius 28px), containing:
   - 5 vertical bar waveform animation on the left (44×32px), driven by real-time audio RMS levels (no hardcoded fake animations) — louder speech produces larger waveforms, quiet moments produce smaller ones. Bar weights are [0.5, 0.8, 1.0, 0.75, 0.55] creating a natural center-high, sides-low effect. Smooth envelope (attack 40%, release 15%), add ±4% random jitter per bar for organic feel. Waveforms should be large enough to be clearly visible.
   - Text label on the right (elastic width 160-560px) showing real-time transcription, capsule elastically widens as text grows
   - Entry spring animation (0.35s), text width smooth transition (0.25s), exit scale animation (0.22s)
4. Text injection uses clipboard + simulated Cmd+V paste. Before injection, detect the current input method: if it is a CJK input method, temporarily switch to an ASCII input source (ABC/US keyboard) before pasting, then restore the original input method after paste completes — this prevents CJK input methods from intercepting Cmd+V. Restore original clipboard contents after injection.
5. Integrate LLM to improve speech recognition accuracy, especially for mixed Chinese-English scenarios. Use an OpenAI-compatible API (configurable API Base URL, API Key, Model) to refine transcribed text. The LLM system prompt must be very conservative in corrections: only fix obvious speech recognition errors (e.g., Chinese homophone errors, English technical terms mistakenly converted to Chinese like 配森→Python, 杰森→JSON). Never rewrite, polish, or remove any content that appears correct — if the input looks correct, return it as-is.
6. Provide an LLM Refinement submenu in the menu bar with an enable/disable toggle and a Settings entry. The Settings window contains three input fields: API Base URL, API Key, Model — the API Key field must support being fully cleared — plus Test and Save buttons. After releasing Fn, if LLM is enabled and configured, the floating window shows a Refining... status, waiting for the LLM response before injecting the final text.
7. The app runs in LSUIElement mode (menu bar icon only, no Dock icon). Build with Swift Package Manager, provide a Makefile (build/run/install/clean), build output is a signed .app bundle.
#macos#swift#voice-input#speech-to-text#code-generation
相关推荐
Coherence Coach
AWeirdDev
Community

监看对话,找出助手可能忽略的上下文,仅在确有必要时给出提醒,否则返回 null。

promptmarkdown
React + Tailwind Product Card Component Prompt
AmirMotefaker
Community

让模型扮演资深前端工程师,生成可用于生产环境、响应式的 React + Tailwind CSS 商品卡片组件(TypeScript)。

promptmarkdown
Secure JWT Authentication Middleware
AmirMotefaker
Community

一个「角色/任务/规则」结构的提示词模板,要求模型为 Node.js + Express 设计安全的 JWT 认证中间件,包含 bcrypt 密码哈希与完整错误处理。

promptmarkdown