@vnejs/compatibility.text-with-audio.voice 0.2.4 → 0.2.5
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/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +4 -7
package/dist/index.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ export declare class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEv
|
|
|
12
12
|
subscribe: () => void;
|
|
13
13
|
init: () => Promise<import("@vnejs/shared").EmitResults<"vne:scenario:line_load_reg">> | undefined;
|
|
14
14
|
onLineLoad: ({ args, priority }?: LineLoadHandlerArg) => Promise<import("@vnejs/shared").EmitResults<"vne:audio:media_load">> | undefined;
|
|
15
|
-
onTextEmitBefore: () => Promise<void>;
|
|
16
15
|
onTextEmit: (payload?: TextEmitPayload) => Promise<void>;
|
|
17
16
|
onInteractStarted: () => Promise<void>;
|
|
18
17
|
onSettingsChanged: ({ name }: SettingsChangedResult) => false | Promise<void>;
|
|
19
18
|
onStateClear: () => Promise<void>;
|
|
20
|
-
|
|
19
|
+
onTextEmitBefore: () => Promise<void>;
|
|
21
20
|
getDefaultState: () => CompatState;
|
|
21
|
+
stopVoice: () => Promise<void>;
|
|
22
22
|
getVoiceFromPayload: ({ args, isExtend, texts }?: TextEmitPayload) => string | undefined;
|
|
23
23
|
getVoiceArg: (args?: Record<string, unknown>) => string | undefined;
|
|
24
24
|
getVoiceVolume: () => number;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore {
|
|
|
22
22
|
const name = resolveVoicePath(voice, this.shared.voiceLang);
|
|
23
23
|
return this.emit(this.EVENTS.AUDIO.MEDIA_LOAD, { layer: this.CONST.VOICE.LAYER, name, priority });
|
|
24
24
|
};
|
|
25
|
-
onTextEmitBefore = () => this.stopVoice();
|
|
26
25
|
onTextEmit = async (payload = {}) => {
|
|
27
26
|
await this.stopVoice();
|
|
28
27
|
const voice = this.getVoiceFromPayload(payload);
|
|
@@ -42,6 +41,8 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore {
|
|
|
42
41
|
onInteractStarted = () => this.stopVoice();
|
|
43
42
|
onSettingsChanged = ({ name }) => name === VOICE_SETTINGS_KEYS.LANG && this.stopVoice();
|
|
44
43
|
onStateClear = () => this.stopVoice();
|
|
44
|
+
onTextEmitBefore = () => this.stopVoice();
|
|
45
|
+
getDefaultState = () => ({ currentName: "" });
|
|
45
46
|
stopVoice = async () => {
|
|
46
47
|
const { currentName } = this.state;
|
|
47
48
|
if (!currentName)
|
|
@@ -49,7 +50,6 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore {
|
|
|
49
50
|
await this.emit(this.EVENTS.AUDIO.STOP, { layer: this.CONST.VOICE.LAYER, name: currentName, duration: 0 });
|
|
50
51
|
this.state.currentName = "";
|
|
51
52
|
};
|
|
52
|
-
getDefaultState = () => ({ currentName: "" });
|
|
53
53
|
getVoiceFromPayload = ({ args = {}, isExtend = false, texts = [] } = {}) => {
|
|
54
54
|
const lineArgs = isExtend && texts.length ? (texts[texts.length - 1]?.args ?? {}) : args;
|
|
55
55
|
return this.getVoiceArg(lineArgs);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -37,8 +37,6 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEvents, Pl
|
|
|
37
37
|
return this.emit(this.EVENTS.AUDIO.MEDIA_LOAD, { layer: this.CONST.VOICE.LAYER, name, priority });
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
onTextEmitBefore = () => this.stopVoice();
|
|
41
|
-
|
|
42
40
|
onTextEmit = async (payload: TextEmitPayload = {}) => {
|
|
43
41
|
await this.stopVoice();
|
|
44
42
|
|
|
@@ -66,6 +64,10 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEvents, Pl
|
|
|
66
64
|
|
|
67
65
|
onStateClear = () => this.stopVoice();
|
|
68
66
|
|
|
67
|
+
onTextEmitBefore = () => this.stopVoice();
|
|
68
|
+
|
|
69
|
+
getDefaultState = (): CompatState => ({ currentName: "" });
|
|
70
|
+
|
|
69
71
|
stopVoice = async () => {
|
|
70
72
|
const { currentName } = this.state;
|
|
71
73
|
|
|
@@ -75,21 +77,16 @@ export class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEvents, Pl
|
|
|
75
77
|
|
|
76
78
|
this.state.currentName = "";
|
|
77
79
|
};
|
|
78
|
-
|
|
79
|
-
getDefaultState = (): CompatState => ({ currentName: "" });
|
|
80
|
-
|
|
81
80
|
getVoiceFromPayload = ({ args = {}, isExtend = false, texts = [] }: TextEmitPayload = {}) => {
|
|
82
81
|
const lineArgs = isExtend && texts.length ? (texts[texts.length - 1]?.args ?? {}) : args;
|
|
83
82
|
|
|
84
83
|
return this.getVoiceArg(lineArgs);
|
|
85
84
|
};
|
|
86
|
-
|
|
87
85
|
getVoiceArg = (args: Record<string, unknown> = {}) => {
|
|
88
86
|
const voice = args.voice;
|
|
89
87
|
|
|
90
88
|
return typeof voice === "string" && voice ? voice : undefined;
|
|
91
89
|
};
|
|
92
|
-
|
|
93
90
|
getVoiceVolume = () => (this.shared.settings[VOICE_SETTINGS_KEYS.VOLUME] as number | undefined) ?? 100;
|
|
94
91
|
}
|
|
95
92
|
|