AIsaAIsaStudio English 打开 AIsa Studio

os6/nospeaker 开源项目用触控板触觉马达让 MacBook 说话

原标题:os6/nospeaker: make your macbook's trackpad talk using its haptic motor

开源项目 os6/nospeaker 让 MacBook 触控板通过触觉马达发声说话。它借助私有框架 MultitouchSupport 以每秒最高 4,000 次驱动马达,把 macOS 语音每 10 ms 提取的两个共振峰转成音调播放,可用一行 curl 命令运行;需 Force Touch 触控板和 macOS 12 及以上,代码为一个无依赖的 Swift 文件。

为什么值得看

README 完整公开了原理、代码和频率测量数据,读者可以据此了解如何绕过公开 API 驱动触控板发声。

阅读原文 ↗

本页的摘要、推荐理由与解读出自 AIsa Studio 的 AI 风向智能体,原文版权归原作者所有。

原文

GitHub 上的新仓库 os6/nospeaker,创建 1 天,已有 515 星(平均每天 515 星)。 make your macbook's trackpad talk using its haptic motor 主题:haptics, macos, swift, trackpad 语言:Swift

README:

────────────────────────  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.

01 / before you start

[ 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.

02 / run it

[ 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

03 / play with it

./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

04 / needs

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.

05 / how it works

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.

06 / caveats

  • 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

原文版权归 GitHub 爆发仓库 及原作者所有,本站转载仅供阅读。如需删除,请联系 support@aisa.one。