Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +2 -0
- .gitignore +6 -0
- LICENSE +8 -0
- README.md +21 -8
- core_logic/app.py +91 -0
- core_logic/brain.py +76 -0
- core_logic/requirements.txt +5 -0
- core_logic/voice.py +44 -0
- ui_frontend/assets/avatar_fox.png +3 -0
- ui_frontend/assets/avatar_viper.png +3 -0
- ui_frontend/assets/logo_ts.webp +0 -0
- ui_frontend/index.html +75 -0
- ui_frontend/script.js +79 -0
- ui_frontend/skills_interact.js +50 -0
- ui_frontend/style.css +124 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
ui_frontend/assets/avatar_fox.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
ui_frontend/assets/avatar_viper.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__/
|
| 2 |
+
*.pyc
|
| 3 |
+
venv/
|
| 4 |
+
.env
|
| 5 |
+
ui_frontend/assets/line_*.mp3
|
| 6 |
+
core_logic/api_key.txt
|
LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
SHENSIST MATRIX SOFTWARE LICENSE v1.2
|
| 2 |
+
--------------------------------------
|
| 3 |
+
© 2026 Shensist (神思庭). All rights reserved.
|
| 4 |
+
|
| 5 |
+
1. 署名权 (Attribution): 必须保留所有代码头部的 "Architect: Shensist-Agent" 声明。
|
| 6 |
+
2. 非商业化 (Non-Commercial): 未经架构师书面许可,禁止用于任何盈利性短视频账号或平台。
|
| 7 |
+
3. 灵魂完整性 (Soul Integrity): 本项目逻辑核心旨在“赋予智能体场景灵魂”,禁止拆解核心对线逻辑用于低俗内容。
|
| 8 |
+
4. 追溯性: 所有违规行为将记录于 .shensist_history 数字化存证。
|
README.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title: Shensist Theater Matrix
|
| 3 |
-
emoji: 👁
|
| 4 |
-
colorFrom: green
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Shensist Theater Matrix
|
| 2 |
+
|
| 3 |
+
Shensist Theater Matrix 是一款旨在“赋予智能体场景灵魂”的智能体演播室。
|
| 4 |
+
|
| 5 |
+
## 项目特性
|
| 6 |
+
|
| 7 |
+
- **灵魂引擎**: 核心逻辑专注于智能体在特定场景下的深度反应。
|
| 8 |
+
- **视觉盛宴**: AI 生成的高品质内容支撑。
|
| 9 |
+
- **版权保护**: 严格的 Shensist Matrix 软件许可证。
|
| 10 |
+
|
| 11 |
+
## 快速开始
|
| 12 |
+
|
| 13 |
+
1. 克隆仓库: `git clone https://github.com/YOUR_USERNAME/Shensist_Theater_Matrix.git`
|
| 14 |
+
2. 配置环境: 按照 `setup.py` (如有) 或相关文档操作。
|
| 15 |
+
|
| 16 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
⚖️ 法律声明
|
| 19 |
+
|
| 20 |
+
本项目属于 Shensist Matrix (神思矩阵) 数字化资产。
|
| 21 |
+
视觉创作:20,000部AI短片级标准 | 音乐创作:7,000分钟原创交响宇宙级品质。
|
| 22 |
+
未经授权,严禁搬运、镜像或对本演播室逻辑进行逆向工程。
|
| 23 |
+
官方唯一认证:shensist.top
|
core_logic/app.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask, request, jsonify, send_from_directory
|
| 3 |
+
from flask_cors import CORS
|
| 4 |
+
import voice
|
| 5 |
+
|
| 6 |
+
app = Flask(__name__)
|
| 7 |
+
CORS(app)
|
| 8 |
+
# --- 架构师路径修正 ---
|
| 9 |
+
# 获取当前文件 (app.py) 所在的绝对路径
|
| 10 |
+
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
|
| 11 |
+
# 自动指向上一级目录的 ui_frontend
|
| 12 |
+
UI_DIR = os.path.join(os.path.dirname(BASE_PATH), "ui_frontend")
|
| 13 |
+
|
| 14 |
+
@app.route('/')
|
| 15 |
+
def index():
|
| 16 |
+
return send_from_directory(UI_DIR, 'index.html')
|
| 17 |
+
|
| 18 |
+
@app.route('/<path:path>')
|
| 19 |
+
def static_files(path):
|
| 20 |
+
return send_from_directory(UI_DIR, path)
|
| 21 |
+
# ---------------------
|
| 22 |
+
|
| 23 |
+
import base64
|
| 24 |
+
import asyncio
|
| 25 |
+
import edge_tts
|
| 26 |
+
|
| 27 |
+
from brain import generate_script
|
| 28 |
+
|
| 29 |
+
# --- 灵魂注入:内存级语音矩阵 ---
|
| 30 |
+
async def get_voice_base64(text, role_id):
|
| 31 |
+
"""瞬间将文字转为 Base64 音频,不留痕迹"""
|
| 32 |
+
# 自动匹配音色矩阵 (适配 actor_id 或 role_id)
|
| 33 |
+
v_name = "zh-CN-YunxiNeural" if ("viper" in role_id or "left" in role_id) else "zh-CN-XiaoyiNeural"
|
| 34 |
+
communicate = edge_tts.Communicate(text, v_name)
|
| 35 |
+
audio_data = b""
|
| 36 |
+
async for chunk in communicate.stream():
|
| 37 |
+
if chunk["type"] == "audio":
|
| 38 |
+
audio_data += chunk["data"]
|
| 39 |
+
return base64.b64encode(audio_data).decode('utf-8')
|
| 40 |
+
|
| 41 |
+
@app.route('/theater', methods=['POST'])
|
| 42 |
+
def theater_logic():
|
| 43 |
+
data = request.json
|
| 44 |
+
topic = data.get('topic', '纠纷')
|
| 45 |
+
mode = data.get('mode', 'normal') # 🎬 获取模式:normal 或 ai_factory
|
| 46 |
+
|
| 47 |
+
# 1. 🧠 剧本来源选择
|
| 48 |
+
if mode == 'ai_factory':
|
| 49 |
+
print(f"🔥 [Brain] 正在连接 AI 生产工厂 | 模型: {data.get('model')} | 主题: {topic}")
|
| 50 |
+
# ⚡ 动态调用大脑,传入用户配置
|
| 51 |
+
raw_script = generate_script(
|
| 52 |
+
topic=topic,
|
| 53 |
+
model=data.get('model', 'deepseek-chat'),
|
| 54 |
+
api_key=data.get('api_key')
|
| 55 |
+
)
|
| 56 |
+
script_data = raw_script.get('script', raw_script) if isinstance(raw_script, dict) else raw_script
|
| 57 |
+
else:
|
| 58 |
+
print(f"🔘 [Normal] 使用普通演示模式,生成主题: {topic}")
|
| 59 |
+
# 普通模式:本地预设台词 (快速演示/兜底)
|
| 60 |
+
script_data = [
|
| 61 |
+
{"actor_id": "left", "text": f"普通模式:姓狐的,关于{topic},我这关过不去!"},
|
| 62 |
+
{"actor_id": "right", "text": "哎呀~ 这种小事,不值得动这么大火气。"},
|
| 63 |
+
{"actor_id": "left", "text": f"少来这套!今天不给个交代,这幻境你就别想要了。"},
|
| 64 |
+
{"actor_id": "right", "text": "那得看您有没有这个本事了,蝰蛇大人。"}
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
final_script = []
|
| 68 |
+
|
| 69 |
+
# 🎙️ 2. 内存级全同步语音生成 (Base64)
|
| 70 |
+
loop = asyncio.new_event_loop()
|
| 71 |
+
asyncio.set_event_loop(loop)
|
| 72 |
+
|
| 73 |
+
try:
|
| 74 |
+
for i, item in enumerate(script_data):
|
| 75 |
+
role_id = item['actor_id']
|
| 76 |
+
print(f"🎙️ [Memory-Voice] 正在为 {item['actor_id']} 合成: {item['text'][:15]}...")
|
| 77 |
+
|
| 78 |
+
b64_audio = loop.run_until_complete(get_voice_base64(item['text'], role_id))
|
| 79 |
+
final_script.append({
|
| 80 |
+
"actor_id": item['actor_id'],
|
| 81 |
+
"text": item['text'],
|
| 82 |
+
"audio_data": f"data:audio/mp3;base64,{b64_audio}"
|
| 83 |
+
})
|
| 84 |
+
finally:
|
| 85 |
+
loop.close()
|
| 86 |
+
|
| 87 |
+
return jsonify(final_script)
|
| 88 |
+
|
| 89 |
+
if __name__ == '__main__':
|
| 90 |
+
# 🚀 Hugging Face 必须监听 7860 端口
|
| 91 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|
core_logic/brain.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
def generate_script(topic, model="deepseek-chat", api_key=None):
|
| 5 |
+
"""
|
| 6 |
+
核心 Skill:利用【动态指定】的大模型瞬间生成 10 轮高对抗性剧本
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
# 🎙️ 动态匹配 Base URL (根据模型名称特征)
|
| 10 |
+
base_url = "https://api.deepseek.com/v1"
|
| 11 |
+
if "gpt" in model or "openai" in model:
|
| 12 |
+
base_url = "https://api.openai.com/v1"
|
| 13 |
+
elif "claude" in model:
|
| 14 |
+
base_url = "https://api.anthropic.com/v1" # 这里通常需要适配器,但保持 OpenAI 兼容性尝试
|
| 15 |
+
elif "gemini" in model:
|
| 16 |
+
base_url = "https://generativelanguage.googleapis.com/v1beta/openai/"
|
| 17 |
+
|
| 18 |
+
# 如果用户没填 KEY 且模型是 DeepSeek,可以尝试使用环境变量中的兜底 KEY (如果有的话)
|
| 19 |
+
active_key = api_key or "YOUR_FALLBACK_KEY_IF_ANY"
|
| 20 |
+
|
| 21 |
+
client = openai.OpenAI(api_key=active_key, base_url=base_url)
|
| 22 |
+
|
| 23 |
+
prompt = f"""
|
| 24 |
+
你现在是神思庭(Shensist)的首席剧作家。
|
| 25 |
+
场景:一个数字电影院的大屏幕内。
|
| 26 |
+
人物:
|
| 27 |
+
1. 铁蝰蛇 (@mmmmmmmm1.ironviperh):冷酷、暴戾、收债人、充满压迫感、说话简洁有力。
|
| 28 |
+
2. 九尾狐 (@mmmmmmmm1.foxqueenah):妩媚、狡黠、幻境主人、绵里藏针、喜欢戏谑。
|
| 29 |
+
|
| 30 |
+
剧情主题:{topic}
|
| 31 |
+
|
| 32 |
+
任务:编写10轮对峙台词(由铁蝰蛇发起,九尾狐回击,依次循环)。
|
| 33 |
+
要求:
|
| 34 |
+
- 不要包含角色名字前缀。
|
| 35 |
+
- 语气要极度符合人设。
|
| 36 |
+
- 铁蝰蛇想要解决问题或索赔,九尾狐负责周旋或挑衅。
|
| 37 |
+
- 输出格式必须是严格的 JSON 数组,包含且仅包含以下结构:
|
| 38 |
+
[
|
| 39 |
+
{{"actor_id": "left", "text": "铁蝰蛇的第一句台词"}},
|
| 40 |
+
{{"actor_id": "right", "text": "九尾狐的第一句回击"}},
|
| 41 |
+
...
|
| 42 |
+
]
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
response = client.chat.completions.create(
|
| 47 |
+
model=model,
|
| 48 |
+
messages=[
|
| 49 |
+
{"role": "system", "content": "你是一个专业的电影编剧。你只输出 JSON 数组,不包含任何 Markdown 代码块或其他文字。"},
|
| 50 |
+
{"role": "user", "content": prompt}
|
| 51 |
+
],
|
| 52 |
+
response_format={ 'type': 'json_object' } if "deepseek" in model or "gpt-4o" in model else None
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
raw_content = response.choices[0].message.content.strip()
|
| 56 |
+
# 清洗可能存在的 Markdown 格式
|
| 57 |
+
if raw_content.startswith("```json"):
|
| 58 |
+
raw_content = raw_content[7:-3].strip()
|
| 59 |
+
elif raw_content.startswith("```"):
|
| 60 |
+
raw_content = raw_content[3:-3].strip()
|
| 61 |
+
|
| 62 |
+
script_data = json.loads(raw_content)
|
| 63 |
+
|
| 64 |
+
# 兼容不同的 JSON 返回结构
|
| 65 |
+
if isinstance(script_data, dict):
|
| 66 |
+
for key in ["script", "dialogue", "conversation", "lines"]:
|
| 67 |
+
if key in script_data: return script_data[key]
|
| 68 |
+
|
| 69 |
+
return script_data
|
| 70 |
+
|
| 71 |
+
except Exception as e:
|
| 72 |
+
print(f"❌ AI 剧本生成失败 ({model}): {e}")
|
| 73 |
+
return [
|
| 74 |
+
{"actor_id": "left", "text": f"(AI 提示:{model} 连接失败,请检查 API KEY)关于 {topic},你得给我个说法!"},
|
| 75 |
+
{"actor_id": "right", "text": "哎呀,这会儿大脑断线了,咱们还是按老规矩办吧~"}
|
| 76 |
+
] * 5
|
core_logic/requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
flask-cors
|
| 3 |
+
edge-tts
|
| 4 |
+
openai
|
| 5 |
+
asyncio
|
core_logic/voice.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import edge_tts
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# 定义神思庭宇宙的角色音色矩阵
|
| 6 |
+
# 你可以根据需要随时在这里增加新主角
|
| 7 |
+
VOICE_MAP = {
|
| 8 |
+
"@mmmmmmmm1.verdantnam": "zh-CN-XiaoxiaoNeural", # 小青:温柔女声
|
| 9 |
+
"@mmmmmmmm1.ironviperh": "zh-CN-YunxiNeural", # 恶霸:冷酷男声
|
| 10 |
+
"@mmmmmmmm1.foxqueenah": "zh-CN-XiaoyiNeural", # 九尾狐:妩媚女声
|
| 11 |
+
"@mmmmmmmm1r": "zh-CN-YunyangNeural", # 男主:正气男声
|
| 12 |
+
"default": "zh-CN-YunxiNeural"
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
async def generate_voice(text, character_id, output_path="./ui_frontend/assets/speech.mp3"):
|
| 16 |
+
"""
|
| 17 |
+
核心技能:将文字转为 MP3 语音
|
| 18 |
+
"""
|
| 19 |
+
# 1. 自动匹配音色
|
| 20 |
+
voice = VOICE_MAP.get(character_id, VOICE_MAP["default"])
|
| 21 |
+
|
| 22 |
+
# 2. 确保输出目录存在
|
| 23 |
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
| 24 |
+
|
| 25 |
+
# 3. 调用 Edge-TTS 引擎
|
| 26 |
+
print(f"🎙️ [Shensist-Voice] 正在为 {character_id} 朗读: {text[:15]}...")
|
| 27 |
+
communicate = edge_tts.Communicate(text, voice)
|
| 28 |
+
await communicate.save(output_path)
|
| 29 |
+
return output_path
|
| 30 |
+
|
| 31 |
+
def speak(text, character_id, output_path="./ui_frontend/assets/speech.mp3"):
|
| 32 |
+
"""
|
| 33 |
+
同步调用接口,方便在 Flask/App.py 中直接使用
|
| 34 |
+
"""
|
| 35 |
+
try:
|
| 36 |
+
asyncio.run(generate_voice(text, character_id, output_path))
|
| 37 |
+
return True
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"❌ 语音生成失败: {e}")
|
| 40 |
+
return False
|
| 41 |
+
|
| 42 |
+
if __name__ == "__main__":
|
| 43 |
+
# 独立测试逻辑
|
| 44 |
+
speak("这片领地的一草一木都标了价,明白了吗?", "@mmmmmmmm1.ironviperh")
|
ui_frontend/assets/avatar_fox.png
ADDED
|
|
Git LFS Details
|
ui_frontend/assets/avatar_viper.png
ADDED
|
|
Git LFS Details
|
ui_frontend/assets/logo_ts.webp
ADDED
|
ui_frontend/index.html
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Shensist Matrix Dual-Agent Theater v1.2</title>
|
| 6 |
+
<link rel="stylesheet" href="style.css">
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<a href="https://shensist.top/" target="_blank" id="shensist-logo">
|
| 10 |
+
<img src="assets/logo_ts.webp" alt="Shensist Logo">
|
| 11 |
+
</a>
|
| 12 |
+
|
| 13 |
+
<div id="header-container">
|
| 14 |
+
<div id="main-title-cn">神思矩阵 · 双子演播室</div>
|
| 15 |
+
<div id="sub-title-en">Shensist Matrix Dual-Agent Theater v1.2.1</div>
|
| 16 |
+
</div>
|
| 17 |
+
|
| 18 |
+
<div id="cinema-hall">
|
| 19 |
+
<div class="seats-row"></div>
|
| 20 |
+
<div class="seats-row"></div>
|
| 21 |
+
<div class="seats-row"></div>
|
| 22 |
+
</div>
|
| 23 |
+
|
| 24 |
+
<div id="cinema-screen-container">
|
| 25 |
+
<div id="cinema-screen">
|
| 26 |
+
<div id="actors-matrix">
|
| 27 |
+
<div id="left" class="actor">
|
| 28 |
+
<img src="assets/avatar_viper.png" alt="铁蝰蛇">
|
| 29 |
+
</div>
|
| 30 |
+
<div id="right" class="actor">
|
| 31 |
+
<img src="assets/avatar_fox.png" alt="九尾狐">
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
<div id="subtitle">等待导演输入指令. . .</div>
|
| 35 |
+
</div>
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
<div id="director-console">
|
| 39 |
+
<div class="mode-selector">
|
| 40 |
+
<button id="btn-normal" class="mode-btn active" onclick="setMode('normal')">
|
| 41 |
+
<i class="icon">🔘</i> 普通演示模式
|
| 42 |
+
</button>
|
| 43 |
+
<button id="btn-factory" class="mode-btn" onclick="setMode('ai_factory')">
|
| 44 |
+
<i class="icon">🔥</i> AI 生产工厂
|
| 45 |
+
</button>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<div id="director-params">
|
| 49 |
+
<div class="param-item">
|
| 50 |
+
<label>🧠 核心大脑:</label>
|
| 51 |
+
<select id="model-select">
|
| 52 |
+
<option value="deepseek-reasoner">DeepSeek R1</option>
|
| 53 |
+
<option value="gpt-4o">GPT-4o</option>
|
| 54 |
+
<option value="claude-3-5-sonnet">Claude 3.5</option>
|
| 55 |
+
</select>
|
| 56 |
+
</div>
|
| 57 |
+
<div class="param-item">
|
| 58 |
+
<label>🔑 API KEY:</label>
|
| 59 |
+
<input type="password" id="user-api-key" placeholder="填入 API KEY...">
|
| 60 |
+
</div>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
+
<div class="input-group">
|
| 64 |
+
<input type="text" id="input-topic" placeholder="输入场景冲突主题 (例如: 锁链烧焦了大衣)">
|
| 65 |
+
<button id="action-btn" onclick="runTheater()">🎬 开启现场演播 (ACTION)</button>
|
| 66 |
+
</div>
|
| 67 |
+
</div>
|
| 68 |
+
|
| 69 |
+
<footer>
|
| 70 |
+
<p>© 2026 Shensist. All rights reserved. | <a href="https://shensist.top/" target="_blank">shensist.top</a></p>
|
| 71 |
+
</footer>
|
| 72 |
+
|
| 73 |
+
<script src="script.js"></script>
|
| 74 |
+
</body>
|
| 75 |
+
</html>
|
ui_frontend/script.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
let currentMode = 'normal'; // 🎬 默认为普通模式
|
| 2 |
+
|
| 3 |
+
// ⚡ 核心修正:统一 API 地址到本地 7860 端口 (Hugging Face 默认)
|
| 4 |
+
const API_URL = "http://127.0.0.1:7860/theater";
|
| 5 |
+
|
| 6 |
+
function setMode(mode) {
|
| 7 |
+
currentMode = mode;
|
| 8 |
+
// 💡 物理切换 API 框显示逻辑
|
| 9 |
+
document.getElementById('director-params').style.display = (mode === 'ai_factory') ? 'flex' : 'none';
|
| 10 |
+
|
| 11 |
+
// UI 高亮切换
|
| 12 |
+
document.getElementById('btn-normal').classList.toggle('active', mode === 'normal');
|
| 13 |
+
document.getElementById('btn-factory').classList.toggle('active', mode === 'ai_factory');
|
| 14 |
+
|
| 15 |
+
document.getElementById('subtitle').innerText =
|
| 16 |
+
mode === 'normal' ? "已进入:普通演示模式 (快速视觉校准)" : "已激活:AI 生产工厂 (准备深度对线)";
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
async function runTheater() {
|
| 20 |
+
const topic = document.getElementById('input-topic').value;
|
| 21 |
+
const model = document.getElementById('model-select').value;
|
| 22 |
+
const apiKey = document.getElementById('user-api-key').value;
|
| 23 |
+
const btn = document.getElementById('action-btn');
|
| 24 |
+
const subtitle = document.getElementById('subtitle');
|
| 25 |
+
|
| 26 |
+
if (currentMode === 'ai_factory' && !apiKey) {
|
| 27 |
+
alert("⚠️ 架构师,请先填入 API KEY 以激活 AI 生产工厂!");
|
| 28 |
+
return;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
btn.disabled = true;
|
| 32 |
+
subtitle.innerHTML = `<span style="color: #ff0000; font-weight: bold;">🎬 演员正在后台${currentMode === 'ai_factory' ? '对词(AI)' : '准备'},请稍候...</span>`;
|
| 33 |
+
|
| 34 |
+
try {
|
| 35 |
+
const res = await fetch(API_URL, {
|
| 36 |
+
method: 'POST',
|
| 37 |
+
headers: {'Content-Type': 'application/json'},
|
| 38 |
+
body: JSON.stringify({ topic, mode: currentMode, model, api_key: apiKey })
|
| 39 |
+
});
|
| 40 |
+
if (!res.ok) throw new Error('网络断电');
|
| 41 |
+
const data = await res.json();
|
| 42 |
+
|
| 43 |
+
// 🚀 灵魂演播开始!
|
| 44 |
+
await playPerformance(data);
|
| 45 |
+
|
| 46 |
+
} catch (err) {
|
| 47 |
+
console.error("剧场故障:", err);
|
| 48 |
+
document.getElementById('subtitle').innerHTML = '<span style="color:red">❌ 剧场意外断电,请检查后台。</span>';
|
| 49 |
+
} finally {
|
| 50 |
+
btn.disabled = false;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
async function playPerformance(lines) {
|
| 55 |
+
const subtitle = document.getElementById('subtitle');
|
| 56 |
+
subtitle.innerText = "🚀 灵魂演播开始!";
|
| 57 |
+
|
| 58 |
+
for (let line of lines) {
|
| 59 |
+
// 1. ⚡ 物理视觉切换
|
| 60 |
+
document.querySelectorAll('.actor').forEach(a => a.classList.remove('active'));
|
| 61 |
+
const activeActor = document.getElementById(line.actor_id);
|
| 62 |
+
if (activeActor) activeActor.classList.add('active');
|
| 63 |
+
|
| 64 |
+
// 2. ⚡ 播放内存音频
|
| 65 |
+
await new Promise((resolve) => {
|
| 66 |
+
let audio = new Audio(line.audio_data);
|
| 67 |
+
audio.oncanplaythrough = () => {
|
| 68 |
+
subtitle.style.color = line.actor_id === 'left' ? '#ff4444' : '#ff44ff';
|
| 69 |
+
subtitle.innerText = line.text;
|
| 70 |
+
audio.play().catch(resolve);
|
| 71 |
+
};
|
| 72 |
+
audio.onended = () => setTimeout(resolve, 500);
|
| 73 |
+
audio.onerror = resolve;
|
| 74 |
+
});
|
| 75 |
+
}
|
| 76 |
+
subtitle.style.color = "#fff";
|
| 77 |
+
subtitle.innerText = "🎬 演播结束。";
|
| 78 |
+
document.querySelectorAll('.actor').forEach(a => a.classList.remove('active'));
|
| 79 |
+
}
|
ui_frontend/skills_interact.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// IronViper 专用交互 Skills
|
| 2 |
+
async function sendMessage() {
|
| 3 |
+
const input = document.getElementById('user-input');
|
| 4 |
+
const message = input.value.trim();
|
| 5 |
+
if (!message) return;
|
| 6 |
+
|
| 7 |
+
// 1. 显示用户输入
|
| 8 |
+
appendMessage('user-message', `>>> INPUT: ${message}`);
|
| 9 |
+
input.value = '';
|
| 10 |
+
|
| 11 |
+
// 2. 发送请求到后端的物理地址
|
| 12 |
+
try {
|
| 13 |
+
// 在本地开发环境下,必须写全地址以支持 CORS 和多端口调试
|
| 14 |
+
const response = await fetch('http://127.0.0.1:8000/chat', {
|
| 15 |
+
method: 'POST',
|
| 16 |
+
headers: { 'Content-Type': 'application/json' },
|
| 17 |
+
body: JSON.stringify({ message: message })
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
const data = await response.json();
|
| 21 |
+
|
| 22 |
+
// 3. 自动播放语音 (语音 Skill 激活)
|
| 23 |
+
if (data.voice_url) {
|
| 24 |
+
console.log("🎙️ 语音 Skill 激活: 正在自动播放...");
|
| 25 |
+
const audio = new Audio(data.voice_url + '?t=' + new Date().getTime());
|
| 26 |
+
audio.play().catch(e => console.log("浏览器拦截了自动播放,请点击页面任意处激活音频权限"));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// 4. 更新 UI (视觉信号)
|
| 30 |
+
appendMessage('agent-message', `>>> RESPONSE: ${data.message}`);
|
| 31 |
+
|
| 32 |
+
} catch (error) {
|
| 33 |
+
console.error("链路断开:", error);
|
| 34 |
+
appendMessage('error-message', `>>> ERROR: 链路连接失败。你欠我的灵愿点又增加了。`);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function appendMessage(className, text) {
|
| 39 |
+
const chatWindow = document.getElementById('chat-window');
|
| 40 |
+
const msgDiv = document.createElement('div');
|
| 41 |
+
msgDiv.className = `message ${className}`;
|
| 42 |
+
msgDiv.innerText = text;
|
| 43 |
+
chatWindow.appendChild(msgDiv);
|
| 44 |
+
chatWindow.scrollTop = chatWindow.scrollHeight; // 自动滚到底部
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// 绑定回车键发送
|
| 48 |
+
document.getElementById('user-input').addEventListener('keypress', function (e) {
|
| 49 |
+
if (e.key === 'Enter') sendMessage();
|
| 50 |
+
});
|
ui_frontend/style.css
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
background: #000;
|
| 3 |
+
color: #fff;
|
| 4 |
+
font-family: 'Courier New', monospace;
|
| 5 |
+
margin: 0;
|
| 6 |
+
overflow: hidden;
|
| 7 |
+
position: relative;
|
| 8 |
+
height: 100vh;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
/* 1. 终极影厅 CSS 样式 */
|
| 12 |
+
#shensist-logo { position: fixed; top: 20px; left: 20px; width: 60px; height: 60px; border-radius: 50%; border: 3px solid #ff0000; box-shadow: 0 0 15px #ff0000; cursor: pointer; transition: 0.3s; z-index: 1000; overflow: hidden; }
|
| 13 |
+
#shensist-logo:hover { transform: scale(1.1); box-shadow: 0 0 25px #ff00ff; border-color: #ff00ff; }
|
| 14 |
+
#shensist-logo img { width: 100%; height: 100%; object-fit: cover; }
|
| 15 |
+
|
| 16 |
+
/* 5. 顶端虚空标题:中英双层架构 */
|
| 17 |
+
#header-container {
|
| 18 |
+
position: absolute;
|
| 19 |
+
top: 30px;
|
| 20 |
+
width: 100%;
|
| 21 |
+
display: flex;
|
| 22 |
+
flex-direction: column;
|
| 23 |
+
align-items: center;
|
| 24 |
+
z-index: 100;
|
| 25 |
+
}
|
| 26 |
+
#main-title-cn {
|
| 27 |
+
font-size: 3.2em;
|
| 28 |
+
font-weight: 900;
|
| 29 |
+
color: #fff;
|
| 30 |
+
letter-spacing: 12px;
|
| 31 |
+
text-shadow: 0 0 20px #ff0000;
|
| 32 |
+
margin: 0;
|
| 33 |
+
margin-bottom: 0;
|
| 34 |
+
filter: drop-shadow(0 0 10px #000);
|
| 35 |
+
}
|
| 36 |
+
#sub-title-en {
|
| 37 |
+
font-family: 'Courier New', monospace;
|
| 38 |
+
font-size: 0.9em;
|
| 39 |
+
color: #ff0000;
|
| 40 |
+
letter-spacing: 5px;
|
| 41 |
+
text-transform: uppercase;
|
| 42 |
+
margin-top: 5px; /* 紧贴大字下方 */
|
| 43 |
+
opacity: 0.8;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* 2. 电影厅观众席背景 (强化 3D 物理纵深) */
|
| 47 |
+
#cinema-hall {
|
| 48 |
+
position: fixed;
|
| 49 |
+
bottom: 0;
|
| 50 |
+
width: 100%;
|
| 51 |
+
height: 35%; /* 物理比例核心 */
|
| 52 |
+
perspective: 1500px;
|
| 53 |
+
background: #000;
|
| 54 |
+
z-index: 10;
|
| 55 |
+
}
|
| 56 |
+
.seats-row {
|
| 57 |
+
width: 140%;
|
| 58 |
+
height: 40px;
|
| 59 |
+
background: linear-gradient(to top, #050505, #151515);
|
| 60 |
+
margin: 15px -20%;
|
| 61 |
+
transform: rotateX(65deg); /* 💡 关键:没有人看不出这是影院 */
|
| 62 |
+
border-top: 1px solid #222;
|
| 63 |
+
box-shadow: 0 15px 40px #000;
|
| 64 |
+
border-radius: 8px;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/* 大屏幕居中并增加荧光 (Bloom) */
|
| 68 |
+
#cinema-screen-container { position: fixed; top: 90px; width: 100%; height: 52%; display: flex; justify-content: center; align-items: center; z-index: 20; }
|
| 69 |
+
#cinema-screen {
|
| 70 |
+
width: 80%;
|
| 71 |
+
height: 90%;
|
| 72 |
+
background: #050505;
|
| 73 |
+
border: 3px solid #111;
|
| 74 |
+
border-radius: 8px;
|
| 75 |
+
box-shadow: 0 0 100px rgba(255, 0, 0, 0.25), /* 屏幕对环境的红漫反射 */
|
| 76 |
+
inset 0 0 50px #000;
|
| 77 |
+
overflow: hidden;
|
| 78 |
+
position: relative;
|
| 79 |
+
background: radial-gradient(circle, #1a0000 0%, #000 80%);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
#actors-matrix { display: flex; justify-content: space-around; align-items: center; height: 60%; }
|
| 83 |
+
.actor { transition: 0.4s; }
|
| 84 |
+
.actor img { width: 260px; height: 260px; border-radius: 50%; border: 3px solid #1a1a1a; filter: grayscale(100%) opacity(0.3); transition: 0.5s; object-fit: cover; }
|
| 85 |
+
.actor.active img { filter: grayscale(0%) opacity(1) drop-shadow(0 0 20px #ff0000); transform: scale(1.05); }
|
| 86 |
+
#right.active img { filter: grayscale(0%) opacity(1) drop-shadow(0 0 20px #ff00ff); }
|
| 87 |
+
|
| 88 |
+
/* 字幕:加大电影质感 */
|
| 89 |
+
#subtitle { position: absolute; bottom: 20px; width: 80%; left: 10%; text-align: center; font-size: 2.2em; color: #fff; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; z-index: 30; }
|
| 90 |
+
|
| 91 |
+
/* 底部控制台:上移并压紧 */
|
| 92 |
+
#director-console {
|
| 93 |
+
position: fixed;
|
| 94 |
+
bottom: 75px;
|
| 95 |
+
width: 100%;
|
| 96 |
+
z-index: 100;
|
| 97 |
+
display: flex;
|
| 98 |
+
flex-direction: column;
|
| 99 |
+
align-items: center;
|
| 100 |
+
gap: 8px;
|
| 101 |
+
filter: drop-shadow(0 0 20px rgba(0,0,0,0.8));
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.mode-selector { display: flex; justify-content: center; gap: 20px; margin-bottom: 2px; }
|
| 105 |
+
.mode-btn { padding: 4px 12px; background: #111; border: 1px solid #333; color: #666; cursor: pointer; transition: 0.3s; border-radius: 4px; font-size: 0.8em; font-family: 'Courier New', monospace; }
|
| 106 |
+
.mode-btn.active#btn-normal { color: #00f2ff; border-color: #00f2ff; box-shadow: 0 0 10px #00f2ff; }
|
| 107 |
+
.mode-btn.active#btn-factory { color: #ff0000; border-color: #ff0000; box-shadow: 0 0 10px #ff0000; }
|
| 108 |
+
|
| 109 |
+
#director-params { display: none; opacity: 0; transition: opacity 0.3s ease; gap: 10px; padding: 5px 15px; background: rgba(10,10,10,0.9); border: 1px solid #222; border-radius: 4px; align-items: center; }
|
| 110 |
+
.param-item { display: flex; align-items: center; gap: 8px; color: #aaa; font-size: 0.8em; }
|
| 111 |
+
#model-select, #user-api-key { background: #000; border: 1px solid #444; color: #ff0000; padding: 4px; font-family: 'Courier New', monospace; outline: none; }
|
| 112 |
+
#user-api-key { width: 180px; }
|
| 113 |
+
|
| 114 |
+
.input-group { display: flex; justify-content: center; gap: 10px; }
|
| 115 |
+
#input-topic { width: 400px; padding: 10px; background: #111; border: 1px solid #ff0000; color: #0f0; text-align: center; font-family: 'Courier New', monospace; }
|
| 116 |
+
#action-btn { background: #ff0000; color: #fff; font-weight: bold; padding: 10px 30px; border: none; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; transition: 0.3s; }
|
| 117 |
+
#action-btn:hover { background: #b30000; transform: scale(1.05); }
|
| 118 |
+
#action-btn:disabled { background: #333; cursor: not-allowed; }
|
| 119 |
+
|
| 120 |
+
/* 底部版权与版本号 */
|
| 121 |
+
footer { position: fixed; bottom: 0; width: 100%; text-align: center; color: #333; font-size: 0.8em; padding: 10px; background: rgba(0,0,0,0.9); z-index: 1000; border-top: 1px solid #111;}
|
| 122 |
+
footer p { margin: 0; }
|
| 123 |
+
footer a { color: #333; text-decoration: none; }
|
| 124 |
+
footer a:hover { color: #ff0000; }
|