xiaozhi-esp32-server/core/utils/asr.py
whoyao 14b8adf964
添加豆包在线 ASR (#82)
* 添加 长期记忆功能

* fix bugs

* add memory parm for config.yaml

* fix is_segment for tts

* 推送主分支测试

* 🎈 perf: 美化log

* 🐞 fix: bug

改用opus_next,增加文档

* 合并main到develop (#75)

* fix: 多种docker build 编译方式

* fix:push

* 优化打包速度 (#65)

* 🐳 chore: 优化打包速度

使用国内镜像

* 🎈 perf: 优化打包速度

注释日志的时间信息

* 合并多个更新 (#68)

* 🐳 chore: 优化打包速度

使用国内镜像

* 🎈 perf: 优化打包速度

注释日志的时间信息

* 🐳 chore: 改用docker hub

* 🐎 ci(ci): 自动打包docker

* 🐳 chore: 更新文档

* 🎈 perf: 改用opuslib_next

* 🌈 style: 统一log

* minimax语音tts和阿里云智能语音tts适配

* 本地模型不重复创建,共用一个 (#51)

* 本地模型不重复创建,共用一个

* 更新web端页面发布版本

* 🎈 perf: 优化开发体验 (#70)

添加内置模型下载,yarn

---------

Co-authored-by: TOM88812 <ttangxs0808@163.com>
Co-authored-by: HonestQiao <honestqiao@163.com>
Co-authored-by: 玄凤科技 <128943504+Eric0308@users.noreply.github.com>
Co-authored-by: 欣南科技 <huangrongzhuang@xin-nan.com>
Co-authored-by: Huang <32005838+openrz@users.noreply.github.com>

* feat: support doubao online ASR

* feat: support doubao online ASR

---------

Co-authored-by: fofo <zhongpei@vip.qq.com>
Co-authored-by: hrz <1710360675@qq.com>
Co-authored-by: 玄凤科技 <128943504+Eric0308@users.noreply.github.com>
Co-authored-by: kalicyh <34980061+kalicyh@users.noreply.github.com>
Co-authored-by: TOM88812 <ttangxs0808@163.com>
Co-authored-by: HonestQiao <honestqiao@163.com>
Co-authored-by: 欣南科技 <huangrongzhuang@xin-nan.com>
Co-authored-by: Huang <32005838+openrz@users.noreply.github.com>
Co-authored-by: 胡垚 <qsct9501@163.com>
2025-02-21 10:05:58 +08:00

24 lines
No EOL
839 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import importlib
import logging
import os
import sys
import time
import wave
import uuid
from abc import ABC, abstractmethod
from typing import Optional, Tuple, List
from core.providers.asr.base import ASRProviderBase
from config.logger import setup_logging
TAG = __name__
logger = setup_logging()
def create_instance(class_name: str, *args, **kwargs) -> ASRProviderBase:
"""工厂方法创建ASR实例"""
if os.path.exists(os.path.join('core', 'providers', 'asr', f'{class_name}.py')):
lib_name = f'core.providers.asr.{class_name}'
if lib_name not in sys.modules:
sys.modules[lib_name] = importlib.import_module(f'{lib_name}')
return sys.modules[lib_name].ASRProvider(*args, **kwargs)
raise ValueError(f"不支持的ASR类型: {class_name},请检查该配置的type是否设置正确")