# ahhs-traine **Repository Path**: subpu/ahhs-traine ## Basic Information - **Project Name**: ahhs-traine - **Description**: 基于HuggingFace的语音推理服务API. 支持: 文本翻译, 文生音频, 语音识别, 流式ASR/TTS - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-11-26 - **Last Updated**: 2025-04-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ahhs-traine #### 介绍 语音应用推理服务API. 包含: 翻译(NLP), 文本到语音(TTS), 语音识别(ASR), 流式语音互动(WebSocket + ASR/NLP/TTS) #### 软件架构 FastApi + HuggingFace的语音应用推理服务. 环境需求: Python 3.10, CUDA 12.1, FFmpeg 6.1.x #### 安装教程 1. 下载FFmpeg 6.1. 并将解压后的目录设置到环境变量中. 2. 检查nvidia CUDA版本. `nvidia-smi`. 例如: 12.x 或 11.x 3. 克隆项目. 在激活env后安装相关的依赖 3.1 根据CUDA的版本安装: pytorch 3.1.1: 12.x `pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121` 3.1.2: 11.4+ `pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113` 3.2 项目依赖 3.2.1 12.x `pip install -r requirements.txt` 3.2.2 11.4+ `pip install -r requirements.cuda11.txt` #### 使用说明 1. 项目配置文件: `.env`. 日志配置: `config/logging.yaml`. 日志目录需要手动创建, 默认为:logs; 在windows系统中的位置为项目所在盘符下, 项目放在c盘就在c盘下创建, 在d盘就在d盘下创建 2. 附件存储支持:本地文件, MinIo对象 3. 启动方式: `python main.py` 或者: `fastapi run` 或者: `uvicorn main:app` 4. 模型下载: 无法科学上网时需要在系统环境变量中增加: `HF_ENDPOINT` 值: `https://hf-mirror.com` 5. 模型加载: 系统启动时可以指定预加载的模型名称, 命令参数为: --nlp 翻译模型,支持: nllb, m2m100. 默认: `nllb` --tts 文本生成语音模型, 支持: mms --asr 语音识别模型, 支持: faster-whisper 6. 示例位于examples文件中. `rest.py` 为连接服务API的客户端相关代码; `tts.py` 为流式文生音频的示例; `asr.py` 为流式语音识别的示例 7. 启动时报aioredis异常: `duplicate base class TimeoutError`, 请参考: [关于AioRedis导入报错duplicate base class TimeoutError](https://blog.csdn.net/ViniJack/article/details/131809573) 8. 下载faster-whisper时若系统为windows会提示: `OSError: Windows requires Developer Mode to be activated, or to run Python`. 关于如何开启开发者模式,请参考: [How to Enable Developer Mode in Windows 11/10](https://www.itechtics.com/enable-developer-mode/)