@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/index.js CHANGED
@@ -2027,12 +2027,14 @@ function SpeechToText({
2027
2027
  IdleAudioIcon,
2028
2028
  handleReplaceInput,
2029
2029
  setIsAudioRecording,
2030
+ onSendAudio,
2030
2031
  ...props
2031
2032
  }) {
2032
2033
  const [isRecording, setIsRecording] = (0, import_react8.useState)(false);
2033
2034
  const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
2034
2035
  const [mediaRecorder, setMediaRecorder] = (0, import_react8.useState)(null);
2035
2036
  const [audioBlob, setAudioBlob] = (0, import_react8.useState)(null);
2037
+ const [speechResult, setSpeechResult] = (0, import_react8.useState)(null);
2036
2038
  const startRecording = async () => {
2037
2039
  setIsRecording(true);
2038
2040
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
@@ -2056,6 +2058,7 @@ function SpeechToText({
2056
2058
  const transcription = await speechToText(audioBase64);
2057
2059
  if (transcription) {
2058
2060
  handleReplaceInput(transcription);
2061
+ setSpeechResult(transcription);
2059
2062
  setIsLoading(false);
2060
2063
  }
2061
2064
  } catch (error) {
@@ -2073,6 +2076,14 @@ function SpeechToText({
2073
2076
  (0, import_react8.useEffect)(() => {
2074
2077
  isLoading || isRecording ? setIsAudioRecording(true) : setIsAudioRecording(false);
2075
2078
  }, [isRecording, isLoading]);
2079
+ (0, import_react8.useEffect)(() => {
2080
+ if (speechResult) {
2081
+ setTimeout(() => {
2082
+ onSendAudio && onSendAudio();
2083
+ setSpeechResult(null);
2084
+ }, 200);
2085
+ }
2086
+ }, [speechResult]);
2076
2087
  const handleRecordButtonClick = () => {
2077
2088
  if (isRecording) {
2078
2089
  stopRecording();
@@ -3145,8 +3156,10 @@ var AssistantInput = React34.forwardRef(
3145
3156
  handleInputChange,
3146
3157
  isMessageStreaming,
3147
3158
  speechToTextComponent,
3159
+ placeholders,
3148
3160
  ...props
3149
3161
  }, ref) => {
3162
+ const placeholder = placeholders ? isMessageStreaming ? placeholders[0] : placeholders[1] : isMessageStreaming ? "Processing..." : "Type your message here...";
3150
3163
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
3151
3164
  "form",
3152
3165
  {
@@ -3162,7 +3175,7 @@ var AssistantInput = React34.forwardRef(
3162
3175
  disabled: isButtonDisabled,
3163
3176
  value: input,
3164
3177
  onChange: handleInputChange,
3165
- placeholder: isMessageStreaming ? "Procesando..." : "Escribe tu mensaje aqu\xED...",
3178
+ placeholder,
3166
3179
  className: cn(
3167
3180
  "flex-1 text-sm p-3 rounded-lg focus:outline-none w-full",
3168
3181
  "border border-input bg-background text-foreground",