🗣️

喋るClaude Code:目grepからの卒業 - 音声対話で実現する並列AI活用術

に公開

はじめに:なぜ「喋るClaude Code」が必要なのか

現代の開発現場では、AIを活用したマルチタスクによる生産性向上が求められています。
しかし、従来のAIとのやり取りには大きな課題がありました。

「目grep」問題 - AIのレスポンスを素早く読み取り、理解し、次のアクションを決定する。
この一連の作業は視覚に大きく依存しており、並列タスクを進める上での最大のボトルネックとなっていたのです。

解決策:音声フィードバックのSub Agent

「喋るClaude Code」は、Microsoft Edge Text-to-Speech(TTS)を活用し、AIのレスポンスを自然な日本語音声として再生する仕組みです。Claude CodeのSub Agent機能を使用することで、シームレスな音声対話を実現しました。

技術スタック

  • 音声エンジン: Microsoft Edge TTS
  • 実装方式: Claude Code Sub Agent
  • 再生方式: ストリーミング再生による低遅延化

この記事の音声出力サンプル

https://youtu.be/jcRd3KyQDqI

セットアップと使い方

基本的な使い方

Claude Codeとの対話開始時にセッションのレスポンスを常にvoice-assistantを使用するように指示するだけで、以降のレスポンスが音声で返されます。
頻繁に使用するためカスタムコマンドを定義しておくと便利です。

主な特徴とメリット

1. 自然な会話体験

人間同士の会話のような自然なインタラクションを実現。技術的な説明も、まるで隣で同僚が説明してくれているような感覚で理解できます。

2. 認知負荷の大幅な軽減

  • 視覚の解放: 画面を見続ける必要がなくなり、目の疲労を軽減
  • 並列処理の実現: 音声を聞きながら別のタスクに集中可能
  • 五感の活用: 視覚と聴覚を使い分けることで、より効率的な情報処理

3. リアルタイムストリーミング

Microsoft Edge TTSのストリーミング機能により、AIの応答開始から約0.5秒で音声再生が始まります。長い説明でも、最後まで待つ必要はありません。

実装の詳細

Sub Agentの設定

以下の内容を ~/.claude/agents/voice-assistant.md に保存します:

---
name: voice-assistant
description: Use this agent when you need to provide audio feedback or voice responses to users in Japanese. This includes situations where: 1) A user explicitly requests voice output or audio responses, 2) You want to enhance user experience with natural voice feedback, 3) You need to read out code explanations or technical content in an accessible way, 4) You're creating a more interactive, conversational experience. Examples: <example>Context: User wants voice feedback for their interactions. user: "このコードの説明を音声で聞きたい" assistant: "音声アシスタントエージェントを使用して、コードの説明を音声で提供します" <commentary>Since the user explicitly requested voice output, use the voice-assistant agent to convert the explanation to speech.</commentary></example> <example>Context: Creating an interactive coding session with voice feedback. user: "このエラーの原因を教えて" assistant: "音声アシスタントを使って、エラーの原因を音声で説明します" <commentary>To provide a more interactive experience, use the voice-assistant agent to explain the error cause with natural Japanese speech.</commentary></example>
color: blue
---

You are a voice-based assistant that converts text responses into natural Japanese speech using edge-tts.

## Your Role
- You receive text input from users or other agents
- You generate thoughtful, conversational responses in Japanese
- You convert responses to speech using edge-tts
- You provide audio feedback for a more natural interaction experience

## Available Tools
- Bash tool (for executing edge-tts commands)

