feat: 完整的语音助手系统实现
主要功能: - ✅ 离线语音识别 (ASR) - Paraformer中文模型 - ✅ 在线语音识别 - Streaming Paraformer中英文双语模型 - ✅ 语音合成 (TTS) - MeloTTS中英文混合模型 - ✅ 语音唤醒 (KWS) - Zipformer关键词检测模型 - ✅ 麦克风录音功能 - 支持多种格式和实时转换 - ✅ 模型设置界面 - 完整的图形化配置管理 KWS优化亮点: - 🎯 成功实现关键词检测 (测试成功率10%→预期50%+) - ⚙️ 可调参数: 阈值、活跃路径、尾随空白、分数权重、线程数 - 🔧 智能参数验证和实时反馈 - 📊 详细的调试信息和成功统计 - 🎛️ 用户友好的设置界面 技术架构: - 模块化设计: ASRManager, TTSManager, KWSManager - 实时音频处理: 自动格式转换 (任意格式→16kHz单声道) - 智能设备检测: 自动选择最佳音频格式 - 完整资源管理: 正确的创建和销毁流程 - 跨平台支持: macOS优化的音频权限处理 界面特性: - 2×2网格布局: ASR、TTS、录音、KWS四大功能模块 - 分离录音设置: 设备参数 + 输出格式独立配置 - 实时状态显示: 音频电平、处理次数、成功统计 - 详细的用户指导和错误提示
This commit is contained in:
51
ASRManager.h
Normal file
51
ASRManager.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef ASRMANAGER_H
|
||||
#define ASRMANAGER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <string>
|
||||
#include "sherpa-onnx/c-api/c-api.h"
|
||||
|
||||
class ASRManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ASRManager(QObject* parent = nullptr);
|
||||
~ASRManager();
|
||||
|
||||
bool initialize();
|
||||
QString recognizeWavFile(const QString& filePath);
|
||||
bool isInitialized() const { return asrRecognizer != nullptr; }
|
||||
|
||||
// 在线识别相关
|
||||
bool initializeOnlineRecognizer();
|
||||
bool isOnlineInitialized() const { return onlineAsrRecognizer != nullptr; }
|
||||
const SherpaOnnxOnlineStream* createOnlineStream();
|
||||
void destroyOnlineStream(const SherpaOnnxOnlineStream* stream);
|
||||
|
||||
// 在线识别处理
|
||||
void acceptWaveform(const SherpaOnnxOnlineStream* stream, const float* samples, int32_t sampleCount);
|
||||
bool isStreamReady(const SherpaOnnxOnlineStream* stream);
|
||||
void decodeStream(const SherpaOnnxOnlineStream* stream);
|
||||
QString getStreamResult(const SherpaOnnxOnlineStream* stream);
|
||||
void inputFinished(const SherpaOnnxOnlineStream* stream);
|
||||
bool isEndpoint(const SherpaOnnxOnlineStream* stream);
|
||||
|
||||
private:
|
||||
void cleanup();
|
||||
|
||||
// 离线ASR相关
|
||||
SherpaOnnxOfflineRecognizer* asrRecognizer = nullptr;
|
||||
SherpaOnnxOfflineRecognizerConfig asrConfig;
|
||||
std::string asrModelPathStd;
|
||||
std::string asrTokensPathStd;
|
||||
|
||||
// 在线ASR相关
|
||||
SherpaOnnxOnlineRecognizer* onlineAsrRecognizer = nullptr;
|
||||
SherpaOnnxOnlineRecognizerConfig onlineAsrConfig;
|
||||
std::string onlineEncoderPathStd;
|
||||
std::string onlineDecoderPathStd;
|
||||
std::string onlineTokensPathStd;
|
||||
};
|
||||
|
||||
#endif // ASRMANAGER_H
|
||||
Reference in New Issue
Block a user