From ad232fdbd98f02f3163e8cbc78f69d326399a93c Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 28 May 2026 13:28:36 +0800 Subject: [PATCH] Add configuration files for FastGPT with XFYun services, including STT, TTS, and audio filtering settings. Introduce new JSON files for different service configurations and enhance logging for text delta responses in the web application. --- config/fastgpt.state.xfyun.json | 99 +++++++++++++++++++++++++++ config/fastgpt.xfyun.dfn.json | 103 +++++++++++++++++++++++++++++ config/fastgpt.xfyun.json | 93 ++++++++++++++++++++++++++ config/fastgpt.xfyun.supertts.json | 95 ++++++++++++++++++++++++++ examples/webpage/app.js | 20 ++++++ 5 files changed, 410 insertions(+) create mode 100644 config/fastgpt.state.xfyun.json create mode 100644 config/fastgpt.xfyun.dfn.json create mode 100644 config/fastgpt.xfyun.json create mode 100644 config/fastgpt.xfyun.supertts.json diff --git a/config/fastgpt.state.xfyun.json b/config/fastgpt.state.xfyun.json new file mode 100644 index 0000000..f25ce21 --- /dev/null +++ b/config/fastgpt.state.xfyun.json @@ -0,0 +1,99 @@ +{ + "server": { + "host": "0.0.0.0", + "port": 8000, + "cors_origins": ["*"] + }, + "audio": { + "sample_rate_hz": 16000, + "channels": 1, + "frame_ms": 20 + }, + "session": { + "inactivity_timeout_sec": 60 + }, + "turn": { + "vad": { + "confidence": 0.7, + "start_secs": 0.35, + "stop_secs": 0.2, + "min_volume": 0.65 + }, + "interruption_min_chars": 3, + "interruption_use_interim": true, + "interruption_short_replies": [ + "是", + "是的", + "对", + "对的", + "嗯", + "好", + "好的", + "行", + "可以", + "没问题", + "不是", + "不", + "不行", + "不用", + "不要", + "没有", + "否", + "你好", + "在吗" + ], + "user_speech_timeout_sec": 0.2 + }, + "agent": { + "system_prompt": "FastGPT app owns the system prompt when send_system_prompt is false.", + "greeting": "您好,这里是无锡交警,我将为您远程处理交通事故。请将人员撤离至路侧安全区域,开启危险报警双闪灯、放置三角警告牌、做好安全防护,谨防二次事故伤害。若您已经准备好了,请点击继续办理,如需人工服务,请说转人工。", + "greeting_mode": "fixed", + "response_state": { + "enabled": true, + "tag": "state", + "event_type": "response.state", + "max_prefix_chars": 256 + } + }, + "services": { + "stt": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://iat-api.xfyun.cn/v2/iat", + "language": "zh_cn", + "domain": "iat", + "accent": "mandarin", + "encoding": "raw", + "frame_size": 1280, + "timeout_sec": 10.0 + }, + "llm": { + "provider": "fastgpt", + "api_key": "fastgpt-zlLjYtWZWN0uhQHs3ZOFHG4KLGMIdr2CkbZLCSfqGm5vcdx5xIZbp", + "base_url": "http://localhost:3030", + "model": "my-voice-app", + "app_id": "691eddaa53e3f8d9f25f1370", + "chat_id": null, + "variables": {}, + "detail": false, + "timeout_sec": 60.0, + "send_system_prompt": false + }, + "tts": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://tts-api.xfyun.cn/v2/tts", + "voice": "x4_xiaoyan", + "aue": "raw", + "tte": "UTF8", + "speed": 50, + "volume": 50, + "pitch": 50, + "source_sample_rate_hz": 16000 + } + } +} diff --git a/config/fastgpt.xfyun.dfn.json b/config/fastgpt.xfyun.dfn.json new file mode 100644 index 0000000..8692399 --- /dev/null +++ b/config/fastgpt.xfyun.dfn.json @@ -0,0 +1,103 @@ +{ + "server": { + "host": "0.0.0.0", + "port": 8000, + "cors_origins": ["*"] + }, + "audio": { + "sample_rate_hz": 16000, + "channels": 1, + "frame_ms": 20 + }, + "audio_filter": { + "enabled": true, + "provider": "deepfilternet", + "lib_path": "C:\\Users\\52943\\Code\\DeepFilterNet\\target\\release\\df.dll", + "model_path": "C:\\Users\\52943\\Code\\DeepFilterNet\\models\\DeepFilterNet3_ll_onnx.tar.gz", + "model_sample_rate_hz": 48000, + "atten_lim_db": 100.0, + "post_filter_beta": 0.0, + "log_level": null + }, + "session": { + "inactivity_timeout_sec": 60 + }, + "turn": { + "vad": { + "confidence": 0.7, + "start_secs": 0.25, + "stop_secs": 0.2, + "min_volume": 0.7 + }, + "interruption_min_chars": 3, + "interruption_use_interim": true, + "interruption_short_replies": [ + "是", + "是的", + "对", + "对的", + "嗯", + "好", + "好的", + "行", + "可以", + "没问题", + "不是", + "不", + "不行", + "不用", + "不要", + "没有", + "否", + "你好", + "在吗" + ], + "user_speech_timeout_sec": 0.2 + }, + "agent": { + "system_prompt": "FastGPT app owns the system prompt when send_system_prompt is false.", + "greeting": "您好,这里是无锡交警,我将为您远程处理交通事故。请将人员撤离至路侧安全区域,开启危险报警双闪灯、放置三角警告牌、做好安全防护,谨防二次事故伤害。若您已经准备好了,请点击继续办理,如需人工服务,请说转人工。", + "greeting_mode": "fixed" + }, + "services": { + "stt": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://iat-api.xfyun.cn/v2/iat", + "language": "zh_cn", + "domain": "iat", + "accent": "mandarin", + "encoding": "raw", + "frame_size": 1280, + "timeout_sec": 10.0 + }, + "llm": { + "provider": "fastgpt", + "api_key": "fastgpt-v1FljAxBz3tJeS0bH7HZU4yVGclsTcfiy9yK7V9Zr9126maDHQ97Xlo8n", + "base_url": "http://localhost:3030", + "model": "my-voice-app", + "app_id": "6a153aed53e3f8d9f2744905", + "chat_id": null, + "variables": {}, + "detail": false, + "timeout_sec": 60.0, + "send_system_prompt": false + }, + "tts": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://tts-api.xfyun.cn/v2/tts", + "voice": "x4_xiaoyan", + "aue": "raw", + "tte": "UTF8", + "speed": 50, + "volume": 50, + "pitch": 50, + "source_sample_rate_hz": 16000 + } + } +} diff --git a/config/fastgpt.xfyun.json b/config/fastgpt.xfyun.json new file mode 100644 index 0000000..e616962 --- /dev/null +++ b/config/fastgpt.xfyun.json @@ -0,0 +1,93 @@ +{ + "server": { + "host": "0.0.0.0", + "port": 8000, + "cors_origins": ["*"] + }, + "audio": { + "sample_rate_hz": 16000, + "channels": 1, + "frame_ms": 20 + }, + "session": { + "inactivity_timeout_sec": 60 + }, + "turn": { + "vad": { + "confidence": 0.7, + "start_secs": 0.35, + "stop_secs": 0.2, + "min_volume": 0.65 + }, + "interruption_min_chars": 3, + "interruption_use_interim": true, + "interruption_short_replies": [ + "是", + "是的", + "对", + "对的", + "嗯", + "好", + "好的", + "行", + "可以", + "没问题", + "不是", + "不", + "不行", + "不用", + "不要", + "没有", + "否", + "你好", + "在吗" + ], + "user_speech_timeout_sec": 0.2 + }, + "agent": { + "system_prompt": "FastGPT app owns the system prompt when send_system_prompt is false.", + "greeting": "您好,这里是无锡交警,我将为您远程处理交通事故。请将人员撤离至路侧安全区域,开启危险报警双闪灯、放置三角警告牌、做好安全防护,谨防二次事故伤害。若您已经准备好了,请点击继续办理,如需人工服务,请说转人工。", + "greeting_mode": "fixed" + }, + "services": { + "stt": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://iat-api.xfyun.cn/v2/iat", + "language": "zh_cn", + "domain": "iat", + "accent": "mandarin", + "encoding": "raw", + "frame_size": 1280, + "timeout_sec": 10.0 + }, + "llm": { + "provider": "fastgpt", + "api_key": "fastgpt-v1FljAxBz3tJeS0bH7HZU4yVGclsTcfiy9yK7V9Zr9126maDHQ97Xlo8n", + "base_url": "http://localhost:3030", + "model": "my-voice-app", + "app_id": "6a153aed53e3f8d9f2744905", + "chat_id": null, + "variables": {}, + "detail": false, + "timeout_sec": 60.0, + "send_system_prompt": false + }, + "tts": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://tts-api.xfyun.cn/v2/tts", + "voice": "x4_xiaoyan", + "aue": "raw", + "tte": "UTF8", + "speed": 50, + "volume": 50, + "pitch": 50, + "source_sample_rate_hz": 16000 + } + } +} diff --git a/config/fastgpt.xfyun.supertts.json b/config/fastgpt.xfyun.supertts.json new file mode 100644 index 0000000..d11cc63 --- /dev/null +++ b/config/fastgpt.xfyun.supertts.json @@ -0,0 +1,95 @@ +{ + "server": { + "host": "0.0.0.0", + "port": 8000, + "cors_origins": ["*"] + }, + "audio": { + "sample_rate_hz": 16000, + "channels": 1, + "frame_ms": 20 + }, + "session": { + "inactivity_timeout_sec": 60 + }, + "turn": { + "vad": { + "confidence": 0.8, + "start_secs": 0.4, + "stop_secs": 0.2, + "min_volume": 0.8 + }, + "interruption_min_chars": 3, + "interruption_use_interim": true, + "interruption_short_replies": [ + "是", + "是的", + "对", + "对的", + "嗯", + "好", + "好的", + "行", + "可以", + "没问题", + "不是", + "不", + "不行", + "不用", + "不要", + "没有", + "否", + "你好", + "在吗" + ], + "user_speech_timeout_sec": 0.2 + }, + "agent": { + "system_prompt": "FastGPT app owns the system prompt when send_system_prompt is false.", + "greeting": "您好,这里是无锡交警,我将为您远程处理交通事故。请将人员撤离至路侧安全区域,开启危险报警双闪灯、放置三角警告牌、做好安全防护,谨防二次事故伤害。若您已经准备好了,请点击继续办理,如需人工服务,请说转人工。", + "greeting_mode": "fixed" + }, + "services": { + "stt": { + "provider": "xfyun", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://iat-api.xfyun.cn/v2/iat", + "language": "zh_cn", + "domain": "iat", + "accent": "mandarin", + "encoding": "raw", + "frame_size": 1280, + "timeout_sec": 10.0 + }, + "llm": { + "provider": "fastgpt", + "api_key": "fastgpt-v1FljAxBz3tJeS0bH7HZU4yVGclsTcfiy9yK7V9Zr9126maDHQ97Xlo8n", + "base_url": "http://localhost:3030", + "model": "my-voice-app", + "app_id": "6a153aed53e3f8d9f2744905", + "chat_id": null, + "variables": {}, + "detail": false, + "timeout_sec": 60.0, + "send_system_prompt": false + }, + "tts": { + "provider": "xfyun_super", + "app_id": "416ce125", + "api_key": "c65342fe603126c3610031d8429bb36d", + "api_secret": "MzkyYmI5OWEyODQzN2FiN2VhN2UzYzU4", + "base_url": "wss://cbm01.cn-huabei-1.xf-yun.com/v1/private/mcd9m97e6", + "voice": "x5_lingxiaoxuan_flow", + "aue": "raw", + "speed": 50, + "volume": 50, + "pitch": 50, + "oral_level": "mid", + "source_sample_rate_hz": 24000, + "text_aggregation_mode": "token", + "timeout_sec": 30.0 + } + } +} diff --git a/examples/webpage/app.js b/examples/webpage/app.js index e18caad..dc23c3a 100644 --- a/examples/webpage/app.js +++ b/examples/webpage/app.js @@ -20,6 +20,7 @@ const MAX_WS_LOG_LINES = 120; const MAX_GROUP_CHILDREN_RENDER = 100; const WS_LOG_GROUP_KEYS = { AUDIO_DELTA: "recv:response.audio.delta", + TEXT_DELTA: "recv:response.text.delta", AUDIO_SEND: "send:input.audio", }; @@ -205,6 +206,9 @@ function wsLogGroupLabel(groupKey) { if (groupKey === WS_LOG_GROUP_KEYS.AUDIO_DELTA) { return "response.audio.delta"; } + if (groupKey === WS_LOG_GROUP_KEYS.TEXT_DELTA) { + return "response.text.delta"; + } if (groupKey === WS_LOG_GROUP_KEYS.AUDIO_SEND) { return "input.audio binary"; } @@ -430,6 +434,22 @@ function logWsPayload(direction, payload) { ); return; } + if (direction === "recv" && payload?.type === "response.text.delta") { + const text = typeof payload.text === "string" ? payload.text : ""; + const bytes = new TextEncoder().encode(text).length; + const detail = + payload.seq != null + ? `seq=${payload.seq} ${JSON.stringify(truncateLogValue(text, 120))}` + : JSON.stringify(truncateLogValue(text, 120)); + appendWsLogGroupItem( + WS_LOG_GROUP_KEYS.TEXT_DELTA, + "recv", + "recv", + detail, + bytes, + ); + return; + } addWsLog(direction, compactWsPayload(payload)); }