# smart-speaker **Repository Path**: another-road/smart-speaker ## Basic Information - **Project Name**: smart-speaker - **Description**: 于开源全栈方案的个人智能音箱实现 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-02-28 - **Last Updated**: 2026-03-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 智能音箱系统 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/) 基于开源全栈方案的个人智能音箱实现,完全跨平台支持! ## 核心功能 - **语音识别**: Vosk (离线,多语言支持) - **AI助手**: 阿里云百炼 (通义千问) - **文本转语音**: Edge-TTS + pyttsx3 (双引擎支持) - **唤醒词检测**: Vosk (支持中文唤醒词) - **噪声过滤**: 带通滤波器 + 自动增益控制 - **跨平台**: Windows/Linux/macOS 全支持 ## 系统要求 ### 通用要求 - Python 3.8+ - 4GB+ 内存 (推荐8GB+) - 麦克风和音响设备 ### Windows 特定要求 - Windows 10/11 (64位) - Visual C++ Redistributable - PowerShell 5.1+ ### Linux 特定要求 - Ubuntu/Debian/CentOS 等 - ALSA/PulseAudio 音频系统 - gcc 编译器 (可选) ## 快速开始 ### 1. 克隆项目 ```bash git clone https://github.com/your-username/smart-speaker.git cd smart-speaker ``` ### 2. 创建虚拟环境 ```bash python -m venv venv source venv/bin/activate # Linux/macOS .\venv\Scripts\activate # Windows ``` ### 3. 安装依赖 ```bash pip install -r requirements.txt ``` ### 4. 下载 Vosk 模型 ```bash # 下载中文模型 (约 1.3GB) wget https://alphacephei.com/vosk/models/vosk-model-cn-0.22.zip unzip vosk-model-cn-0.22.zip -d models/ mv models/vosk-model-cn-0.22 models/vosk-model-cn-0.22 ``` ### 5. 配置 ```bash cp config.example.json config.json # 编辑 config.json 填入你的 API 密钥(可选) ``` ### 6. 启动 ```bash python main.py ``` ## 配置选项 配置文件: `config.json` (复制 `config.example.json`) ```json { "wake_word": { "keywords": ["老王", "你好小助手"] }, "speech_recognition": { "engine": "vosk", "model_path": "./models/vosk-model-cn-0.22", "whisper": { "enabled": false, "model_name": "base", "device": "cpu", "language": "zh" } }, "tts": { "engine": "edge", "voice": "zh-CN-XiaoxiaoNeural" }, "bailian": { "enabled": true, "api_key": "YOUR_API_KEY" } } ``` ### 语音识别 使用 Vosk 进行离线语音识别: - 优点:轻量级、快速、完全离线 - 缺点:准确度中等 - 适合:实时应用、低配置设备 ### 唤醒词检测 使用 Vosk 进行唤醒词检测: - 优点:快速、低延迟 - 缺点:准确度中等 - 适合:需要快速响应的场景 **支持的唤醒词**: 小度、小王、小爱、小李子等 **自定义唤醒词**: 在 `config.json` 中修改: ```json { "wake_word": { "keywords": ["小度", "你好"] } } ``` ## 安全提示 **重要**: 请勿将包含真实 API 密钥的 `config.json` 提交到版本控制! - 使用 `config.example.json` 作为模板 - 真实的 `config.json` 已被 `.gitignore` 排除 - 生产环境建议使用环境变量存储敏感信息 ## 跨平台特性 ### 音频处理 - **Windows**: DirectSound + WASAPI - **Linux**: ALSA + PulseAudio - **macOS**: Core Audio ### 文件路径 - 自动检测操作系统 - 统一使用 `pathlib.Path` 处理路径 ## 目录结构 ``` smart-speaker/ ├── main.py # 主程序入口 ├── config.example.json # 配置模板 ├── config.json # 配置文件(gitignore) ├── voice_recognition.py # 语音识别模块(Vosk) ├── tts.py # 文本转语音模块 ├── wake_word_vosk.py # 唤醒词检测模块 ├── audio_noise_filter.py # 音频噪声过滤模块 ├── bailian_client.py # 阿里云百炼客户端 ├── conversation_manager.py # 对话管理器 ├── models/ # AI模型目录 ├── requirements.txt # Python依赖 ├── LICENSE # MIT许可证 └── README.md # 本文件 ``` ## 贡献指南 欢迎提交 Issue 和 Pull Request! 1. Fork 本仓库 2. 创建特性分支 (`git checkout -b feature/AmazingFeature`) 3. 提交更改 (`git commit -m 'Add some AmazingFeature'`) 4. 推送到分支 (`git push origin feature/AmazingFeature`) 5. 创建 Pull Request ## 许可证 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件 ## 致谢 - [Vosk](https://alphacephei.com/vosk/) - 离线语音识别 - [Edge-TTS](https://github.com/rany2/edge-tts) - 微软 Edge 语音合成 - [PyAudio](https://people.csail.mit.edu/hubert/pyaudio/) - 音频 I/O