-
Notifications
You must be signed in to change notification settings - Fork 81
feat: add quickapp api using coze in websocket realtime asr scene #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tnaught
wants to merge
1
commit into
coze-dev:main
Choose a base branch
from
tnaught:feat/quickapp-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@coze/quickapp-api/feat-quickapp-api_2025-08-11-09-23.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@coze/quickapp-api", | ||
"comment": "add quickapp-api for websocket and asr and quickapp-examples", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@coze/quickapp-api", | ||
"email": "[email protected]" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 快应用构建输出 | ||
/build/ | ||
/dist/ | ||
|
||
# 依赖目录 | ||
/node_modules/ | ||
|
||
# 日志文件 | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# 编辑器目录和文件 | ||
.idea/ | ||
.vscode/ | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# 系统文件 | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# 配置文件 | ||
src/config.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Coze.js 快应用示例 - 语音转写 | ||
|
||
这是一个使用Coze.js在快应用平台上实现实时语音转写功能的示例项目。该示例展示了如何使用WebSocket连接进行实时语音转写,包括开始、暂停、恢复和停止录音等功能。 | ||
|
||
## 功能特点 | ||
|
||
- 实时语音转写 | ||
- 录音状态管理(开始、暂停、恢复、停止) | ||
- 错误处理和状态指示 | ||
- 简洁直观的用户界面 | ||
|
||
## 项目结构 | ||
|
||
``` | ||
├── src/ | ||
│ ├── app.ux # 应用入口文件 | ||
│ ├── manifest.json # 应用配置文件 | ||
│ ├── common/ # 公共资源 | ||
│ │ ├── styles/ # 样式文件 | ||
│ │ │ └── common.css # 公共样式 | ||
│ │ ├── js/ # JavaScript文件 | ||
│ │ │ └── use-transcription.js # 语音转写功能模块 | ||
│ │ ├── images/ # 图片资源 | ||
│ │ └── logo.png # 应用图标 | ||
│ └── pages/ # 页面文件 | ||
│ ├── index/ # 首页 | ||
│ │ └── index.ux # 首页组件 | ||
│ └── transcription/ # 语音转写页面 | ||
│ └── index.ux # 语音转写组件 | ||
└── package.json # 项目配置文件 | ||
``` | ||
|
||
## 使用方法 | ||
|
||
### 前提条件 | ||
|
||
- 安装Node.js和npm | ||
- 安装快应用开发工具(hap-toolkit) | ||
|
||
### 安装依赖 | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
### 配置API令牌 | ||
|
||
在使用前,请复制`src/config.example.js`文件为`src/config.js`,并替换`YOUR_API_TOKEN_HERE`为您的实际API令牌: | ||
|
||
```javascript | ||
export default { | ||
// 语音转写API令牌 | ||
transcriptionToken: 'YOUR_API_TOKEN_HERE', | ||
|
||
// 调试模式 | ||
debug: true | ||
}; | ||
``` | ||
|
||
### 运行项目 | ||
|
||
```bash | ||
npm start | ||
``` | ||
|
||
### 构建项目 | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
## 技术栈 | ||
|
||
- 快应用框架 | ||
- Coze.js WebSocket API | ||
- 快应用录音API(@system.record) | ||
|
||
## 注意事项 | ||
|
||
- 该示例需要麦克风权限才能正常工作 | ||
- WebSocket连接需要网络权限 | ||
- 在真机上测试时,请确保设备支持快应用框架 | ||
|
||
## 许可证 | ||
|
||
MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { defineConfig } = require('@coze-infra/eslint-config'); | ||
|
||
module.exports = defineConfig({ | ||
packageRoot: __dirname, | ||
preset: 'node', | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-require-imports': 'off', | ||
'@typescript-eslint/no-magic-numbers': 'off', | ||
'@typescript-eslint/naming-convention': 'off', | ||
'@typescript-eslint/no-useless-constructor': 'off', | ||
'@typescript-eslint/no-shadow': 'off', | ||
'security/detect-object-injection': 'off', | ||
'no-inner-declarations': 'off', | ||
'no-var': 'off', | ||
}, | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Reconsider disabling critical linting rules
Disabling important TypeScript and security rules reduces code quality and safety. Consider:
@typescript-eslint/no-explicit-any
enabled to maintain type safetysecurity/detect-object-injection
enabled to prevent potential security vulnerabilitiesno-var
enabled asconst
/let
are preferred in modern JavaScriptFor example code that genuinely needs exceptions, use inline eslint-disable comments with explanations rather than blanket disabling.