# 🎉 LiveKit Voice AI - 启动成功

## ✅ 所有服务就绪

| 组件 | 状态 | 端口 |
|------|------|------|
| LiveKit Server | ✅ | localhost:7880 |
| FunASR STT | ✅ | localhost:8080 |
| Agnes AI LLM | ✅ | api.agnes-ai.cn |
| Edge TTS | ✅ | zh-CN-XiaoxiaoNeural |
| Voice AI Agent | ✅ 已注册 | Worker: AW_q969... |

## 🔑 Token 信息

```bash
python3 gen_token.py
```

输出:
```
Room: voice-ai-test
Identity: user1
Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
```

## 📱 React Native 测试步骤

### 1. 获取 Mac IP
```bash
ipconfig getifaddr en0
# 输出: 192.168.31.xxx
```

### 2. 配置 App.js
编辑 `react-native-example/App.js`:
```javascript
const SERVER_URL = 'ws://YOUR_MAC_IP:7880';  // 替换为上面输出
const TOKEN = '从 gen_token.py 获取的 token';
```

### 3. 创建 React Native 项目
```bash
npx react-native init VoiceAI
cd VoiceAI
npm install livekit-client
```

### 4. iOS HTTP 配置
编辑 `ios/VoiceAI/Info.plist`:
```xml
<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
```

### 5. 复制代码
将 `react-native-example/App.js` 内容复制到 `App.js`

### 6. 运行
```bash
npx react-native run-ios
```

## 🚀 完整测试流程

```bash
# 终端 1: 启动 Agent
source ~/s2s-env/bin/activate
cd /Users/leo/.hermes/workspace/livekit-agents
python3 agent_server.py start

# 终端 2: 生成 Token
python3 gen_token.py

# 终端 3: 运行 React Native
npx react-native run-ios
```

## 📊 测试结果

```
✅ STT: 识别成功
✅ LLM: "你好！我是 Agnes，由 Sapiens"
✅ TTS: 15984 bytes (1.0秒音频)
```

## 🐛 故障排查

| 问题 | 检查 |
|------|------|
| Token invalid | 检查 API_KEY/SECRET 是否匹配 |
| Connection refused | 确认 Mac IP 正确，防火墙开放 7880 |
| Audio not working | 检查麦克风权限 |
| No response | 查看 Agent 日志 |

## 📁 文件位置

- Agent Worker: `agent.py`
- 启动脚本: `agent_server.py`
- Token 生成: `gen_token.py`
- RN 示例: `react-native-example/App.js`
