用 Claude 定位神秘的蜂鸣声来源
原题Locating the source of a mysterious beep with Claude
推荐理由Simon Willison 用多设备声学定位解决真实蜂鸣器问题,展示代码智能体连接硬件感知后如何逐步验证方案,读者能学习可观察实验而非只看炫技演示。
读前速览
作者展示了 Claude Code 如何构建一套多设备声学三角定位系统,在房间内找到神秘蜂鸣声的来源,展现了 AI 如何通过连接设备为智能体赋予感知能力。
通过连接硬件为 AI 智能体赋予感知能力
通过运行 Web 服务器,并借助 WebSockets 和 WebAudio 连接多台设备,Claude Code 得以「为智能体装上耳朵」——将基于文本的 AI 转变为能够感知并分析物理环境中声学信号的系统。
BeepBeep 论文为声学三角定位提供了技术基础
Claude Code 自主研究并实现了一篇 2007 年的学术论文,该论文探讨了如何使用普通设备进行高精度声学测距。这展示了 AI 查找、理解并应用相关技术文献来解决现实问题的能力。
通过迭代提示词,无需手动操作设备即可快速开发功能
作者可以在 Claude Code 工作时着手设置设备。系统的热插拔模块机制允许更新代码,而无需在每台设备上重新加载页面;这对于在物理环境中免手动操作地开发至关重要。
系统成功将蜂鸣声来源定位到 40cm 以内
构建并测试三角定位系统后,作者在 AI 构建的软件所指示的精确位置,找到了一个老旧的一氧化碳探测器,验证了这一技术方案的有效性和实用价值。
完整摘要
文章介绍了 AI 辅助开发的一项实际应用:Simon Willison 使用 Claude Code 构建了「Beep Locator」——一款 Python Web 应用,可将多台设备用作麦克风和扬声器,以三角定位法确定声源。系统使用 WebSockets 协调设备,通过 WebAudio 捕获声音,并以一篇 2007 年的 BeepBeep 论文为技术基础。经过多轮提示词迭代,Claude 实现了拖放式粗略定位、拍手测试模式、带时间戳的声音标记以及回放功能。系统成功将一台一氧化碳探测器定位在 40cm 范围内。文章强调,只要将编程智能体连接到外部硬件,就能为其赋予感知能力,让它们的感知范围超越文本交互。
2026年11月9日9th November 2026
我们家有一间储物间,里面堆满了箱子,都是上次搬家后还没拆开的。几周前,那个房间里开始间歇性地传出哔哔声。每次哔声间隔都很长,站在房间里试图找出声音来源实在令人沮丧,而且我真的不想把那些箱子一个个翻遍。于是我让 Claude Code 开发了 Beep Locator——一套利用散布在房间各处的多台设备,对神秘哔声来源进行三角定位的软件系统。Our house has a box room, full of boxes that we still haven’t unpacked from our last move. A couple of weeks ago something in that room started intermittently beeping. The beeps were far enough apart that standing in the room and trying to determine the source of the noise was frustrating, and I really didn’t want to dig through every one of those boxes. So I had Claude Code build Beep Locator, a software system for triangulating the source of a mysterious beep using multiple devices scattered around the room.
这是 Beep Locator 运行一段时间后的样子:Here’s what Beep Locator looks like after it has been running for a while:

