-- 2026-06-14
-- Add Tencent realtime ASR bridge configuration for mod_tx_asr.

DELETE FROM `sys_config`
WHERE `config_key` = 'config_asr_provider_tx';

INSERT INTO `sys_config` (`config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`, `remark`)
VALUES ('腾讯ASR', 'config_asr_provider_tx', 'tx', 'Y', 'admin', NOW(), 'ASR厂商-mod_tx_asr');

DELETE FROM `sys_role_menu`
WHERE `menu_id` = 4023;

DELETE FROM `sys_menu`
WHERE `menu_id` = 4023
   OR `perms` = 'cc:txasrbridgeconf:view'
   OR `url` = '/cc/fsconf/txasrbridgeconf';

INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `menu_code`, `parent_id`, `order_num`, `url`, `target`, `menu_type`, `visible`, `is_refresh`, `perms`, `icon`, `create_by`, `create_time`, `remark`)
VALUES (4023, '腾讯ASR配置', 'txAsrBridgeConf', 3018, 8, '/cc/fsconf/txasrbridgeconf', 'menuItem', 'C', '0', '1', 'cc:txasrbridgeconf:view', '#', 'admin', NOW(), 'mod_tx_asr 参数配置菜单');

INSERT INTO `sys_role_menu` (`role_id`, `menu_id`)
VALUES (2, 4023);

DELETE FROM `fs_variables`
WHERE `var_field_name` IN (
    'appid',
    'secret-id',
    'secret-key',
    'websocket-host',
    'engine-model-type',
    'voice-format',
    'need-vad',
    'filter-dirty',
    'filter-modal',
    'filter-punc',
    'filter-empty-result',
    'convert-num-mode',
    'word-info',
    'vad-silence-time',
    'max-speak-time',
    'hotword-id',
    'hotword-list',
    'customization-id',
    'noise-threshold',
    'signature-expire-seconds'
)
AND `cat` = 5;

INSERT INTO `fs_variables` (`id`, `cat`, `var_field_name`, `var_field_alias`) VALUES
(400, 5, 'appid', '腾讯 ASR AppID'),
(401, 5, 'secret-id', '腾讯 ASR SecretId'),
(402, 5, 'secret-key', '腾讯 ASR SecretKey'),
(403, 5, 'websocket-host', 'WebSocket Host'),
(404, 5, 'engine-model-type', '引擎模型'),
(405, 5, 'voice-format', '音频编码格式'),
(406, 5, 'need-vad', '启用 VAD'),
(407, 5, 'filter-dirty', '脏词过滤'),
(408, 5, 'filter-modal', '语气词过滤'),
(409, 5, 'filter-punc', '标点过滤'),
(410, 5, 'filter-empty-result', '过滤空识别结果'),
(411, 5, 'convert-num-mode', '数字转换模式'),
(412, 5, 'word-info', '词级时间戳'),
(413, 5, 'vad-silence-time', '句尾静音时长(毫秒)'),
(414, 5, 'max-speak-time', '强制断句时长(毫秒)'),
(415, 5, 'hotword-id', '热词表 ID'),
(416, 5, 'hotword-list', '临时热词表'),
(417, 5, 'customization-id', '自学习模型 ID'),
(418, 5, 'noise-threshold', '噪音阈值'),
(419, 5, 'signature-expire-seconds', '签名有效期(秒)');

DELETE FROM `cc_asr_languages`
WHERE `asr_provider` = 'tx';

INSERT INTO `cc_asr_languages` (`asr_provider`, `models`, `language_code`, `language_name`) VALUES
('tx', '8k_zh', 'zh-CN', '中文(8k)'),
('tx', '16k_zh', 'zh-CN', '中文(16k)'),
('tx', '8k_en', 'en-US', '英文(8k)'),
('tx', '16k_en', 'en-US', '英文(16k)'),
('tx', '16k_yue', 'zh-HK', '粤语');

UPDATE `cc_params`
SET `param_name` = '双向asr语音识别，使用哪个asr引擎(chinatelecom/funasr/aliyun/ali/tx)'
WHERE `param_code` = 'fs_call_asr_engine';
