Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3274c7f
feat(audiochat): implement generic audio chat provider that schedules…
julien-nc Jul 3, 2025
b98e717
feat(audio-chat): record audio, store file, submit new fake message
julien-nc Jul 3, 2025
285b40d
feat(audio-chat): adjust UI to really submit, handle audio attachment…
julien-nc Jul 4, 2025
0c0ed92
feat(audio-chat): auto play new assistant audio messages
julien-nc Jul 4, 2025
2d53275
feat(audio-chat): generate openAPI specs
julien-nc Jul 7, 2025
3a706b8
feat(audio-chat): remove fallback task type, register provider only i…
julien-nc Jul 7, 2025
ffe2bcf
feat(audio-chat): filter out the audio chat task type in the assistan…
julien-nc Jul 7, 2025
7594d46
feat(audio-chat): implement ContextAgentAudioInteraction provider and…
julien-nc Jul 7, 2025
9a72e81
feat(audio-chat): add personal setting to toggle autoplay, fix person…
julien-nc Jul 8, 2025
bb6124e
feat(audio-chat): make sure attachments are always set in the entity
julien-nc Jul 8, 2025
e609d1d
feat(audio-chat): perform TTS for response after agency confirmation
julien-nc Jul 8, 2025
ba4ea60
feat(audio-chat): add support for optional remote_audio_id which we c…
julien-nc Jul 9, 2025
4cecfca
fix(chat): delete related tasks when deleting a session or a message,…
julien-nc Jul 10, 2025
cb6529a
feat(audio-chat): store and use potential remote_audio_expires_at
julien-nc Jul 10, 2025
6d85f2d
fix(audio-chat): prevent crash when trying to delete non existing task
julien-nc Jul 10, 2025
330296c
check if audio chat is available to show the record button, filter ou…
julien-nc Jul 11, 2025
4eb342f
clarify message mapper, use sessionId in deleteMessageById and getMes…
julien-nc Jul 11, 2025
891bb75
in regenerateForSession, delete task related with the deleted message
julien-nc Jul 11, 2025
003cdb3
rename initial state, mention integration_openai in comments, add mis…
julien-nc Jul 11, 2025
5cc7c59
fix typos
julien-nc Jul 11, 2025
7afb3e1
fix(audio-chat): update session title if the first message was audio,…
julien-nc Jul 11, 2025
77c2647
enh(audio-chat): add warning log if TTS of agency post-confirmation m…
julien-nc Jul 15, 2025
cf6648a
enh(audio-chat): add comments and adjust frontend error messages
julien-nc Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(audio-chat): record audio, store file, submit new fake message
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jul 15, 2025
commit b98e7179d10d7e198d4e31e14bc3c223848a1e5c
2 changes: 1 addition & 1 deletion lib/TaskProcessing/AudioToAudioChatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getId(): string {
}

public function getName(): string {
return $this->l->t('Generic Assistant');
return $this->l->t('Assistant fallback');
}

public function getTaskTypeId(): string {
Expand Down
31 changes: 27 additions & 4 deletions src/components/ChattyLLM/ChattyLLMInputForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
v-model:chat-content="chatContent"
class="session-area__input-area"
:loading="loading"
@submit="handleSubmit" />
@submit="handleSubmit"
@submit-audio="handleSubmitAudio" />
</NcAppContent>
<NcDialog :open="sessionIdToDelete !== null"
:name="t('assistant', 'Conversation deletion')"
Expand Down Expand Up @@ -415,10 +416,32 @@ export default {
return
}

console.debug('submit:', event)
const role = Roles.HUMAN
const content = this.chatContent.trim()
const timestamp = +new Date() / 1000 | 0
console.debug('[Assistant] submit text', content)

if (this.active === null) {
await this.newSession()
}

// sending a message if there are pending actions means the user rejected the actions
// so we can consider the agency confirmation answered
if (this.active.sessionAgencyPendingActions) {
this.active.agencyAnswered = true
}

this.messages.push({ role, content, timestamp })
this.chatContent = ''
this.scrollToBottom()
await this.newMessage(role, content, timestamp, this.active.id)
},

