Skip to content

Commit 97dad3c

Browse files
committed
Merge branch 'add-frontend-speech-recognition' of https://github.com/devforth/adminforth-agent into add-frontend-speech-recognition
2 parents 55e85e4 + 968d61f commit 97dad3c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

custom/ChatSurface.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@
118118
transition: `transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out`
119119
}"
120120
>
121-
<div class="w-full border rounded-lg pb-8 dark:bg-gray-700">
121+
<div
122+
class="w-full border rounded-lg pb-8 dark:bg-gray-700"
123+
:class="agentStore.isAudioChatMode ? 'border-none mt-8' : 'border'"
124+
>
122125
<textarea
126+
v-if="!agentStore.isAudioChatMode"
123127
v-model="agentStore.userMessageInput"
124128
ref="textInput"
125129
@input="autoResize"
@@ -325,6 +329,7 @@ function selectMode(modeName: string) {
325329
}
326330
327331
async function sendMessage() {
332+
if (agentStore.isAudioChatMode) return;
328333
isModeMenuOpen.value = false;
329334
await agentStore.sendMessage();
330335
autoResize();

custom/speech_recognition_frontend/MicrophoneButon.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
class="absolute bottom-2 h-9 bg-lightPrimary dark:bg-darkPrimary
44
hover:opacity-90 rounded-full flex items-center justify-center
55
transition-all duration-300 ease-in-out overflow-hidden"
6-
:class="[isAudioChatMode ? 'w-32 px-2': 'w-9', !agentStore.isAudioChatMode ? 'right-16': 'right-4']"
6+
:class="[isAudioChatMode ? 'w-32 px-2': 'w-9', !agentStore.isAudioChatMode ? 'right-16': 'right-1/2 translate-x-1/2']"
77
@click="toggleChatMode"
88
>
99
<div class="w-5 h-5 flex items-center justify-center">
1010
<div v-if="!showButtonSpinner" class="flex justify-evenly items-center gap-[0.1rem]">
1111
<AudioLines :showAnimation="showAnimation" :isRecording="isAudioChatMode" />
1212
</div>
13+
<div v-else-if="showStopGenerationMessage" class="flex items-center justify-center gap-2 text-white text-sm">
14+
<span class="w-3 h-3 bg-white rounded-sm" />
15+
{{ $t('Stop') }}
16+
</div>
1317
<Spinner v-else class="w-4 h-4 text-lightButtonsText dark:text-darkButtonsText fill-lightButtonsBackground dark:fill-darkPrimary" />
1418
</div>
1519

@@ -44,6 +48,7 @@ agentStore.registerOnBeforeChatCloseCallback(async () => {
4448
4549
const showAnimation = ref(false);
4650
const showButtonSpinner = ref(false);
51+
const showStopGenerationMessage = ref(false);
4752
const hideAnimationDebounced = debounce(() => {
4853
showAnimation.value = false;
4954
}, 100);
@@ -55,9 +60,11 @@ const isAudioChatMode = computed(() => agentStore.isAudioChatMode);
5560
5661
watch(isStreamingResponse, (newVal) => {
5762
if(!newVal) {
63+
showStopGenerationMessage.value = false;
5864
showButtonSpinner.value = false;
5965
} else {
6066
showButtonSpinner.value = true;
67+
showStopGenerationMessage.value = true;
6168
}
6269
})
6370
@@ -92,6 +99,7 @@ function resetAll() {
9299
stopGenerationAndAudio();
93100
showAnimation.value = false;
94101
showButtonSpinner.value = false;
102+
showStopGenerationMessage.value = false;
95103
hideAnimationDebounced.cancel();
96104
sendUserRecordDebounced.cancel();
97105
}

0 commit comments

Comments
 (0)