-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Support stt mode auto send message #1977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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='自动发送'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,21 +319,16 @@ | |
| <el-form-item> | ||
| <template #label> | ||
| <div class="flex-between"> | ||
| <div class="flex align-center"> | ||
| <span class="mr-4">语音输入</span> | ||
| <!-- <el-tooltip | ||
| effect="dark" | ||
| content="开启后,需要设定语音转文本模型,语音输入完成后会转化为文字直接发送提问" | ||
| placement="right" | ||
| > | ||
| <AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon> | ||
| </el-tooltip> --> | ||
| <span class="mr-4">语音输入</span> | ||
| <div class="flex"> | ||
| <el-checkbox v-model="applicationForm.stt_autosend">自动发送</el-checkbox> | ||
| <el-switch | ||
| class="ml-8" | ||
| size="small" | ||
| v-model="applicationForm.stt_model_enable" | ||
| @change="sttModelEnableChange" | ||
| /> | ||
| </div> | ||
| <el-switch | ||
| size="small" | ||
| v-model="applicationForm.stt_model_enable" | ||
| @change="sttModelEnableChange" | ||
| /> | ||
| </div> | ||
| </template> | ||
| <el-select | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code has several issues:
Here’s a suggested optimized version of the code: <template>
<el-form-item :label-width="formLabelWidth">
<div class="flex-between">
<span class="mr-4">语音输入</span>
<div class="flex">
<el-checkbox v-model="applicationForm.stt_autosend">自动发送</el-checkbox>
<el-switch
class="ml-8"
size="small"
v-model="applicationForm.stt_model_enable"
@change="sttModelEnableChange"
></el-switch>
</div>
</div>
<!-- Other form-items... -->
</el-form-item>
</template>
<script>
export default {
// ...
};
</script>
<style scoped>
.flex-between {
display: flex;
justify-content: space-between;
}
.el-checkbox {
margin-right: 8px; /* Adjusted margin */
}
</style>Optimization Suggested Points:
By applying these changes, the code becomes more uniform, easier to read, and maintains consistency in its styling. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,21 +84,16 @@ | |
| <el-form-item> | ||
| <template #label> | ||
| <div class="flex-between"> | ||
| <div class="flex align-center"> | ||
| <span class="mr-4">语音输入</span> | ||
| <!-- <el-tooltip | ||
| effect="dark" | ||
| content="开启后,需要设定语音转文本模型,语音输入完成后会转化为文字直接发送提问" | ||
| placement="right" | ||
| > | ||
| <AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon> | ||
| </el-tooltip> --> | ||
| <span class="mr-4">语音输入</span> | ||
| <div class="flex"> | ||
| <el-checkbox v-model="form_data.stt_autosend">自动发送</el-checkbox> | ||
| <el-switch | ||
| class="ml-8" | ||
| size="small" | ||
| v-model="form_data.stt_model_enable" | ||
| @change="sttModelEnableChange" | ||
| /> | ||
| </div> | ||
| <el-switch | ||
| size="small" | ||
| v-model="form_data.stt_model_enable" | ||
| @change="sttModelEnableChange" | ||
| /> | ||
| </div> | ||
| </template> | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code you provided has a few issues:
Here's an optimized version of the code: <template>
<el-form-item>
<template #label>
<div class="flex-between">
<p>
<span class="mr-4">语音输入</span>
<!-- Add description here if needed -->
</p>
<div class="flex align-center">
<el-checkbox v-model="form_data.stt_autosend">{{ $t('common.auto_send') }}</el-checkbox>
<el-switch
class="ml-8"
style="--el-slider-button-size: 0;"
:active-text="$t('settings.enable_stt')"
size="small"
v-model="form_data.stt_model_enable"
@change="sttModelEnableChange"
/>
</div>
</div>
</template>
<!-- Rest of form item elements -->
</el-form-item>
</template>
<script>
export default {
data() {
return {
form_data: { ... } // Initialize your form_data object here
};
},
methods: {
sttModelEnableChange(enabled) {
this.$emit('update:model-value', { ...this.form_data, stt_enabled: enabled });
this.handleSttInput(enabled);
},
handleSttInput(autostart) {
// Implement logic to enable/disable automatic start based on autostart value
}
}
};
</script>Key Changes:
These changes should resolve most issues while maintaining clear presentation and functionality. Make sure to adjust the labels and placeholder text according to your application requirements. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code seems to be a Vue.js component that handles file uploads, real-time recording of voice messages, and sending text-based messages with attachments. Here are some observations, potential issues, and optimization suggestions:
Observations:
nextTickutility is used multiple times, which can optimize rendering by ensuring that DOM updates occur after certain operations have been completed.autoSendMessagefunction is called when the user hits the Enter key (after disabling the default behavior), but it could benefit from more robust logic, such as checking if the message is not empty before proceeding.inputValue,uploadImageList, etc., especially during automated sends. This might lead to unexpected state management.RecordPlayer.vue,quick-input-ref) are properly imported and referenced.Potential Issues:
inputValue,upload*List) and computed properties, which can make it harder to debug and maintain.MsgAlertutility.Optimization Suggestions:
RecordPlayer.vueis complex or heavy, consider lazy loading it only when needed.Overall, the code appears functional and complete, but refining its structure, performance, and clarity will enhance its sustainability and reliability. Let me know if you need further assistance!