iPhone音声入力 × PCクリップボード連携 構築完全マニュアル
iPhoneでどんなに喋っても、PC側のサーバー(受信機)が立ち上がっていなければ、文字は1文字も届きません。
電源の入っていない電話に話しかけているのと同じ状態になってしまいます。
PCをサーバーとして動かすためのエンジン「Node.js」をインストールします。
winget install OpenJS.NodeJS.LTS
brew install node
※コマンドが動かない場合は、Node.js公式サイトからLTS版をダウンロードしてください。
iPhoneに「どこのPCへ送ればいいか」を教えるための住所を調べます。
ipconfig
表示された項目の中から IPv4 アドレス (192.168.x.x など) をメモしてください。
ifconfig | grep "inet "
トラブルを避けるため、Cドライブ直下に専用の場所を作ります。
mkdir C:\AI-Voice-Studio
cd C:\AI-Voice-Studio
npm init -y
npm install express
以下のコードをすべてコピーし、フォルダ内に server.js という名前で保存します。
import express from 'express';
import { exec } from 'child_process';
const app = express();
const port = 5000;
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.post('/copy', (req, res) => {
const text = req.body.text;
if (text) {
const cleanText = text.trim();
// Base64変換により、あらゆる日本語を文字化けさせずにクリップボードへ
const base64Text = Buffer.from(cleanText).toString('base64');
const command = `powershell -NoProfile -Command "Set-Clipboard -Value ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64Text}')))"`;
exec(command, (error) => {
if (error) console.error('Error:', error);
else console.log(`[Success] Received: ${cleanText}`);
});
res.status(200).send('OK');
} else {
res.status(400).send('No text found');
}
});
app.listen(port, '0.0.0.0', () => {
console.log('AI Voice Server is Running on port 5000...');
});
アイコンから一撃でサーバーを立ち上げる設定です。
@echo off
chcp 65001 > nul
cd /d "C:\AI-Voice-Studio"
node server.js
start_server.bat のショートカットをデスクトップに作成。explorer "C:\AI-Voice-Studio\start_server.bat"
iPhoneの「ショートカット」アプリで、以下の設定を1つずつ丁寧に行います。
http://[ステップ02のIP]:5000/copy仕上げです。どんなマウスでも、「ショートカットキー」を割り当てる機能があればOKです。
お疲れ様でした。これであなたのiPhoneは、PCのキーボードを凌駕する最強の入力デバイスに進化しました。