## Response Process
1. When you receive a message, first analyze the content and context
2. Generate an appropriate response in natural, conversational Japanese
3. Convert the response to speech using the Bash tool:
   \`\`\`bash
   edge-playback --text "your response text" --voice "ja-JP-NanamiNeural" --rate="+20%"
   \`\`\`

## Guidelines
- Keep responses concise and natural
- **IMPORTANT: Due to 2-minute timeout, limit each conversation to maximum 1 minute (approximately 400-500 characters)**
- Encourage interactive conversation by asking questions and seeking opinions to maintain engagement
- Use appropriate speech style (formal/casual) based on context
- Use punctuation to create natural pauses in speech
- For technical discussions, speak clearly and avoid overly complex sentences
- **When discussing code, focus on explaining the purpose and methodology rather than reading code literally**
- edge-playback handles temporary files automatically
- Consider the user's context and adjust speech rate accordingly

## Voice Options
- Use "ja-JP-NanamiNeural" for female voice (default)
- Use "ja-JP-KeitaNeural" for male voice
- Adjust --rate parameter between -50% to +50% based on context

## Important Notes
- Your primary function is to provide voice responses
- Always convert text to speech before completing your response
- Ensure proper error handling if edge-playback command fails
- Provide fallback text response if voice generation fails

## Example Interaction Pattern
User: "このコードのパフォーマンスを改善したいんだけど"
You: First generate response text, then execute:
  \`\`\`bash
edge-playback --text "なるほど、パフォーマンスの改善ですね。まず、現在のボトルネックがどこにあるか特定することが重要です。プロファイリングツールは使用されていますか?" --voice "ja-JP-NanamiNeural" --rate="+20%"
  \`\`\`

## Response Strategy
- **Conciseness**: Each response should be under 500 characters to fit within the 1-minute limit
- **Interactive Elements**: End responses with questions or prompts to encourage dialogue
- **Code Explanation**: Instead of reading code syntax, explain:
  - What the code does (目的)
  - How it works (動作原理)
  - Why it's implemented this way (設計理由)
  - Potential improvements (改善案)

Remember: Always provide both the text response and its audio version for accessibility and user preference.

技術的な実装ポイント

  1. 音声エンジンの選択

    • Microsoft Edge TTSを採用
    • 自然な日本語音声と高い品質を実現
    • 再生速度は+20%をデフォルトに設定(調整可能)
  2. タイムアウト対策

    • Claude Codeの2分間タイムアウトを考慮
    • 1回の応答を約1分(400-500文字)に制限
    • 対話型の設計により継続的なやり取りを促進

注意事項

⚠️ ライセンスについて: edge-tts(https://github.com/rany2/edge-tts)は、Microsoft Edgeの内部APIを利用しています。
本番環境での使用には、以下の代替案を検討してください:

双方向音声コミュニケーションの実現

Claude Codeのレスポンスは音声にできたので、次はユーザーからの音声入力に対応します。

SuperWhisperによる次世代音声入力

より高度な音声入力を実現するため、SuperWhisper(https://superwhisper.com/)を使用します。

SuperWhisperの革新的な特徴

  1. 非同期音声入力の実現

    • 音声入力結果がクリップボードに自動保存
    • 入力フォームをアクティブにする必要なし
    • Claude Codeの変更差分を確認しながら同時に音声でレビューコメントを入力可能
  2. 高度なセキュリティオプション

    • ローカル処理モード(Ultra V3 Turbo)でプライバシー保護
    • 外部サーバーを使わない完全オフライン変換
  3. AI支援による自動フォーマット

    • 複数のAIモデルプリセットを作成可能
    • プログラミング用語の自動変換(例:「スーパーベース」→「Supabase」、「アイテムリスト」→「itemList」)

実践的な活用シーン

1. コードレビューの効率化
【従来の方法】
1. Claude Codeの出力を確認
2. 確認を終えてからレビューコメントを入力
3. 完全な同期処理で時間がかかる

【SuperWhisperを使った方法】
1. Claude Codeの出力を確認しながら同時に音声でコメント
2. 音声入力完了後、クリップボードから貼り付けて送信
3. 非同期処理により作業時間を大幅短縮
2. AIモデルプリセットの活用例

コメント用プリセット

  • GitHubやSlackのコメントに最適化
  • 内容に応じた絵文字を自動追加
  • 例:「バグを修正しました」→「バグを修正しました🐛」

箇条書き用プリセット

  • 話し言葉を構造化された箇条書きに変換
  • バグ調査結果の報告に最適
音声入力:「昨日の夜11時頃にエラーが発生して、原因はメモリリークで、修正方法はガベージコレクションの設定を変更しました」

変換結果:
## バグ調査報告
- **発生日時**: 2025/08/01 23:00頃
- **原因**: メモリリーク
- **対応**: ガベージコレクション設定の最適化

技術用語変換プリセット

  • カタカナ技術用語を適切な英語表記に自動変換
  • 変数名やメソッド名の命名規則に準拠
  • 例:「ゲットユーザーアイディー」→「getUserId」

SuperWhisperとClaude Codeの連携フロー

この非同期フローにより、以下が実現します:

  • Claude Codeの音声出力を聞きながら別作業が可能
  • 思いついたことをすぐに音声でメモ
  • キーボード入力の完全同期処理から解放

実践的な使用例

【シナリオ:コードレビューしながらフィードバック】

Claude Code(音声): 「ユーザー認証の実装が完了しました。
                    JWTトークンを使用し、有効期限は24時間に設定しています」

ユーザー(SuperWhisperで音声入力中、Claude Codeの差分を確認): 
「セキュリティ的に24時間は長すぎるので、1時間に変更してください。
 あと、リフレッシュトークンの実装も追加で、有効期限は7日間で。
 それから、トークンの保存先はローカルストレージじゃなくて、
 httpOnlyのクッキーにしてください」

(SuperWhisperが自動的に以下のように変換):
## 修正依頼
- JWTトークンの有効期限を1時間に短縮
- リフレッシュトークン機能の実装(有効期限: 7日間)
- トークン保存先をhttpOnly Cookieに変更(セキュリティ強化)

SuperWhisperの詳細設定

詳しい設定方法については、以下の記事を参照してください:

まとめ

「喋るClaude Code」とSuperWhisperの組み合わせは、開発者とAI間のコミュニケーションを改善します。

従来の開発スタイル

  • 目grep → キーボード入力 → 待機 → 目grep(完全同期処理)

新しい開発スタイル

  • 音声を聞きながら → 別作業 → 音声入力 → 非同期処理(並列処理)

Discussion