Initial commit
This commit is contained in:
165
developer-front/public/docs/capabilities.md
Normal file
165
developer-front/public/docs/capabilities.md
Normal file
@@ -0,0 +1,165 @@
|
||||
# 能力中心
|
||||
|
||||
语音、转写、翻译、AI 助手的端到端工作流与常见场景模板。
|
||||
|
||||
## 语音识别
|
||||
|
||||
实时语音识别,支持多种语言和方言。
|
||||
|
||||
### 基础使用
|
||||
|
||||
```javascript
|
||||
// 启动语音识别
|
||||
const recognition = glasses.voice.startRecognition({
|
||||
language: 'zh-CN',
|
||||
continuous: true,
|
||||
interimResults: true
|
||||
})
|
||||
|
||||
recognition.on('result', (text) => {
|
||||
console.log('识别结果:', text)
|
||||
})
|
||||
|
||||
recognition.on('error', (error) => {
|
||||
console.error('识别错误:', error)
|
||||
})
|
||||
```
|
||||
|
||||
### 语言支持
|
||||
|
||||
- 中文(普通话、粤语、四川话等)
|
||||
- 英语
|
||||
- 日语
|
||||
- 韩语
|
||||
- 更多语言持续更新
|
||||
|
||||
## 转写服务
|
||||
|
||||
将音频文件转换为文本。
|
||||
|
||||
### 上传音频
|
||||
|
||||
```javascript
|
||||
const transcription = await glasses.transcription.transcribe({
|
||||
audioUrl: 'https://example.com/audio.mp3',
|
||||
language: 'zh-CN',
|
||||
format: 'text'
|
||||
})
|
||||
|
||||
console.log('转写结果:', transcription.text)
|
||||
```
|
||||
|
||||
### 批量转写
|
||||
|
||||
```javascript
|
||||
const tasks = await glasses.transcription.batchTranscribe([
|
||||
{ audioUrl: 'audio1.mp3', language: 'zh-CN' },
|
||||
{ audioUrl: 'audio2.mp3', language: 'en-US' }
|
||||
])
|
||||
|
||||
tasks.forEach(task => {
|
||||
task.on('complete', (result) => {
|
||||
console.log('转写完成:', result.text)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## 翻译服务
|
||||
|
||||
多语言实时翻译。
|
||||
|
||||
### 文本翻译
|
||||
|
||||
```javascript
|
||||
const translation = await glasses.translation.translate({
|
||||
text: 'Hello World',
|
||||
from: 'en',
|
||||
to: 'zh'
|
||||
})
|
||||
|
||||
console.log('翻译结果:', translation.text)
|
||||
```
|
||||
|
||||
### 语音翻译
|
||||
|
||||
```javascript
|
||||
const translation = glasses.translation.translateSpeech({
|
||||
audioUrl: 'audio.mp3',
|
||||
from: 'en',
|
||||
to: 'zh'
|
||||
})
|
||||
|
||||
translation.on('complete', (result) => {
|
||||
console.log('翻译结果:', result.text)
|
||||
console.log('音频URL:', result.audioUrl)
|
||||
})
|
||||
```
|
||||
|
||||
## AI 助手
|
||||
|
||||
智能对话助手,支持上下文理解。
|
||||
|
||||
### 对话
|
||||
|
||||
```javascript
|
||||
const conversation = glasses.ai.createConversation({
|
||||
model: 'gpt-4',
|
||||
systemPrompt: '你是一个智能助手'
|
||||
})
|
||||
|
||||
const response = await conversation.chat('你好')
|
||||
console.log('回复:', response.text)
|
||||
```
|
||||
|
||||
### 流式响应
|
||||
|
||||
```javascript
|
||||
const stream = await conversation.chatStream('请介绍一下智能眼镜')
|
||||
|
||||
stream.on('data', (chunk) => {
|
||||
process.stdout.write(chunk.text)
|
||||
})
|
||||
|
||||
stream.on('end', () => {
|
||||
console.log('\n对话完成')
|
||||
})
|
||||
```
|
||||
|
||||
## 场景模板
|
||||
|
||||
### 会议记录
|
||||
|
||||
```javascript
|
||||
const meeting = glasses.scenarios.createMeeting({
|
||||
participants: ['user1', 'user2'],
|
||||
language: 'zh-CN'
|
||||
})
|
||||
|
||||
meeting.on('transcription', (text) => {
|
||||
// 实时转写
|
||||
console.log('会议内容:', text)
|
||||
})
|
||||
|
||||
meeting.on('summary', (summary) => {
|
||||
// 会议摘要
|
||||
console.log('会议摘要:', summary)
|
||||
})
|
||||
```
|
||||
|
||||
### 实时翻译
|
||||
|
||||
```javascript
|
||||
const translator = glasses.scenarios.createTranslator({
|
||||
from: 'en',
|
||||
to: 'zh'
|
||||
})
|
||||
|
||||
translator.on('translation', (result) => {
|
||||
// 显示翻译结果
|
||||
glasses.display.showText({
|
||||
text: result.text,
|
||||
position: { x: 100, y: 200 }
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user