fix: fix aiAns Extension & distinguish asr large/small model configurations & remove linebreak eslint.

This commit is contained in:
quemingyi.wudong 2025-04-03 14:15:53 +08:00
parent 4f088b0e89
commit b79f5bcfc5
3 changed files with 27 additions and 13 deletions

View File

@ -42,7 +42,7 @@
], ],
"rules": { "rules": {
"prettier/prettier": ["warn", { "trailingComma": "es5", "printWidth": 200 }], "prettier/prettier": ["warn", { "trailingComma": "es5", "printWidth": 200 }],
"linebreak-style": ["error", "unix"], "linebreak-style": "off",
"no-console": ["warn", { "allow": ["warn", "error", "log"] }], "no-console": ["warn", { "allow": ["warn", "error", "log"] }],
"no-case-declarations": 0, "no-case-declarations": 0,
"no-param-reassign": 0, "no-param-reassign": 0,

View File

@ -72,7 +72,9 @@ export class ConfigFactory {
ASRAppId: 'Your ASR AppId', ASRAppId: 'Your ASR AppId',
/** /**
* @brief AppId Access Token * @brief AppId Access Token
* 使 * @note 使 **** , https://console.volcengine.com/speech/service/10011?AppID=6482372612&s=g 中查看。
* , ASRToken, Demo 使
* 使 ASRToken
*/ */
ASRToken: undefined, ASRToken: undefined,
}; };
@ -156,13 +158,13 @@ export class ConfigFactory {
} }
get ASRConfig() { get ASRConfig() {
const params: Record<string, any> = { /**
* @brief SmallModelASRConfigs
* @note 使, ASR 使
*/
const SmallModelASRConfigs = {
Provider: 'volcano', Provider: 'volcano',
ProviderParams: { ProviderParams: {
/**
* @note 使, ASR 使
* 使 https://www.volcengine.com/docs/6348/1404673#volcanolmasrconfig?s=g
*/
Mode: 'smallmodel', Mode: 'smallmodel',
AppId: this.BaseConfig.ASRAppId, AppId: this.BaseConfig.ASRAppId,
/** /**
@ -171,16 +173,29 @@ export class ConfigFactory {
*/ */
Cluster: 'volcengine_streaming_common', Cluster: 'volcengine_streaming_common',
}, },
/**
* @note , 使 VAD ,
*/
VADConfig: { VADConfig: {
SilenceTime: 600, SilenceTime: 600,
SilenceThreshold: 200, SilenceThreshold: 200,
}, },
VolumeGain: 0.3, VolumeGain: 0.3,
}; };
if (this.BaseConfig.ASRToken) {
params.ProviderParams.AccessToken = this.BaseConfig.ASRToken; /**
} * @brief BigModelASRConfigs
return params; * @note 使 https://www.volcengine.com/docs/6348/1404673#volcanolmasrconfig?s=g
*/
const BigModelASRConfigs = {
Provider: 'volcano',
ProviderParams: {
Mode: 'bigmodel',
AppId: this.BaseConfig.ASRAppId,
AccessToken: this.BaseConfig.ASRToken,
},
};
return this.BaseConfig.ASRToken ? BigModelASRConfigs : SmallModelASRConfigs;
} }
get TTSConfig() { get TTSConfig() {

View File

@ -70,8 +70,6 @@ export interface BasicBody {
login_token: string | null; login_token: string | null;
} }
export const AIAnsExtension = new RTCAIAnsExtension();
/** /**
* @brief RTC Core Client * @brief RTC Core Client
* @notes Refer to official website documentation to get more information about the API. * @notes Refer to official website documentation to get more information about the API.
@ -101,6 +99,7 @@ export class RTCClient {
this.engine = VERTC.createEngine(this.config.appId); this.engine = VERTC.createEngine(this.config.appId);
try { try {
const AIAnsExtension = new RTCAIAnsExtension();
await this.engine.registerExtension(AIAnsExtension); await this.engine.registerExtension(AIAnsExtension);
AIAnsExtension.enable(); AIAnsExtension.enable();
} catch (error) { } catch (error) {