运行 Python Web 服务器来显示主界面,然后通过二维码或 URL 连接尽可能多的闲置设备,让它们充当监听器——我当时用的是两台 iPad、一部手机、一台 MacBook Pro 和一台 Surface Ultra。You run Python web server to show the primary UI, and then use the QR code or URL to connect as many devices as you can spare to act as listeners—I was using two iPads, a phone, a MacBook Pro and a Surface Ultra.
随后,这些设备会彼此播放声音,以帮助估算它们的位置。这个方法效果不太理想,所以我添加了“粗略模式”,让你可以在空间中拖动设备图标来提供大致位置,然后再根据这些声音进行调整。The devices then play noises to each other to help estimate their locations. This didn’t work particularly well, so I added a “Rough mode” where you can drag their icons around in the space to provide rough locations which are then adjusted based on those sounds.
设置完成后,所有设备都会等待哔声!Once that’s set up, the devices all listen for the beep!
我还添加了一个拍手模式,这样我就能在房间里不同位置拍手进行测试,并在地图上以菱形显示拍手的位置。这让我更确信它能够定位声音。I added a clapping mode too so I could test it by clapping my hands in different locations around the room—displayed as diamonds on the map. This helped me gain confidence that it was capable of locating a sound.
蜂鸣声会在地图上显示为一个 X,并记录在“已定位的声音”日志中。你可以依次从每台设备重放这些声音,确认它们是否就是你要找的神秘蜂鸣声,然后点击“这是神秘蜂鸣声”将其标记出来。Beeps show up on the map as an X, plus a line in the “Sounds located” log. You can replay these sounds (from each device in turn) to confirm they are the mysterious beep you are looking for, then click “This is the mystery beep” to mark them as such.
一旦你确认了神秘哔声的频率,系统就会监听这种声音,测量哔声之间的间隔,并利用三角定位得出的地点,在地图上锁定最有可能的位置。Once you’ve confirmed the mysterious beep frequency the system will listen out for it, measure the interval between beeps, and use the triangulated locations to lock down the most likely location on the map.
系统按预期工作了。它将蜂鸣声的位置定位到了约40厘米的误差范围内,随后我翻找了那堆特定的箱子,找到一个急需更换电池的老式一氧化碳探测器。The system worked as intended. It gave me the position of the beep to within about 40cm, then I dug through that specific pile of boxes and found an ancient carbon monoxide detector that desperately wanted its batteries replaced.
工作原理How it works
当我开始和 Claude 一起着手解决这个问题时,它很快就找到了《BeepBeep:一种利用 COTS 设备进行测距与定位的高精度声学系统》——这篇论文发表于 2007 年,作者是 Chunyi Peng、Guobin Shen、Yongguang Zhang、Yanlin Li 和 Kun Tan。以下是该论文的摘要:When I started working through this problem with Claude it quickly dug up BeepBeep: A High-Accuracy Acoustic-Based System for Ranging and Localization Using COTS Devices, a 2007 paper by Chunyi Peng, Guobin Shen, Yongguang Zhang, Yanlin Li, and Kun Tan. Here’s that paper’s abstract:
我们介绍了 BeepBeep 的设计、实现与评估。BeepBeep 是一种高精度的声学测距系统,可在自发、临时组建的设备到设备场景中运行,无需依赖任何预先规划的基础设施。它是一种纯软件解决方案,仅使用最基本的商用硬件——扬声器、麦克风以及某种形式的设备间通信——因此可轻松应用于许多低成本传感器平台,以及手机、PDA 等大多数商用现成移动设备。它结合了三种技术来实现高精度:双向感知、自录制和采样计数。We present the design, implementation, and evaluation of BeepBeep, a high-accuracy acoustic-based ranging system. It operates in a spontaneous, ad-hoc, and device-to-device context without leveraging any pre-planned infrastructure. It is a pure software-based solution and uses only the most basic set of commodity hardware – a speaker, a microphone, and some form of device-to-device communication – so that it is readily applicable to many low-cost sensor platforms and to most commercial-off-the-shelf mobile devices like cell phones and PDAs. It achieves high accuracy through a combination of three techniques: two-way sensing, self-recording, and sample counting.
听起来这正是我们需要构建的东西!That sounded exactly like what we needed to build!
Beep Locator 运行一个 Python Web 应用服务器,负责处理大部分工作。监听设备随后通过 WebSocket 连接到该服务器,并显示一个请求浏览器麦克风访问权限的界面。监听设备的主要工作方式是录制最近 60 秒的音频缓冲区。它们还会运行一个简单的蜂鸣声检测算法(参见 detector.js),通过快速傅里叶变换和高通滤波器识别潜在的蜂鸣声,并将这些事件发送到主服务器。Beep Locator runs a Python web application server that does most of the work. The listening devices then connect to that server via WebSockets and present a UI which requests browser microphone access. The listeners mainly work by recording a 60 second buffer of recent audio. They also run a simple beep detection algorithm (see detector.js), which uses Fast Fourier Transform and a high-pass filter to identify potential beeps. It sends these events to the main server.
报告有蜂鸣声后,服务器会让一台设备播放一声短促的啁啾声(选择与服务器往返延迟最低的设备),然后要求每个监听设备上传一段音频,内容从蜂鸣声发生前约 0.6 秒开始,持续到这声啁啾声结束后约 0.8 秒。啁啾声可用于对齐各段音频,这是定位蜂鸣声的关键步骤。When a beep is reported, the server has a device play a short chirp (the device with the lowest round-trip time to the server), then asks every listener upload a clip from about 0.6s before the beep to 0.8s after that chirp. This chirp allows the clips to be aligned with each other, a crucial step in locating the beep.
我是如何构建它的How I built it
我通过 iPhone 使用 Claude Code Cloud 启动了这个项目,当时运行的是 Opus 5.5,并开启了 Extra thinking effort 模式。以下是那个共享的初始会话,它以这条提示开始,目标是一个新建的空 GitHub 仓库:I started this project using Claude Code Cloud via my iPhone, with Opus 5.5 running in Extra thinking effort mode. Here’s that shared starter session, which began with this prompt against a newly created empty GitHub repository:
编写一个 problem.md 文件,描述我们想要解决的问题。 房间里有一台设备一直在发出哔哔声,但我找不到它。我想在房间周围设置几台设备——笔记本电脑、手机、iPad——让它们同时监听,并协助确定哔哔声的来源位置。 需要开发一个 Python Web 应用来协调这一切:一台设备显示该应用的网页,其他设备通过访问一个 URL 加入,并变成监听设备。所有操作都通过浏览器中的 WebAudio 和 WebSocket 与 Python 服务器应用通信。 理想情况下,我不需要手动输入这些设备的相对位置。如果它们能互相播放声音,以此确定彼此在二维空间中的位置,那就太棒了——不过,这真的可行吗?
Write out a problem.md file describing the problem we want to solve
There is a device beeping in a room and I cannot find it
I want to set up several devices - laptops, phones, iPads - around the room all listening at the same time and have them help triangulate where the beep comes from
There needs to be a Python web app which coordinates it all - one device shows a web page for the app, other devices join a URL which turns them into listeners - all via browser WebAudio and WebSockets back to the Python server app
Ideally I wouldn't need to manually input the relative locations of the devices - it would be amazing if they could play sounds to each other in order to locate each other in 2D space - is that even possible though?
于是我得到了这个 problem.md 文件。在撰写这份文档的过程中,Claude 找到了并阅读了 BeepBeep 论文,这篇论文在该文件中有介绍。That got me this problem.md file. As part of writing that up Claude found and read the BeepBeep paper, which is described in that file.
研究看起来不错,所以我对它说:The research looked good, so I told it:
好,试着把它构建出来,再加上一种机制,让你可以向监听器发送新代码,由它们自动运行。这样我就能在房间里把一切都设置好,然后让你继续折腾和试验,而我去做点别的。
Ok try and build it, add a mechanism so you can send new code to the listeners which they will then run automatically - that way I can set everything up in the room and then leave you alone to continue hacking and experiment while I do something else
到这一步,系统的大部分都已经搭建完成,但还没有真正尝试运行过。That got me to this point—most of the system was built, but nothing had actually tried running it yet.
我把新仓库克隆到了笔记本上,启动了 Claude Code……随后 Fable 5.2 发布了,而这个项目似乎正是全面测试它的绝佳机会。I cloned the new repository to my laptop and fired up Claude Code... and then Fable 5.2 was released, and this project seemed like an excellent opportunity to put that through its paces.
我让笔记本上的 Claude Code 启动服务器,然后确认它既能看到运行过程中发生的情况,也能在软件运行时实时修改它。I had Claude Code on my laptop start the server running, then made sure it could both see what was happening and make live changes to the software as it ran.
这已经内置在软件中了:Opus 5.5 在监听器上实现了 installModule() 方法,可以通过 WebSocket 连接触发,这意味着管理服务器能够在任意客户端上执行任意新代码。This was already baked into the software: Opus 5.5 had built an installModule() method on the listeners that could be triggered over the WebSocket connection, meaning the admin server could execute arbitrary new code on any of its clients.
在某些设备上,每当页面重新加载时,使用麦克风监听的网页都会请求用户授权。热替换模块机制让我们能够部署新代码,而不必逐一手动操作每台正在监听的设备。On some devices, web pages that listen on the microphone request user permission any time the page reloads. The hot-swap module mechanism meant that we could deploy new code without having to manually interact with each of the listening devices in turn.
从那以后,我主要就是坐在笔记本电脑旁,和 Fable 5.2 聊聊正在发生的事情,偶尔也会提出添加新功能的请求。以下是我用过的一些功能提示词:From that point on my involvement was mainly to sit by the laptop chatting with Fable 5.2 about what was going on, and occasionally requesting new features. Here are some of the feature prompts I ran:
我觉得我们需要加一个“粗略模式”,这样我就能在地图上拖动这些东西,把它们大致放到正确的位置;然后退出粗略模式,让系统尝试将它们精确定位。
I think we need to make it so I can drag things around on the map in “rough mode”, where my job is just to put them roughly where they are, then switch out of rough mode and it attempts to get them accurate
这让我能够在地图上拖动听众。This gave me the ability to drag listeners around the map.
我在想,有什么好办法可以测试这个?能不能让它监听拍手声,然后我拍一下手,它就能识别出拍手声的位置?[...] 地图上应该用不同于哔声的符号来表示拍手声。
what’s a good way for me to test this I wonder? Can we have it listen for claps, then I could clap and it could identify the location of the clap? [...]
Claps should use a different symbol on the map than beeps
这样就增加了一个功能:每当我拍手时,地图上就会用不同于哔声的符号显示出来。That added the thing where any time I clapped it would show on the map as a different symbol from the beeps.
地图上的每个符号都应包含 HH:MM:SS 时间戳。
each symbol on the map should include a HH:MM:SS timestamp
这让人更容易辨别哪些符号可能对应哪些现实中的声音。That made it easier to spot which symbol likely reflected which real-world sound.
日志应显示哔声和拍手声及其时间戳,并带有一个小播放按钮。点击后,按顺序重放每个监听器录制的声音片段(屏幕上应清楚标明每段片段是由哪个监听器录制的),同时在重放期间暂时关闭麦克风录音。
The log should show beeps and claps with their timestamps AND have a little play button which, when clicked, replays the recorded noise from each of the listeners in sequence (with clear text on screen showing which listener recorded which snippet) while temporarily turning off microphone recording while that replay plays
现在我可以重放声音了,这样更容易识别出哪个录制片段里有我一直在找的神秘哔声。Now I could replay sounds, making it much easier to identify which recorded clip was the mysterious beep I was looking for.
录音旁边应该有一个“这是那个神秘哔声”的按钮——这样我就可以点击重放听听,然后确认这是不是我要找的那个神秘哔声。之后,系统就能对未来的声音进行分类,判断它们是否很可能是同一个神秘哔声,并利用这些信息更准确地推断它的位置。
There should be a button next to a recording for “This is the mystery beep” - then I can hit replay to see and then confirm it was the mystery beep if that’s the one I am looking for
Then the system can categorize noises in the future to see if they are likely that same mysterious beep and use that information to build a more accurate idea of where it is
这时候我已经快要找到答案了——我基本确定哔声是从哪里传来的,但要是能把监听器重新布置到那个位置周围,从而更精确地定位,岂不是很棒?At this point I was getting close—I had a solid idea of where the beep was coming from, but wouldn’t it be neat if I could reposition the listeners around that point to get an even finer location?
我希望能有这样一个功能,不用每次都重启各个监听设备等。我希望可以点击“重新定位设备”按钮,进入重新定位模式;然后点击“已重新定位”,切换到粗略模式,让我大致标注它们的位置。完成后再点击确认,设备就会重新启动。之前的会话可以通过应用以只读方式查看。
I want a feature for this, I don’t want to have to restart each listening device etc, I want to be able to click a “Reposition the devices” button which lets me switch into repositioning, then I click “Repositioned” and it puts me into Rough mode and asks me to roughly locate them, then I do that and click, then it starts up again. The previous session can be read-only viewed through the app.
而且由于我有一台闲置设备,我接着说道:And since I had one spare device, I then said:
添加一项功能:根据目前收集到的数据,在地图上标出一个建议地点,提示在该处添加监听器可能会有用。
add a feature where the map includes a spot that is a suggestion for a location that it would be useful to add a listener at - based on data collected so far
给 Claude Code 配上耳朵Giving Claude Code ears
我认为这个项目最有意思的地方在于,我证明了让 Claude Code 拥有耳朵是可行的。I think the most interesting part of this project is that I demonstrated it’s possible to give Claude Code ears.
Claude 尚不支持原生音频输入,但可以运行 JavaScript 和 Python 代码来分析麦克风采集的音频。Claude doesn’t have native audio input (yet), but it can run JavaScript and Python code that can analyze audio captured by a microphone.
我让它运行一个带有 WebSocket 连接的 Web 服务器,以连接多个监听设备;接着又让它在这些设备上运行 WebAudio 麦克风,并将它们接入系统,以便通过该 WebSocket 向它们发送新的 JavaScript 代码来执行。I told it to run a web server with WebSocket connections to multiple listening devices, then had it both run a WebAudio microphone on those devices and hook them up so they could be sent fresh JavaScript code to execute via that WebSocket.
然后我基本上就可以不管 Claude,让它自己埋头解决问题、查询音频日志,并重新配置它的“耳朵”,帮助它解决问题。Then I could pretty much leave Claude alone, hacking away at the problem, querying the audio logs, and reconfiguring its ears to help it solve the problem.
这让我想起几周前在 GitHub Universe 上听到的一个类似的小技巧:Martin Woodward 告诉我,他一直在调试 GitHub Universe 徽章设备,方法是用 USB-C 把它们连接到一台电脑上,再把网络摄像头对准设备屏幕,这样他的编码代理就能判断更新是否正常运行。I’m reminded of a similar hack I heard about at GitHub Universe a few weeks ago, where Martin Woodward told me he had been debugging the GitHub Universe Badge computers by plugging them into a computer via USB-C and then pointing a webcam at their screen, so his coding agent could tell if updates were working correctly or not.
想办法让编程智能体感知周围的世界,真是乐趣无穷。Figuring out ways to let coding agents perceive the world around them is a whole lot of fun.