Skip to content

Commit 8645500

Browse files
committed
update:简化文档
1 parent 5006323 commit 8645500

File tree

1 file changed

+8
-194
lines changed

1 file changed

+8
-194
lines changed

README.md

Lines changed: 8 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,20 @@
22

33
基于3D-Speaker模型的声纹识别服务,提供声纹注册、识别、删除等功能。
44

5-
## 🚀 新版本特性
6-
7-
### 架构重构
8-
- **模块化设计**: 清晰的目录结构,便于维护和扩展
9-
- **高并发支持**: 使用gunicorn + gevent,支持高并发访问
10-
- **配置管理**: 统一的配置管理,支持环境变量和配置文件
11-
- **日志系统**: 完善的日志记录和监控
12-
- **错误处理**: 统一的异常处理和错误响应
13-
14-
### 性能优化
15-
- **连接池**: 数据库连接池,提高并发性能
16-
- **异步处理**: 支持异步音频处理
17-
- **内存管理**: 优化的内存使用和临时文件清理
18-
- **缓存策略**: 模型预加载,减少响应时间
19-
20-
## 📁 项目结构
21-
22-
```
23-
voiceprint-api/
24-
├── app/ # 应用主目录
25-
│ ├── main.py # FastAPI应用入口
26-
│ ├── core/ # 核心模块
27-
│ │ ├── config.py # 配置管理
28-
│ │ ├── security.py # 安全认证
29-
│ │ └── logging.py # 日志配置
30-
│ ├── api/ # API模块
31-
│ │ ├── v1/ # API v1版本
32-
│ │ │ ├── endpoints/ # API端点
33-
│ │ │ │ ├── voiceprint.py # 声纹相关API
34-
│ │ │ │ └── health.py # 健康检查API
35-
│ │ │ └── api.py # API路由
36-
│ │ └── dependencies.py # API依赖
37-
│ ├── models/ # 数据模型
38-
│ │ └── voiceprint.py # 声纹数据模型
39-
│ ├── services/ # 业务服务
40-
│ │ └── voiceprint_service.py # 声纹识别服务
41-
│ ├── database/ # 数据库模块
42-
│ │ ├── connection.py # 数据库连接
43-
│ │ └── voiceprint_db.py # 声纹数据库操作
44-
│ └── utils/ # 工具模块
45-
│ └── audio_utils.py # 音频处理工具
46-
├── data/ # 配置文件
47-
│ └── .voiceprint.yaml # 主配置文件
48-
├── tmp/ # 临时文件目录
49-
├── start_server.py # 生产环境启动脚本
50-
├── requirements.txt # Python依赖
51-
├── Dockerfile # Docker配置
52-
└── README.md # 项目文档
53-
```
5+
目前用于xiaozhi说话人识别,[xiaozhi-esp32-server](https://github.com/xinnan-tech/xiaozhi-esp32-server)
546

557
## 🛠️ 安装和配置
568

57-
### 1. 环境要求
58-
- Python 3.9+
59-
- MySQL 5.7+
60-
- 至少4GB内存(用于模型加载)
61-
62-
### 2. 安装依赖
9+
### 1. 安装依赖
6310
```bash
11+
conda remove -n voiceprint-api --all -y
12+
conda create -n voiceprint-api python=3.10 -y
13+
conda activate voiceprint-api
14+
6415
pip install -r requirements.txt
6516
```
6617

67-
### 3. 数据库配置
18+
### 2. 数据库配置
6819
创建MySQL数据库和表:
6920
```sql
7021
CREATE DATABASE voiceprint_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
@@ -104,144 +55,7 @@ python -m app.main
10455
python start_server.py
10556
```
10657

107-
### Docker部署
108-
```bash
109-
docker build -t voiceprint-api .
110-
docker run -d -p 8005:8005 --name voiceprint-api voiceprint-api
111-
```
112-
11358
## 📚 API文档
11459

11560
启动服务后,访问以下地址查看API文档:
116-
- Swagger UI: http://localhost:8005/docs
117-
- ReDoc: http://localhost:8005/redoc
118-
119-
### 主要API接口
120-
121-
#### 1. 声纹注册
122-
```http
123-
POST /api/v1/voiceprint/register
124-
Content-Type: multipart/form-data
125-
Authorization: Bearer <your_token>
126-
127-
speaker_id: user_001
128-
file: audio.wav
129-
```
130-
131-
#### 2. 声纹识别
132-
```http
133-
POST /api/v1/voiceprint/identify
134-
Content-Type: multipart/form-data
135-
Authorization: Bearer <your_token>
136-
137-
speaker_ids: user_001,user_002,user_003
138-
file: audio.wav
139-
```
140-
141-
#### 3. 删除声纹
142-
```http
143-
DELETE /api/v1/voiceprint/{speaker_id}
144-
Authorization: Bearer <your_token>
145-
```
146-
147-
#### 4. 获取所有说话人
148-
```http
149-
GET /api/v1/voiceprint/speakers
150-
Authorization: Bearer <your_token>
151-
```
152-
153-
#### 5. 健康检查
154-
```http
155-
GET /api/v1/health
156-
```
157-
158-
## 🔧 高并发配置
159-
160-
### 1. 系统级优化
161-
```bash
162-
# 增加文件描述符限制
163-
echo "* soft nofile 65536" >> /etc/security/limits.conf
164-
echo "* hard nofile 65536" >> /etc/security/limits.conf
165-
166-
# 增加网络连接数
167-
echo "net.core.somaxconn = 65535" >> /etc/sysctl.conf
168-
sysctl -p
169-
```
170-
171-
### 2. 数据库优化
172-
```sql
173-
-- 增加连接数
174-
SET GLOBAL max_connections = 1000;
175-
SET GLOBAL innodb_buffer_pool_size = 1073741824; -- 1GB
176-
```
177-
178-
### 3. 应用级优化
179-
- 使用连接池管理数据库连接
180-
- 异步处理音频文件
181-
- 合理的超时设置
182-
- 内存监控和清理
183-
184-
## 📊 监控和日志
185-
186-
### 日志文件
187-
- 应用日志: `voiceprint_api.log`
188-
- 访问日志: stdout
189-
- 错误日志: stderr
190-
191-
### 监控指标
192-
- 请求响应时间
193-
- 并发连接数
194-
- 内存使用情况
195-
- 数据库连接状态
196-
197-
## 🔒 安全特性
198-
199-
- API令牌认证
200-
- 文件类型验证
201-
- 音频文件大小限制
202-
- 临时文件自动清理
203-
- CORS配置
204-
205-
## 🐛 故障排除
206-
207-
### 常见问题
208-
209-
1. **模型加载失败**
210-
- 检查网络连接
211-
- 确保有足够的内存
212-
- 检查modelscope版本
213-
214-
2. **数据库连接失败**
215-
- 检查数据库配置
216-
- 确保数据库服务运行
217-
- 检查网络连接
218-
219-
3. **音频处理失败**
220-
- 检查音频文件格式
221-
- 确保音频文件完整
222-
- 检查磁盘空间
223-
224-
### 日志查看
225-
```bash
226-
# 查看应用日志
227-
tail -f voiceprint_api.log
228-
229-
# 查看Docker日志
230-
docker logs -f voiceprint-api
231-
```
232-
233-
## 🤝 贡献指南
234-
235-
1. Fork 项目
236-
2. 创建功能分支
237-
3. 提交更改
238-
4. 推送到分支
239-
5. 创建 Pull Request
240-
241-
## 📄 许可证
242-
243-
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
244-
245-
## 📞 联系方式
246-
247-
如有问题或建议,请提交 Issue 或联系开发团队。
61+
- Swagger UI: http://localhost:8005/voiceprint/docs

0 commit comments

Comments
 (0)