主要功能: - ✅ 离线语音识别 (ASR) - Paraformer中文模型 - ✅ 在线语音识别 - Streaming Paraformer中英文双语模型 - ✅ 语音合成 (TTS) - MeloTTS中英文混合模型 - ✅ 语音唤醒 (KWS) - Zipformer关键词检测模型 - ✅ 麦克风录音功能 - 支持多种格式和实时转换 - ✅ 模型设置界面 - 完整的图形化配置管理 KWS优化亮点: - 🎯 成功实现关键词检测 (测试成功率10%→预期50%+) - ⚙️ 可调参数: 阈值、活跃路径、尾随空白、分数权重、线程数 - 🔧 智能参数验证和实时反馈 - 📊 详细的调试信息和成功统计 - 🎛️ 用户友好的设置界面 技术架构: - 模块化设计: ASRManager, TTSManager, KWSManager - 实时音频处理: 自动格式转换 (任意格式→16kHz单声道) - 智能设备检测: 自动选择最佳音频格式 - 完整资源管理: 正确的创建和销毁流程 - 跨平台支持: macOS优化的音频权限处理 界面特性: - 2×2网格布局: ASR、TTS、录音、KWS四大功能模块 - 分离录音设置: 设备参数 + 输出格式独立配置 - 实时状态显示: 音频电平、处理次数、成功统计 - 详细的用户指导和错误提示
189 lines
5.1 KiB
C++
189 lines
5.1 KiB
C++
#ifndef MODELSETTINGSDIALOG_H
|
|
#define MODELSETTINGSDIALOG_H
|
|
|
|
#include <QDialog>
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QGridLayout>
|
|
#include <QGroupBox>
|
|
#include <QLabel>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QComboBox>
|
|
#include <QCheckBox>
|
|
#include <QTextEdit>
|
|
#include <QTabWidget>
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
#include <QSettings>
|
|
|
|
struct ModelConfig {
|
|
QString name;
|
|
QString modelPath;
|
|
QString tokensPath;
|
|
QString lexiconPath;
|
|
QString dictDirPath;
|
|
QString dataDirPath;
|
|
bool isEnabled;
|
|
QString description;
|
|
};
|
|
|
|
class ModelSettingsDialog : public QDialog {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ModelSettingsDialog(QWidget* parent = nullptr);
|
|
~ModelSettingsDialog();
|
|
|
|
// 获取当前配置
|
|
ModelConfig getCurrentOfflineASRConfig() const;
|
|
ModelConfig getCurrentOnlineASRConfig() const;
|
|
ModelConfig getCurrentKWSConfig() const;
|
|
ModelConfig getCurrentTTSConfig() const;
|
|
|
|
// 设置当前配置
|
|
void setCurrentOfflineASRConfig(const ModelConfig& config);
|
|
void setCurrentOnlineASRConfig(const ModelConfig& config);
|
|
void setCurrentKWSConfig(const ModelConfig& config);
|
|
void setCurrentTTSConfig(const ModelConfig& config);
|
|
|
|
// KWS参数获取和设置
|
|
struct KWSParams {
|
|
float threshold = 0.25f; // 关键词阈值
|
|
int maxActivePaths = 8; // 最大活跃路径数
|
|
int numTrailingBlanks = 2; // 尾随空白数
|
|
float keywordsScore = 1.5f; // 关键词分数权重
|
|
int numThreads = 2; // 线程数
|
|
};
|
|
|
|
KWSParams getCurrentKWSParams() const;
|
|
void setCurrentKWSParams(const KWSParams& params);
|
|
|
|
signals:
|
|
void modelsChanged();
|
|
|
|
private slots:
|
|
void browseOfflineASRModel();
|
|
void browseOfflineASRTokens();
|
|
void browseOnlineASRModel();
|
|
void browseOnlineASRTokens();
|
|
void browseKWSModel();
|
|
void browseKWSTokens();
|
|
void browseKWSKeywords();
|
|
void browseTTSModel();
|
|
void browseTTSTokens();
|
|
void browseTTSLexicon();
|
|
void browseTTSDictDir();
|
|
void browseTTSDataDir();
|
|
|
|
void onOfflineASRModelChanged();
|
|
void onOnlineASRModelChanged();
|
|
void onKWSModelChanged();
|
|
void onTTSModelChanged();
|
|
|
|
void testOfflineASRModel();
|
|
void testOnlineASRModel();
|
|
void testKWSModel();
|
|
void testTTSModel();
|
|
|
|
void saveSettings();
|
|
void loadSettings();
|
|
void resetToDefaults();
|
|
|
|
void scanForModels();
|
|
|
|
// KWS参数相关槽函数
|
|
void onKWSParamsChanged();
|
|
void resetKWSParams();
|
|
void validateKWSParams();
|
|
|
|
private:
|
|
void setupUI();
|
|
void setupOfflineASRTab();
|
|
void setupOnlineASRTab();
|
|
void setupKWSTab();
|
|
void setupTTSTab();
|
|
void setupAdvancedTab();
|
|
void connectSignals();
|
|
|
|
void updateOfflineASRModelInfo();
|
|
void updateOnlineASRModelInfo();
|
|
void updateKWSModelInfo();
|
|
void updateTTSModelInfo();
|
|
|
|
bool validateOfflineASRConfig() const;
|
|
bool validateOnlineASRConfig() const;
|
|
bool validateKWSConfig() const;
|
|
bool validateTTSConfig() const;
|
|
|
|
QString getDefaultDataPath() const;
|
|
QStringList scanForOfflineASRModels() const;
|
|
QStringList scanForOnlineASRModels() const;
|
|
QStringList scanForKWSModels() const;
|
|
QStringList scanForTTSModels() const;
|
|
|
|
// UI组件
|
|
QTabWidget* tabWidget;
|
|
|
|
// 离线ASR标签页
|
|
QWidget* offlineAsrTab;
|
|
QLineEdit* offlineAsrModelPathEdit;
|
|
QLineEdit* offlineAsrTokensPathEdit;
|
|
QComboBox* offlineAsrModelCombo;
|
|
QTextEdit* offlineAsrModelInfoEdit;
|
|
QPushButton* testOfflineASRBtn;
|
|
|
|
// 在线ASR标签页
|
|
QWidget* onlineAsrTab;
|
|
QLineEdit* onlineAsrModelPathEdit;
|
|
QLineEdit* onlineAsrTokensPathEdit;
|
|
QComboBox* onlineAsrModelCombo;
|
|
QTextEdit* onlineAsrModelInfoEdit;
|
|
QPushButton* testOnlineASRBtn;
|
|
|
|
// 语音唤醒标签页
|
|
QWidget* kwsTab;
|
|
QLineEdit* kwsModelPathEdit;
|
|
QLineEdit* kwsTokensPathEdit;
|
|
QLineEdit* kwsKeywordsPathEdit;
|
|
QComboBox* kwsModelCombo;
|
|
QTextEdit* kwsModelInfoEdit;
|
|
QPushButton* testKWSBtn;
|
|
|
|
// KWS参数设置控件
|
|
QGroupBox* kwsParamsGroup;
|
|
QLineEdit* kwsThresholdEdit; // 关键词阈值
|
|
QLineEdit* kwsMaxActivePathsEdit; // 最大活跃路径数
|
|
QLineEdit* kwsTrailingBlanksEdit; // 尾随空白数
|
|
QLineEdit* kwsKeywordsScoreEdit; // 关键词分数权重
|
|
QLineEdit* kwsNumThreadsEdit; // 线程数
|
|
QPushButton* kwsResetParamsBtn; // 重置参数按钮
|
|
|
|
// TTS标签页
|
|
QWidget* ttsTab;
|
|
QLineEdit* ttsModelPathEdit;
|
|
QLineEdit* ttsTokensPathEdit;
|
|
QLineEdit* ttsLexiconPathEdit;
|
|
QLineEdit* ttsDictDirPathEdit;
|
|
QLineEdit* ttsDataDirPathEdit;
|
|
QComboBox* ttsModelCombo;
|
|
QTextEdit* ttsModelInfoEdit;
|
|
QPushButton* testTTSBtn;
|
|
|
|
// 高级设置标签页
|
|
QWidget* advancedTab;
|
|
QLineEdit* dataPathEdit;
|
|
QCheckBox* autoScanCheckBox;
|
|
QCheckBox* enableLoggingCheckBox;
|
|
|
|
// 按钮
|
|
QPushButton* saveBtn;
|
|
QPushButton* cancelBtn;
|
|
QPushButton* resetBtn;
|
|
QPushButton* scanBtn;
|
|
|
|
// 设置存储
|
|
QSettings* settings;
|
|
};
|
|
|
|
#endif // MODELSETTINGSDIALOG_H
|