feat: Support stt mode auto send message
--story=1017616 --user=刘瑞斌 【应用】语音输入支持自动发送 https://www.tapd.cn/57709429/s/1641715
This commit is contained in:
parent
301c60ee92
commit
c307f6b0af
18
apps/application/migrations/0023_application_stt_autosend.py
Normal file
18
apps/application/migrations/0023_application_stt_autosend.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.15 on 2025-01-06 10:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('application', '0022_application_tts_autoplay'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='application',
|
||||||
|
name='stt_autosend',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='自动发送'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -66,6 +66,7 @@ class Application(AppModelMixin):
|
|||||||
stt_model_enable = models.BooleanField(verbose_name="语音识别模型是否启用", default=False)
|
stt_model_enable = models.BooleanField(verbose_name="语音识别模型是否启用", default=False)
|
||||||
tts_type = models.CharField(verbose_name="语音播放类型", max_length=20, default="BROWSER")
|
tts_type = models.CharField(verbose_name="语音播放类型", max_length=20, default="BROWSER")
|
||||||
tts_autoplay = models.BooleanField(verbose_name="自动播放", default=False)
|
tts_autoplay = models.BooleanField(verbose_name="自动播放", default=False)
|
||||||
|
stt_autosend = models.BooleanField(verbose_name="自动发送", default=False)
|
||||||
clean_time = models.IntegerField(verbose_name="清理时间", default=180)
|
clean_time = models.IntegerField(verbose_name="清理时间", default=180)
|
||||||
file_upload_enable = models.BooleanField(verbose_name="文件上传是否启用", default=False)
|
file_upload_enable = models.BooleanField(verbose_name="文件上传是否启用", default=False)
|
||||||
file_upload_setting = models.JSONField(verbose_name="文件上传相关设置", default=dict)
|
file_upload_setting = models.JSONField(verbose_name="文件上传相关设置", default=dict)
|
||||||
|
|||||||
@ -1009,7 +1009,7 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
|
update_keys = ['name', 'desc', 'model_id', 'multiple_rounds_dialogue', 'prologue', 'status',
|
||||||
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
|
'dataset_setting', 'model_setting', 'problem_optimization', 'dialogue_number',
|
||||||
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',
|
'stt_model_id', 'tts_model_id', 'tts_model_enable', 'stt_model_enable', 'tts_type',
|
||||||
'tts_autoplay', 'file_upload_enable', 'file_upload_setting',
|
'tts_autoplay', 'stt_autosend', 'file_upload_enable', 'file_upload_setting',
|
||||||
'api_key_is_active', 'icon', 'work_flow', 'model_params_setting', 'tts_model_params_setting',
|
'api_key_is_active', 'icon', 'work_flow', 'model_params_setting', 'tts_model_params_setting',
|
||||||
'problem_optimization_prompt', 'clean_time']
|
'problem_optimization_prompt', 'clean_time']
|
||||||
for update_key in update_keys:
|
for update_key in update_keys:
|
||||||
@ -1075,6 +1075,8 @@ class ApplicationSerializer(serializers.Serializer):
|
|||||||
instance['tts_type'] = node_data['tts_type']
|
instance['tts_type'] = node_data['tts_type']
|
||||||
if 'tts_autoplay' in node_data:
|
if 'tts_autoplay' in node_data:
|
||||||
instance['tts_autoplay'] = node_data['tts_autoplay']
|
instance['tts_autoplay'] = node_data['tts_autoplay']
|
||||||
|
if 'stt_autosend' in node_data:
|
||||||
|
instance['stt_autosend'] = node_data['stt_autosend']
|
||||||
if 'tts_model_params_setting' in node_data:
|
if 'tts_model_params_setting' in node_data:
|
||||||
instance['tts_model_params_setting'] = node_data['tts_model_params_setting']
|
instance['tts_model_params_setting'] = node_data['tts_model_params_setting']
|
||||||
if 'file_upload_enable' in node_data:
|
if 'file_upload_enable' in node_data:
|
||||||
|
|||||||
@ -22,6 +22,7 @@ interface ApplicationFormType {
|
|||||||
tts_model_enable?: boolean
|
tts_model_enable?: boolean
|
||||||
tts_type?: string
|
tts_type?: string
|
||||||
tts_autoplay?: boolean
|
tts_autoplay?: boolean
|
||||||
|
stt_autosend?: boolean
|
||||||
}
|
}
|
||||||
interface Chunk {
|
interface Chunk {
|
||||||
real_node_id: string
|
real_node_id: string
|
||||||
|
|||||||
@ -175,7 +175,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||||
import Recorder from 'recorder-core'
|
import Recorder from 'recorder-core'
|
||||||
import applicationApi from '@/api/application'
|
import applicationApi from '@/api/application'
|
||||||
import { MsgAlert } from '@/utils/message'
|
import { MsgAlert } from '@/utils/message'
|
||||||
@ -254,7 +254,7 @@ const getAcceptList = () => {
|
|||||||
if (video) {
|
if (video) {
|
||||||
accepts = [...accepts, ...videoExtensions]
|
accepts = [...accepts, ...videoExtensions]
|
||||||
}
|
}
|
||||||
// console.log(accepts)
|
|
||||||
if (accepts.length === 0) {
|
if (accepts.length === 0) {
|
||||||
return '.请在文件上传配置中选择文件类型'
|
return '.请在文件上传配置中选择文件类型'
|
||||||
}
|
}
|
||||||
@ -462,7 +462,12 @@ const uploadRecording = async (audioBlob: Blob) => {
|
|||||||
recorderLoading.value = false
|
recorderLoading.value = false
|
||||||
mediaRecorder.value.close()
|
mediaRecorder.value.close()
|
||||||
inputValue.value = typeof response.data === 'string' ? response.data : ''
|
inputValue.value = typeof response.data === 'string' ? response.data : ''
|
||||||
// chatMessage(null, res.data)
|
// 自动发送
|
||||||
|
if (props.applicationDetails.stt_autosend) {
|
||||||
|
nextTick(() => {
|
||||||
|
autoSendMessage()
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
recorderLoading.value = false
|
recorderLoading.value = false
|
||||||
@ -486,12 +491,7 @@ const handleTimeChange = () => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendChatHandle(event?: any) {
|
function autoSendMessage() {
|
||||||
if (!event?.ctrlKey) {
|
|
||||||
// 如果没有按下组合键ctrl,则会阻止默认事件
|
|
||||||
event?.preventDefault()
|
|
||||||
if (!isDisabledChart.value && !props.loading && !event?.isComposing) {
|
|
||||||
if (inputValue.value.trim()) {
|
|
||||||
props.sendMessage(inputValue.value, {
|
props.sendMessage(inputValue.value, {
|
||||||
image_list: uploadImageList.value,
|
image_list: uploadImageList.value,
|
||||||
document_list: uploadDocumentList.value,
|
document_list: uploadDocumentList.value,
|
||||||
@ -504,6 +504,15 @@ function sendChatHandle(event?: any) {
|
|||||||
uploadAudioList.value = []
|
uploadAudioList.value = []
|
||||||
uploadVideoList.value = []
|
uploadVideoList.value = []
|
||||||
quickInputRef.value.textareaStyle.height = '45px'
|
quickInputRef.value.textareaStyle.height = '45px'
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendChatHandle(event?: any) {
|
||||||
|
if (!event?.ctrlKey) {
|
||||||
|
// 如果没有按下组合键ctrl,则会阻止默认事件
|
||||||
|
event?.preventDefault()
|
||||||
|
if (!isDisabledChart.value && !props.loading && !event?.isComposing) {
|
||||||
|
if (inputValue.value.trim()) {
|
||||||
|
autoSendMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -319,22 +319,17 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<div class="flex align-center">
|
|
||||||
<span class="mr-4">语音输入</span>
|
<span class="mr-4">语音输入</span>
|
||||||
<!-- <el-tooltip
|
<div class="flex">
|
||||||
effect="dark"
|
<el-checkbox v-model="applicationForm.stt_autosend">自动发送</el-checkbox>
|
||||||
content="开启后,需要设定语音转文本模型,语音输入完成后会转化为文字直接发送提问"
|
|
||||||
placement="right"
|
|
||||||
>
|
|
||||||
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
|
|
||||||
</el-tooltip> -->
|
|
||||||
</div>
|
|
||||||
<el-switch
|
<el-switch
|
||||||
|
class="ml-8"
|
||||||
size="small"
|
size="small"
|
||||||
v-model="applicationForm.stt_model_enable"
|
v-model="applicationForm.stt_model_enable"
|
||||||
@change="sttModelEnableChange"
|
@change="sttModelEnableChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-select
|
<el-select
|
||||||
v-show="applicationForm.stt_model_enable"
|
v-show="applicationForm.stt_model_enable"
|
||||||
|
|||||||
@ -84,22 +84,17 @@
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<div class="flex align-center">
|
|
||||||
<span class="mr-4">语音输入</span>
|
<span class="mr-4">语音输入</span>
|
||||||
<!-- <el-tooltip
|
<div class="flex">
|
||||||
effect="dark"
|
<el-checkbox v-model="form_data.stt_autosend">自动发送</el-checkbox>
|
||||||
content="开启后,需要设定语音转文本模型,语音输入完成后会转化为文字直接发送提问"
|
|
||||||
placement="right"
|
|
||||||
>
|
|
||||||
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
|
|
||||||
</el-tooltip> -->
|
|
||||||
</div>
|
|
||||||
<el-switch
|
<el-switch
|
||||||
|
class="ml-8"
|
||||||
size="small"
|
size="small"
|
||||||
v-model="form_data.stt_model_enable"
|
v-model="form_data.stt_model_enable"
|
||||||
@change="sttModelEnableChange"
|
@change="sttModelEnableChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-select
|
<el-select
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user