@alquimia-ai/ui 1.5.0 → 1.5.2
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/components/organisms/index.d.mts +3 -1
- package/dist/components/organisms/index.d.ts +3 -1
- package/dist/components/organisms/index.js +14 -1
- package/dist/components/organisms/index.js.map +1 -1
- package/dist/components/organisms/index.mjs +14 -1
- package/dist/components/organisms/index.mjs.map +1 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -107,12 +107,14 @@ function SpeechToText({
|
|
|
107
107
|
IdleAudioIcon,
|
|
108
108
|
handleReplaceInput,
|
|
109
109
|
setIsAudioRecording,
|
|
110
|
+
onSendAudio,
|
|
110
111
|
...props
|
|
111
112
|
}) {
|
|
112
113
|
const [isRecording, setIsRecording] = useState2(false);
|
|
113
114
|
const [isLoading, setIsLoading] = useState2(false);
|
|
114
115
|
const [mediaRecorder, setMediaRecorder] = useState2(null);
|
|
115
116
|
const [audioBlob, setAudioBlob] = useState2(null);
|
|
117
|
+
const [speechResult, setSpeechResult] = useState2(null);
|
|
116
118
|
const startRecording = async () => {
|
|
117
119
|
setIsRecording(true);
|
|
118
120
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
@@ -136,6 +138,7 @@ function SpeechToText({
|
|
|
136
138
|
const transcription = await speechToText(audioBase64);
|
|
137
139
|
if (transcription) {
|
|
138
140
|
handleReplaceInput(transcription);
|
|
141
|
+
setSpeechResult(transcription);
|
|
139
142
|
setIsLoading(false);
|
|
140
143
|
}
|
|
141
144
|
} catch (error) {
|
|
@@ -153,6 +156,14 @@ function SpeechToText({
|
|
|
153
156
|
useEffect2(() => {
|
|
154
157
|
isLoading || isRecording ? setIsAudioRecording(true) : setIsAudioRecording(false);
|
|
155
158
|
}, [isRecording, isLoading]);
|
|
159
|
+
useEffect2(() => {
|
|
160
|
+
if (speechResult) {
|
|
161
|
+
setTimeout(() => {
|
|
162
|
+
onSendAudio && onSendAudio();
|
|
163
|
+
setSpeechResult(null);
|
|
164
|
+
}, 200);
|
|
165
|
+
}
|
|
166
|
+
}, [speechResult]);
|
|
156
167
|
const handleRecordButtonClick = () => {
|
|
157
168
|
if (isRecording) {
|
|
158
169
|
stopRecording();
|
|
@@ -2735,8 +2746,10 @@ var AssistantInput = React34.forwardRef(
|
|
|
2735
2746
|
handleInputChange,
|
|
2736
2747
|
isMessageStreaming,
|
|
2737
2748
|
speechToTextComponent,
|
|
2749
|
+
placeholders,
|
|
2738
2750
|
...props
|
|
2739
2751
|
}, ref) => {
|
|
2752
|
+
const placeholder = placeholders ? isMessageStreaming ? placeholders[0] : placeholders[1] : isMessageStreaming ? "Processing..." : "Type your message here...";
|
|
2740
2753
|
return /* @__PURE__ */ jsxs20(
|
|
2741
2754
|
"form",
|
|
2742
2755
|
{
|
|
@@ -2752,7 +2765,7 @@ var AssistantInput = React34.forwardRef(
|
|
|
2752
2765
|
disabled: isButtonDisabled,
|
|
2753
2766
|
value: input,
|
|
2754
2767
|
onChange: handleInputChange,
|
|
2755
|
-
placeholder
|
|
2768
|
+
placeholder,
|
|
2756
2769
|
className: cn(
|
|
2757
2770
|
"flex-1 text-sm p-3 rounded-lg focus:outline-none w-full",
|
|
2758
2771
|
"border border-input bg-background text-foreground",
|