Skip to content

Commit c1ac7f4

Browse files
tnaughttianqin
authored andcommitted
feat: add quickapp api using coze in websocket realtime asr scene
1 parent 3068887 commit c1ac7f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+24928
-12
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze/quickapp-api",
5+
"comment": "add quickapp-api for websocket and asr and quickapp-examples",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze/quickapp-api",
10+
"email": "[email protected]"
11+
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 3306 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 快应用构建输出
2+
/build/
3+
/dist/
4+
5+
# 依赖目录
6+
/node_modules/
7+
8+
# 日志文件
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
13+
# 编辑器目录和文件
14+
.idea/
15+
.vscode/
16+
*.suo
17+
*.ntvs*
18+
*.njsproj
19+
*.sln
20+
*.sw?
21+
22+
# 系统文件
23+
.DS_Store
24+
Thumbs.db
25+
26+
# 配置文件
27+
src/config.js
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Coze.js 快应用示例 - 语音转写
2+
3+
这是一个使用Coze.js在快应用平台上实现实时语音转写功能的示例项目。该示例展示了如何使用WebSocket连接进行实时语音转写,包括开始、暂停、恢复和停止录音等功能。
4+
5+
## 功能特点
6+
7+
- 实时语音转写
8+
- 录音状态管理(开始、暂停、恢复、停止)
9+
- 错误处理和状态指示
10+
- 简洁直观的用户界面
11+
12+
## 项目结构
13+
14+
```
15+
├── src/
16+
│ ├── app.ux # 应用入口文件
17+
│ ├── manifest.json # 应用配置文件
18+
│ ├── common/ # 公共资源
19+
│ │ ├── styles/ # 样式文件
20+
│ │ │ └── common.css # 公共样式
21+
│ │ ├── js/ # JavaScript文件
22+
│ │ │ └── use-transcription.js # 语音转写功能模块
23+
│ │ ├── images/ # 图片资源
24+
│ │ └── logo.png # 应用图标
25+
│ └── pages/ # 页面文件
26+
│ ├── index/ # 首页
27+
│ │ └── index.ux # 首页组件
28+
│ └── transcription/ # 语音转写页面
29+
│ └── index.ux # 语音转写组件
30+
└── package.json # 项目配置文件
31+
```
32+
33+
## 使用方法
34+
35+
### 前提条件
36+
37+
- 安装Node.js和npm
38+
- 安装快应用开发工具(hap-toolkit)
39+
40+
### 安装依赖
41+
42+
```bash
43+
npm install
44+
```
45+
46+
### 配置API令牌
47+
48+
在使用前,请复制`src/config.example.js`文件为`src/config.js`,并替换`YOUR_API_TOKEN_HERE`为您的实际API令牌:
49+
50+
```javascript
51+
export default {
52+
// 语音转写API令牌
53+
transcriptionToken: 'YOUR_API_TOKEN_HERE',
54+
55+
// 调试模式
56+
debug: true
57+
};
58+
```
59+
60+
### 运行项目
61+
62+
```bash
63+
npm start
64+
```
65+
66+
### 构建项目
67+
68+
```bash
69+
npm run build
70+
```
71+
72+
## 技术栈
73+
74+
- 快应用框架
75+
- Coze.js WebSocket API
76+
- 快应用录音API(@system.record)
77+
78+
## 注意事项
79+
80+
- 该示例需要麦克风权限才能正常工作
81+
- WebSocket连接需要网络权限
82+
- 在真机上测试时,请确保设备支持快应用框架
83+
84+
## 许可证
85+
86+
MIT
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { defineConfig } = require('@coze-infra/eslint-config');
2+
3+
module.exports = defineConfig({
4+
packageRoot: __dirname,
5+
preset: 'node',
6+
rules: {
7+
'@typescript-eslint/no-explicit-any': 'off',
8+
'@typescript-eslint/no-unused-vars': 'off',
9+
'@typescript-eslint/no-require-imports': 'off',
10+
'@typescript-eslint/no-magic-numbers': 'off',
11+
'@typescript-eslint/naming-convention': 'off',
12+
'@typescript-eslint/no-useless-constructor': 'off',
13+
'@typescript-eslint/no-shadow': 'off',
14+
'security/detect-object-injection': 'off',
15+
'no-inner-declarations': 'off',
16+
'no-var': 'off',
17+
},
18+
});

0 commit comments

Comments
 (0)