Nospeaker ─ 使用 MacBook 触控板的触觉马达让其说话
Nospeaker ─ Make your MacBook's trackpad talk using its haptic motor

原始链接: https://github.com/os6/nospeaker

**nospeaker** 是一个让 MacBook 触控板仅用其触觉电机“说话”的工具——没有扬声器。它运行 macOS 语音合成,每 10 毫秒提取一次共振峰(共振),并用相应的音调驱动电机,在你的指尖下产生可听见的语音、歌唱和音乐。 可通过一条命令(`curl -fsSL a90.com/nospeaker | sh`)安装,或下载已签名的二进制文件。它需要 Force Touch 触控板,以及 macOS 12+(Apple Silicon)或 13+(Intel)。已在 MacBook Pro M5 Max 上测试;Intel Mac 和 Magic Trackpad 未测试。 电机从不会被驱动到其正常最大强度之上,因此安全,但由于电机是为点击而设计的,所以声音较轻。代码是单个 Swift 文件,无依赖,使用私有 MultitouchSupport 框架(借鉴自 Tactile 项目)。macOS 更新可能会破坏它。由 Cody Collier 以 MIT 许可证发布。

Hacker News 新 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 Nospeaker ─ 让你的 MacBook 触控板借助触觉马达说话 ( github.com/os6 ) 16 点 由 yakkomajuri 1 小时前 | 隐藏 | 过去 | 收藏 | 2 条评论 帮助 _def 13 分钟前 [–] 缺少演示视频 回复 exitb 7 分钟前 | 父评论 [–] https://nitter.netbub.com/codycollier/status/212450585988371... 回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文
────────────────────────  a90.com presents  ─────────────────────────

    _   __ ____      _____  ____   ______ ___     __ __  ______ ____
   / | / // __ \    / ___/ / __ \ / ____//   |   / //_/ / ____// __ \
  /  |/ // / / /    \__ \ / /_/ // __/  / /| |  / ,<   / __/  / /_/ /
 / /|  // /_/ /    ___/ // ____// /___ / ___ | / /| | / /___ / _, _/
/_/ |_/ \____/    /____//_/    /_____//_/  |_|/_/ |_|/_____//_/ |_|

─  haptic voice synthesis  ─────────────────────────────  trackpad  ─

Mute your Mac. Your trackpad will still talk.

There's no speaker in a MacBook trackpad, just a small haptic motor that taps the glass so you feel a click. NO SPEAKER drives that motor up to 4,000 times a second, fast enough to make sound you can hear, and turns it into a voice. It talks, sings, raps, and becomes an instrument under your finger.

One command. About a minute and a half. No speakers used.

[ mute your mac ]        it still talks; that's the point
[ put it on a table ]    on your lap it's much quieter
[ hands off the glass ]  until it asks you to touch it

Space skips a part. q or Ctrl-C goes to the end.

[ one line ]

curl -fsSL a90.com/nospeaker | sh

Downloads the latest release to ~/.local/bin/nospeaker and starts the show. a90.com/nospeaker points to play.sh in this repo, so you can read what it runs first.

[ download ]

Grab nospeaker.zip from the latest release, unzip it and run ./nospeaker in Terminal. Signed with a Developer ID and notarized by Apple.

[ from source ]

Needs Xcode or the Command Line Tools (xcode-select --install). Builds one program for Apple Silicon and Intel Macs.

git clone https://github.com/os6/nospeaker
cd nospeaker
./build.sh
./nospeaker
./nospeaker "hello there"            say anything
./nospeaker --voice Daniel "hello"   in another macOS voice
./nospeaker --sweep                  a rising tone, 100 Hz to 4 kHz

--dark                               white on black
--plain                              no visuals, plain text

A Force Touch trackpad (built into MacBooks from 2015 on, or a Magic Trackpad 2 or newer), and macOS 12 or later on Apple Silicon, or macOS 13 or later on Intel. Without a Force Touch trackpad, it says so and exits.

tested on

MacBook Pro (Mac17,10)   M5 Max   macOS 27.2.1   everything works

Not tested yet: Intel Macs, a Magic Trackpad, and older versions of macOS. MultitouchSupport is private, so older systems may lack the functions it uses, and loudness differs between trackpads. If you try it on another Mac, open an issue with your model, your macOS version and how it sounded.

say ──▶ formants ──▶ two tones ──▶ motor ──▶ glass
        per 10 ms    F1 + F2       haptics   sound

Why you can hear it. The trackpad has no speaker, but the motor moves the glass. Driven back and forth hundreds or thousands of times a second, the glass vibrates fast enough to make sound you can hear. It's quiet because the motor is built for short taps, not for sound.

The motor. MultitouchSupport is the private framework macOS uses for the trackpad. Its function MTActuationCreateFromDictionary takes a description of a vibration, a list of sine tones with a frequency, a strength and a length each, and MTActuationActuate plays it on the motor. Apple's public haptics API only offers three fixed taps.

The range. Measured with the MacBook's own microphone, every semitone from 98 Hz to 3,951 Hz: how loud it is over a quiet room, and how much of the sound is the note itself.

│                                      ###
│                          #+#     +++#####        #
│                         +#+#+   .+++#####       .#
│              .       ++++#+#+   .+++#####    # #.# #
│   ++        +. . #..+++++#+#++++.+++#####+ #####.###          .#
│   +++#.     +...+#..+++++#+#++++.+++#####+ #####.####+        .#
│  ++++#...   +...+#..+++++#+#++++.+++#####+.#####.####+        .#
│ .++++#...++++...+#..+++++#+#++++.+++#####+.#####.####+  +#    .#
│..++++#...++++...+#..+++++#+#++++.+++#####+.#####.####+#.+#  .#.#
│..++++#...++++...+#..+++++#+#++++.+++#####+.#####.####+#.+#+..#.#
└─────────────────────────────────────────────────────────────────
      131         262         523         1047        2093    3951
   public notes stop at 600 Hz ─┘

across: every semitone, in Hz · up: loudness, +16 to +34 dB
# clean note   + fair   . mostly buzz

It's loud from about 100 Hz to 4 kHz, with a few dead spots where the glass resonates. Its loudest, cleanest notes are around 1 kHz, which covers the most important part of a voice.

The voice. macOS's own voice speaks the line into memory. Every 10 ms, linear prediction finds the voice's two strongest resonances (formants), its loudness and its pitch. The motor plays those two resonances as tones, restarted on every beat of the pitch, so they buzz like a voice instead of whistling. Hiss sounds (s, f, t) become quick bursts of high tones. Two resonances beat three: in a blind test they were clearer, and louder, because the motor's strength is split fewer ways.

It sounds robotic, and it's much easier to follow when you can read along, which is why the show types every line as it speaks.

The code. One Swift file, nospeaker.swift, with no dependencies.

  • Is it safe? It never drives the motor past its normal maximum strength. Going past it is possible and louder, but the driver starts to stall, so nospeaker doesn't.
  • MultitouchSupport is private and undocumented, so a macOS update could break this.

The MultitouchSupport function names were learned from the open-source Tactile project. Everything else was measured on a MacBook.

──────────────────────  thanks for listening  ───────────────────────

Made by Cody Collier · a90.com · MIT license

联系我们 contact @ memedata.com