python+qwen3-omni-flash-realtime+live2d实现网页中二次元数字人实时音视频ai聊天助手千问qwen示例代码

代码语言:python

所属分类:其他

代码描述:python+qwen3-omni-flash-realtime+live2d实现网页中二次元数字人实时音视频ai聊天助手千问qwen示例代码,一个二次元的ai数字人与你视频聊天,她能看到你,支持语音打断,采用python内嵌html的单个python代码实现。

代码标签: python qwen3-omni-flash-realtime live2d 网页 卡通 二次元

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
# -- coding: utf-8 --
import uvicorn
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.responses import HTMLResponse
import asyncio
import json
import websockets
import logging

# ================= 配置区 =================
# ⚠️ 请务必替换为您的阿里云 DashScope API Key
API_KEY = "sk-"  # 替换为你的真实 Key

# 阿里云实时API地址
DASHSCOPE_URL = "wss://dashscope.aliyuncs.com/api-ws/v1/realtime?model=qwen3-omni-flash-realtime"

app = FastAPI()

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("Live2DBot")

# ================= 前端 HTML/JS/CSS =================
html_content = """
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Live2D AI 酱 (口型修复版)</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body { margin: 0; overflow: hidden; background-color: #f0f4f8; font-family: 'Microsoft YaHei', sans-serif; }
        
        #canvas-container { 
            width: 100vw; height: 100vh; display: block; 
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        }
        
        /* UI 悬浮层 */
        #ui-layer {
            position: absolute; top: 20px; left: 20px; z-index: 100;
            background: rgba(255, 255, 255, 0.9);
            padding: 15px 25px; border-radius: 20px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            backdrop-filter: blur(5px);
        }
        
        h1 { margin: 0 0 5px 0; font-size: 20px; color: #ff7eb0; }
        #status { font-size: 13px; color: #888; margin-bottom: 10px; }

        button {
            padding: 8px 20px; border-radius: 20px; border: none;
            font-size: 14px; cursor: pointer; transition: all 0.3s;
            color: white; font-weight: bold;
        }
        #btn-start { background: linear-gradient(90deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%); box-shadow: 0 2px 8px rgba(255, 15.........完整代码请登录后点击上方下载按钮下载查看

网友评论0