@amaster.ai/components-templates 1.4.10 → 1.4.11

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amaster-react-project",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --force",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@a2a-js/sdk": "^0.3.7",
20
- "@amaster.ai/client": "1.1.0-beta.55",
21
- "@amaster.ai/vite-plugins": "1.1.0-beta.55",
20
+ "@amaster.ai/client": "1.1.0-beta.56",
21
+ "@amaster.ai/vite-plugins": "1.1.0-beta.56",
22
22
  "@fontsource-variable/inter": "^5.2.8",
23
23
  "@fortawesome/fontawesome-free": "^6.1.1",
24
24
  "@hookform/resolvers": "^5.2.2",
@@ -29,7 +29,7 @@ const VoiceInputButton: React.FC<{
29
29
  onClick={stoppable ? stop : status === "idle" ? start : undefined}
30
30
  disabled={finalDisabled}
31
31
  className={cn("h-8 w-8 rounded-lg cursor-pointer text-xs ", {
32
- "bg-gradient-to-r from-blue-500 to-blue-800 hover:from-blue-400 hover:to-blue-600 text-white":
32
+ "bg-gradient-to-r from-blue-500 to-blue-800 hover:from-blue-400 hover:to-blue-600 text-white animate-pulse":
33
33
  running,
34
34
  "w-auto": statusText,
35
35
  })}
@@ -8,7 +8,10 @@ type Status =
8
8
  | "idle"
9
9
  | "starting"
10
10
  | "ready"
11
+ | "speaking"
12
+ | "recording"
11
13
  | "stopping"
14
+ | "ended"
12
15
  | "error"
13
16
  | "closed";
14
17
 
@@ -27,10 +30,10 @@ export const useVoiceInput = ({
27
30
  const AsrClientRef = useRef<ASRClient | null>(null);
28
31
  const runningRef = useRef(false);
29
32
  const stoppable = useMemo(() => {
30
- return ["ready"].includes(status);
33
+ return ["ready", "speaking", "recording"].includes(status);
31
34
  }, [status]);
32
35
  const disabledClick = useMemo(() => {
33
- return ["starting", "stopping", "closed", "error"].includes(
36
+ return ["starting", "ended", "closed", "error", "stopping"].includes(
34
37
  status,
35
38
  );
36
39
  }, [status]);
@@ -50,6 +53,13 @@ export const useVoiceInput = ({
50
53
  onReady() {
51
54
  setStatus("ready");
52
55
  },
56
+ onSpeechStart() {
57
+ setStatus((status) => (status !== "stopping" ? "recording" : status));
58
+ },
59
+
60
+ onSpeechEnd() {
61
+ setStatus((status) => (status !== "stopping" ? "recording" : status));
62
+ },
53
63
  onTranscript(text, isFinal) {
54
64
  if (!isFinal) {
55
65
  temp = text;
@@ -60,21 +70,10 @@ export const useVoiceInput = ({
60
70
  onChange(result);
61
71
  }
62
72
  },
63
- onAudioBufferCommitted() {
64
- console.debug("音频缓冲区已提交");
73
+ onSessionFinished() {
74
+ setStatus("ended");
65
75
  },
66
- onError(error) {
67
- if (error.message === "NO_DEVICES_AVAILABLE") {
68
- toast({
69
- title: getText().voiceInputError.microphoneAccessDenied,
70
- variant: "destructive",
71
- });
72
- } else {
73
- toast({
74
- title: getText().voiceInputError.unknownError,
75
- variant: "destructive",
76
- });
77
- }
76
+ onError() {
78
77
  reset();
79
78
  },
80
79
  onClose() {
@@ -90,7 +89,7 @@ export const useVoiceInput = ({
90
89
  AsrClientRef.current = asrClient;
91
90
  } catch (error) {
92
91
  const message = error.message;
93
- const showError = (title: string) => toast({ title });
92
+ const showError = (title: string) => toast({title})
94
93
  if (message.includes("Microphone access denied")) {
95
94
  showError(getText().voiceInputError.microphoneAccessDenied);
96
95
  } else if (message.includes("No speech detected")) {
@@ -148,12 +147,15 @@ export const useVoiceInput = ({
148
147
  }
149
148
  }, [status]);
150
149
 
151
- const statusTextMap: Record<Status, string> = {
150
+ const statusTextMap = {
152
151
  // idle: t('translation:voiceInputStatus.idle'),
153
152
  idle: "",
154
153
  starting: getText().voiceInputStatus.starting,
155
154
  ready: getText().voiceInputStatus.ready,
155
+ speaking: getText().voiceInputStatus.speaking,
156
+ recording: getText().voiceInputStatus.recording,
156
157
  stopping: getText().voiceInputStatus.stopping,
158
+ ended: getText().voiceInputStatus.ended,
157
159
  error: getText().voiceInputStatus.error,
158
160
  closed: getText().voiceInputStatus.closed,
159
161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/components-templates",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "Amaster component templates collection",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/cli",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "Amaster CLI tool for component templates",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",