@ray-js/t-agent-plugin-aistream 0.2.4-beta-2 → 0.2.4-beta-4
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/dist/asr/AsrAgent.js +15 -5
- package/dist/utils/defaultMock.js +13 -14
- package/dist/utils/ttt.d.ts +1 -0
- package/dist/utils/ttt.js +1 -0
- package/package.json +2 -2
package/dist/asr/AsrAgent.js
CHANGED
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import "core-js/modules/es.json.stringify.js";
|
|
4
4
|
import "core-js/modules/es.promise.finally.js";
|
|
5
5
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
|
-
import { authorize, getCurrentHomeInfo, initAudioRecorder } from '../utils';
|
|
6
|
+
import { authorize, authorizeStatus, getCurrentHomeInfo, initAudioRecorder } from '../utils';
|
|
7
7
|
import { AIStreamAttributePayloadType, AIStreamAttributeType, ConnectClientType, ConnectState, ReceivedTextPacketType, SessionState } from '../AIStreamTypes';
|
|
8
8
|
import { DEFAULT_TOKEN_API, DEFAULT_TOKEN_API_VERSION, globalAIStreamClient } from '../global';
|
|
9
9
|
import { Logger, safeParseJSON } from '@ray-js/t-agent';
|
|
@@ -46,10 +46,20 @@ export class AsrAgent {
|
|
|
46
46
|
} = options;
|
|
47
47
|
const sampleRate = recordingOptions === null || recordingOptions === void 0 ? void 0 : recordingOptions.sampleRate;
|
|
48
48
|
// 如果需要提前启动,直接初始化和创建连接
|
|
49
|
-
this.createSession().then(session => session.ensureSession()).then(() =>
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
49
|
+
this.createSession().then(session => session.ensureSession()).then(() => authorizeStatus({
|
|
50
|
+
scope: 'scope.record'
|
|
51
|
+
}).then(() => true, () => false)).then(authorized => {
|
|
52
|
+
this.authorized = authorized;
|
|
53
|
+
if (!authorized) {
|
|
54
|
+
logger.log('AsrAgent EarlyStart: No record permission granted');
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
// 初始化录音
|
|
58
|
+
return initAudioRecorder(sampleRate ? {
|
|
59
|
+
sampleRate
|
|
60
|
+
} : {});
|
|
61
|
+
}).catch(error => {
|
|
62
|
+
logger.error('AsrAgent EarlyStart Failed to create ASR session:', error);
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
if (this.options.enableLog) {
|
|
@@ -4,7 +4,6 @@ import "core-js/modules/es.json.stringify.js";
|
|
|
4
4
|
import "core-js/modules/es.regexp.exec.js";
|
|
5
5
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
6
6
|
import "core-js/modules/esnext.iterator.filter.js";
|
|
7
|
-
import "core-js/modules/esnext.iterator.for-each.js";
|
|
8
7
|
import "core-js/modules/esnext.iterator.map.js";
|
|
9
8
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
10
9
|
import { mock } from './mock';
|
|
@@ -141,19 +140,19 @@ mock.hooks.hook('createSession', context => {
|
|
|
141
140
|
};
|
|
142
141
|
|
|
143
142
|
// 用于测试断开连接;
|
|
144
|
-
setTimeout(() => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}, 5000);
|
|
143
|
+
// setTimeout(() => {
|
|
144
|
+
// dispatch('onConnectStateChanged', {
|
|
145
|
+
// connectionId: '',
|
|
146
|
+
// connectState: ConnectState.DISCONNECTED,
|
|
147
|
+
// code: 200,
|
|
148
|
+
// });
|
|
149
|
+
// mock.data.set('currentConnection', null);
|
|
150
|
+
// const map: Map<string, MockSession> = mock.data.get('sessionMap');
|
|
151
|
+
// map.forEach(s => {
|
|
152
|
+
// s.closed = true;
|
|
153
|
+
// });
|
|
154
|
+
// mock.data.set('sessionMap', new Map());
|
|
155
|
+
// }, 5000);
|
|
157
156
|
|
|
158
157
|
// 用于测试断开会话
|
|
159
158
|
// setTimeout(() => {
|
package/dist/utils/ttt.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const getCurrentHomeInfo: (options?: Omit<GetCurrentHomeInfoParam
|
|
|
27
27
|
admin: boolean;
|
|
28
28
|
}>;
|
|
29
29
|
export declare const authorize: (options?: Omit<AuthorizeParams, "success" | "fail"> | undefined) => Promise<null>;
|
|
30
|
+
export declare const authorizeStatus: (options?: Omit<AuthorizeParams, "success" | "fail"> | undefined) => Promise<null>;
|
|
30
31
|
export declare const getAppInfo: (options?: Omit<GetAppInfoParams, "success" | "fail"> | undefined) => Promise<{
|
|
31
32
|
serverTimestamp: number;
|
|
32
33
|
appVersion: string;
|
package/dist/utils/ttt.js
CHANGED
|
@@ -18,6 +18,7 @@ export const createNativeEventManager = options => {
|
|
|
18
18
|
};
|
|
19
19
|
export const getCurrentHomeInfo = promisify(ty.home.getCurrentHomeInfo);
|
|
20
20
|
export const authorize = promisify(ty.authorize, true);
|
|
21
|
+
export const authorizeStatus = promisify(ty.authorizeStatus, true);
|
|
21
22
|
export const getAppInfo = promisify(ty.getAppInfo);
|
|
22
23
|
export const canIUseRouter = promisify(ty.canIUseRouter);
|
|
23
24
|
export const router = promisify(ty.router);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-plugin-aistream",
|
|
3
|
-
"version": "0.2.4-beta-
|
|
3
|
+
"version": "0.2.4-beta-4",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/url-parse": "^1.4.11"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "651120ff704ee5ff8430e4a3a5a741e1f913958a"
|
|
39
39
|
}
|