✨ 功能特性
- 完整的语音对话功能
- 长按交互设计,用户体验佳
- 无任何外部依赖,极轻量
- 即开即用,无需编译
- 支持自定义样式和配置
- 完全隐私,数据不上传
🚀 快速开始
最简单的方式,在你的 HTML 中添加 iframe:
<iframe
src="./portable-dist/index.html"
width="450"
height="600"
frameborder="0"
allow="microphone; speaker"
style="border-radius: 12px; border: none;">
</iframe>
就这么简单!语音助手会自动在右下角显示。
📦 文件结构
portable-dist/
├── index.html # 主页面(即开即用)
├── app.js # 应用逻辑(无依赖)
├── README.md # 详细文档
└── examples/ # 更多示例
⚙️ 配置 API 密钥
第一次使用时,点击右下角 ⚙️ 按钮配置:
- 访问 https://open.bigmodel.cn
- 注册并登录账号
- 创建 API 密钥
- 复制密钥到应用中
💡 提示: API 密钥会自动保存到本地浏览器,下次无需重新输入。
💻 不同场景的集成方式
方式 1: 固定位置浮窗
<!-- 右下角固定 -->
<div style="position: fixed;
bottom: 20px;
right: 20px;
z-index: 999;">
<iframe src="./portable-dist/index.html"
width="450" height="600"
allow="microphone; speaker">
</iframe>
</div>
方式 2: 侧边栏内嵌
<div style="display: grid;
grid-template-columns: 1fr 450px;">
<main>主内容</main>
<aside>
<iframe src="./portable-dist/index.html"
width="100%" height="100%"
allow="microphone; speaker">
</iframe>
</aside>
</div>
方式 3: 模态对话框
<div id="modal"
style="position: fixed;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
z-index: 999;">
<iframe src="./portable-dist/index.html"
width="450" height="600"
allow="microphone; speaker">
</iframe>
</div>
方式 4: 页面底部栏
<div style="position: fixed;
bottom: 0; left: 0; right: 0;
height: 600px;
z-index: 999;">
<iframe src="./portable-dist/index.html"
width="100%" height="100%"
allow="microphone; speaker">
</iframe>
</div>
🔗 iframe 属性说明
allow="microphone; speaker" - 允许访问麦克风和扬声器
frameborder="0" - 隐藏边框
width / height - 推荐 450×600 像素
⚠️ 重要: 如果在 HTTPS 网站上使用,源 URL 也必须是 HTTPS。本地 http://localhost 可以正常工作。