-- 2026-05-22
-- Keep the old aliyun provider and add an independent ali provider for mod_ali_asr.
DELETE FROM `sys_config`
WHERE `config_key` = 'config_asr_provider_ali';

INSERT INTO `sys_config` (`config_name`, `config_key`, `config_value`, `config_type`, `create_by`, `create_time`, `remark`)
VALUES ('阿里ASR(新)', 'config_asr_provider_ali', 'ali', 'Y', 'admin', NOW(), 'ASR厂商-mod_ali_asr');

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

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

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 (4022, '阿里ASR配置(新)', 'aliAsrBridgeConf', 3018, 7, '/cc/fsconf/aliasrbridgeconf', 'menuItem', 'C', '0', '1', 'cc:aliasrbridgeconf:view', '#', 'admin', NOW(), 'mod_ali_asr 参数配置菜单');

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

DELETE FROM `fs_variables`
WHERE `var_field_name` IN (
    'api-key',
    'workspace-id',
    'websocket-url',
    'model',
    'sample-rate',
    'send-chunk-ms',
    'semantic-punctuation-enabled',
    'max-sentence-silence',
    'multi-threshold-mode-enabled',
    'punctuation-prediction-enabled',
    'inverse-text-normalization-enabled',
    'heartbeat',
    'verify-peer'
)
AND `cat` = 5;

INSERT INTO `fs_variables` (`id`, `cat`, `var_field_name`, `var_field_alias`) VALUES
(37, 5, 'api-key', '阿里 ASR API Key'),
(38, 5, 'workspace-id', '工作空间 ID'),
(39, 5, 'websocket-url', 'WebSocket 地址'),
(40, 5, 'model', '识别模型'),
(41, 5, 'sample-rate', '音频采样率'),
(42, 5, 'send-chunk-ms', '音频发送分片时长(毫秒)'),
(43, 5, 'semantic-punctuation-enabled', '启用语义标点'),
(44, 5, 'max-sentence-silence', '句尾静音时长(毫秒)'),
(45, 5, 'multi-threshold-mode-enabled', '启用多阈值模式'),
(46, 5, 'punctuation-prediction-enabled', '启用标点预测'),
(47, 5, 'inverse-text-normalization-enabled', '启用逆文本归一化'),
(48, 5, 'heartbeat', '启用心跳'),
(49, 5, 'verify-peer', '校验证书');

DELETE FROM `cc_asr_languages`
WHERE `asr_provider` = 'ali'
  AND `models` = 'fun-asr-flash-8k-realtime'
  AND `language_code` = 'zh-CN';

INSERT INTO `cc_asr_languages` (`asr_provider`, `models`, `language_code`, `language_name`)
VALUES ('ali', 'fun-asr-flash-8k-realtime', 'zh-CN', '中文');

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

UPDATE `sys_config`
SET `config_value` = 'v20260217'
WHERE `config_key` = 'sys.version';
