The Need
I watch English videos on my phone with TransLee. The phone speaker plays the video. The microphone listens. Korean text appears on the screen.
That works, but I have to keep looking at the screen. I wanted to hear the Korean in my earphones instead, with my eyes on the video.
The obvious fix does not work on one phone. If the phone plays the translated voice, the microphone hears it again and the translation starts to loop. Echo cancellation would also remove the video sound I want to translate. I had already hit this problem in July. The only clean answer I found was to split the two jobs.
The Proof
Phone A plays the video and does the translating. Phone B only receives and plays.
I opened one page on phone B, typed a short code, and tapped one button. Korean voice came out of the Bluetooth earphones about one to two seconds after the English was spoken. The English from phone A’s speaker did not get into the earphones at all.
My first try was choppy. After one fix it sounded smooth, and I said so at the time (“it plays smoothly now”). So far I have used it at my desk with one phone pair. Next I want to try it on a long video and outside the house.
The Story
The idea came from a chat answer I pasted in. It suggested a “two-phone mirror”: phone A sends the translated text to phone B, and phone B reads it with the browser’s text-to-speech. I liked that, and I added one more thing to my request. A cheap, low-spec device should be able to be phone B one day.
While reading my own code, I found a shortcut. Gemini already sends Korean voice back, even in speaker mode. My app was throwing it away, because playing it on phone A causes the loop above. So phone A can pass that voice to phone B as it is. Nobody needs a text-to-speech engine for the default mode. I kept text-to-speech as a second choice on phone B.
I have no cost number to give for the translation itself. I did not buy anything for this change, and the relay runs on the NAS I already own, so the extra cost I can point to is $0. The Gemini usage is the same as before, and I still don’t have a clean monthly figure for it.
The How
1. A small relay on the NAS. Two browsers cannot talk to each other directly, so I added a Node.js container with the ws package. A room code pairs the sender and the receiver. The server forwards messages and stores nothing.
// phone A (role=tx) -> every phone B (role=rx) in the same room
ws.on('message', (data, isBinary) => {
for (const r of room.rx) {
if (r.readyState === WebSocket.OPEN) r.send(data, { binary: isBinary });
}
});
nginx forwards one path to it, so the same Cloudflare Tunnel is used and no port is opened:
location /relay {
proxy_pass http://relay:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
}
2. Phone A forwards what it already receives. I added three small hooks in the existing code: the voice chunks, the translated text pieces, and the end of a sentence. The Live session and translation settings are untouched. The voice goes out as raw 24 kHz PCM, and the text goes out as small JSON messages. I kept this format simple on purpose, so a tiny device could read it later.
3. Phone B is just a web page. There is nothing to install. It plays the PCM chunks with the Web Audio API. It also asks the browser to keep the screen on and loops a silent sound, so Android is less likely to stop the audio. I made a short address for it, and the room code is something I choose myself, such as four to twelve letters and numbers.
4. The two problems I hit.
- Bad Gateway. The relay container kept restarting with a “cannot open /app/server.js” error. Files I copy to the NAS over SMB end up with permissions the container’s normal user cannot read. I had this exact problem with the tunnel container before. Running
chmod 644inside the Dockerfile fixed it. Also, my NAS login needssudoto talk to Docker. - Choppy sound. My first version played each chunk almost immediately. Network chunks do not arrive evenly, so every late chunk made a gap. Now phone B waits 0.4 seconds first. If sound still runs dry, it raises that wait by 0.15 seconds each time, up to 1.5 seconds, and shows a counter.
🗂 Claude.md Rule A container that runs as a non-root user cannot read files copied over SMB. Add
RUN chmod 644for the files in the Dockerfile. On this NAS, usesudo docker compose.
💬 Prompt that worked “Right now I have to read the translation as text on the screen, but I want to listen to it with earphones. Please implement this, using the following content as a reference.”
I pasted the chat answer under that prompt. It had the two-phone idea and a rough code sketch, and the plan came from comparing it with my code.
What I want to improve next.
- Phone A must keep its screen on. Android stops the microphone when the screen turns off or another app covers TransLee. I added a screen wake lock, but it cannot stop a power-button press. For now I use a split-screen window with the video. I want to find a way to keep phone A working with the screen off.
- The pasted answer suggested an ESP32-S3 board as a tiny receiver. As far as I can tell, that chip has no Bluetooth Classic, which earphones normally need, so a board like this would need a different way to reach earphones. I want to try a small board later. For now a cheap used Android phone is the realistic phone B.