@coze/realtime-api 0.0.4 → 1.0.0-alpha.7419f0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Coze Realtime API
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@coze/realtime-api.svg)](https://www.npmjs.com/package/@coze/realtime-api)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@coze/realtime-api.svg)](https://www.npmjs.com/package/@coze/realtime-api)
5
+ [![license](https://img.shields.io/npm/l/@coze/realtime-api.svg)](https://github.com/coze-dev/coze-js/blob/main/LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
7
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/coze-dev/coze-js/pulls)
8
+
3
9
  A powerful real-time communication SDK for voice interactions with Coze AI bots.
4
10
 
5
11
  ## Features
@@ -39,6 +45,11 @@ import { RealtimeClient, EventNames, RealtimeUtils } from "@coze/realtime-api";
39
45
  const client = new RealtimeClient({
40
46
  baseURL: "https://api.coze.cn",
41
47
  accessToken: "your_access_token",
48
+ // or
49
+ // accessToken: async () => {
50
+ // // refresh token if expired
51
+ // return 'your_oauth_token';
52
+ // },
42
53
  botId: "your_bot_id",
43
54
  voiceId: "your_voice_id", // Optional: Specify voice ID
44
55
  conversationId: "conversation_id", // Optional: For conversation continuity
@@ -52,8 +63,8 @@ const client = new RealtimeClient({
52
63
  // Essential Setup
53
64
  async function initializeVoiceChat() {
54
65
  // 1. Verify device permissions
55
- const hasPermission = await RealtimeUtils.checkPermission();
56
- if (!hasPermission) {
66
+ const result = await RealtimeUtils.checkDevicePermission();
67
+ if (!result.audio) {
57
68
  throw new Error("Microphone access required");
58
69
  }
59
70