async handleSubmitAudio(fileId) {
console.debug('[Assistant] submit audio', fileId)
const role = Roles.HUMAN
const content = 'lala' + fileId
const timestamp = +new Date() / 1000 | 0

if (this.active === null) {
await this.newSession()
Expand Down Expand Up @@ -679,7 +702,7 @@ export default {
async pollGenerationTask(taskId, sessionId) {
return new Promise((resolve, reject) => {
this.pollMessageGenerationTimerId = setInterval(() => {
if (sessionId !== this.active.id) {
if (this.active === null || sessionId !== this.active.id) {
console.debug('Stop polling messages for session ' + sessionId + ' because it is not selected anymore')
clearInterval(this.pollMessageGenerationTimerId)
return
Expand Down Expand Up @@ -715,7 +738,7 @@ export default {
async pollTitleGenerationTask(taskId, sessionId) {
return new Promise((resolve, reject) => {
this.pollTitleGenerationTimerId = setInterval(() => {
if (sessionId !== this.active.id) {
if (this.active === null || sessionId !== this.active.id) {
console.debug('Stop polling title for session ' + sessionId + ' because it is not selected anymore')
clearInterval(this.pollTitleGenerationTimerId)
return
Expand Down
38 changes: 33 additions & 5 deletions src/components/ChattyLLM/InputArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@update:model-value="$emit('update:chatContent', $event)"
@submit="$emit('submit', $event)" />
<div class="input-area__button-box">
<NcButton class="input-area__button-box__button"
<NcButton v-if="chatContent"
class="input-area__button-box__button"
:aria-label="submitBtnAriaText"
:disabled="disabled || !chatContent.trim()"
variant="primary"
Expand All @@ -27,18 +28,28 @@
<SendIcon :size="20" />
</template>
</NcButton>
<AudioRecorderWrapper v-else
v-model:is-recording="isRecording"
:compact="true"
:disabled="disabled"
@new-recording="onNewRecording" />
</div>
</div>
</template>

<script>
import SendIcon from 'vue-material-design-icons/Send.vue'

import isMobile from '../../mixins/isMobile.js'

import NcButton from '@nextcloud/vue/components/NcButton'
import NcRichContenteditable from '@nextcloud/vue/components/NcRichContenteditable'

import AudioRecorderWrapper from '../fields/AudioRecorderWrapper.vue'

import isMobile from '../../mixins/isMobile.js'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'

/*
maxlength calculation (just a rough estimate):
- 1600 characters
Expand All @@ -50,8 +61,8 @@ export default {
name: 'InputArea',

components: {
AudioRecorderWrapper,
SendIcon,

NcButton,
NcRichContenteditable,
},
Expand Down Expand Up @@ -80,13 +91,18 @@ export default {
},
},

emits: ['update:chatContent', 'submit'],
emits: [
'update:chatContent',
'submit',
'submit-audio',
],

data: () => {
return {
placeholderText: t('assistant', 'Type a message…'),
thinkingText: t('assistant', 'Processing…'),
submitBtnAriaText: t('assistant', 'Submit'),
isRecording: false,
}
},

Expand All @@ -106,6 +122,18 @@ export default {
this.$refs.richContenteditable.focus()
})
},
onNewRecording(blob) {
const url = generateOcsUrl('/apps/assistant/api/v1/input-file')
const formData = new FormData()
formData.append('data', blob)
formData.append('filename', 'chat-input.mp3')
axios.post(url, formData).then(response => {
this.$emit('submit-audio', response.data.ocs.data.fileId)
}).catch(error => {
showError(t('assistant', 'Could not upload the recorded file'))
console.error(error)
})
},
},
}
</script>
Expand Down
36 changes: 32 additions & 4 deletions src/components/fields/AudioRecorderWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<template>
<div class="assistant-audio-recorder-wrapper">
<NcButton v-if="!isRecording"
ref="startRecordingButton"
:disabled="disabled"
:title="compact ? t('assistant', 'Start recording') : undefined"
@click="start">
<template #icon>
<MicrophoneOutlineIcon />
</template>
{{ t('assistant', 'Start recording') }}
<template v-if="!compact" #default>
{{ t('assistant', 'Start recording') }}
</template>
</NcButton>
<NcButton v-if="isRecording"
variant="error"
Expand Down Expand Up @@ -73,6 +75,10 @@ export default {
type: Boolean,
default: false,
},
compact: {
type: Boolean,
default: false,
},
},

emits: [
Expand Down Expand Up @@ -127,8 +133,30 @@ export default {
await register(await connect())
OCA.Assistant.encoderRegistered = true
}
const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
this.mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/wav' })
// Create new audio stream
try {
this.audioStream = await navigator.mediaDevices.getUserMedia({ audio: true, video: false })
} catch (exception) {
console.debug(exception)
this.killStreams()
if (exception.name === 'NotAllowedError') {
showError(t('assistant', 'Access to the microphone was denied'))
} else {
showError(t('assistant', 'Microphone either not available or disabled in settings'))
}
return
}

// Create a media recorder to capture the stream
try {
this.mediaRecorder = new MediaRecorder(this.audioStream, { mimeType: 'audio/wav' })
} catch (exception) {
console.debug(exception)
this.killStreams()
this.audioStream = null
showError(t('spreed', 'Error while recording audio'))
return
}

// Add event handler to onstop
this.mediaRecorder.onstop = this.generateFile
Expand Down