add suno extend (#102)
This commit is contained in:
1 parent
c1081d47e8
commit
b46a96e219
10 files changed
+233
-7
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"comment": "add suno extend",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "1348977728@qq.com",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -7,11 +7,16 @@
|
||||
<lyric-input v-if="config?.custom && !config.instrumental" class="mb-4" />
|
||||
<style-input v-if="config?.custom" class="mb-4" />
|
||||
<title-input v-if="config?.custom" class="mb-4" />
|
||||
<extend-from-input v-if="config?.action === 'extend'" class="mb-4" />
|
||||
<div class="actions">
|
||||
<el-button type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<el-button v-if="config?.action !== 'extend'" type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('suno.button.generate') }}
|
||||
</el-button>
|
||||
<el-button v-else type="primary" class="btn w-full" round @click="onGenerate">
|
||||
<font-awesome-icon icon="fa-solid fa-magic" class="mr-2" />
|
||||
{{ $t('suno.button.extend') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,6 +30,7 @@ import PromptInput from './config/PromptInput.vue';
|
||||
import LyricInput from './config/LyricInput.vue';
|
||||
import StyleInput from './config/StyleInput.vue';
|
||||
import TitleInput from './config/TitleInput.vue';
|
||||
import ExtendFromInput from './config/ExtendFromInput.vue';
|
||||
import InstrumentSwitch from './config/InstrumentSwitch.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
@@ -37,6 +43,7 @@ export default defineComponent({
|
||||
InstrumentSwitch,
|
||||
StyleInput,
|
||||
TitleInput,
|
||||
ExtendFromInput,
|
||||
FontAwesomeIcon,
|
||||
ElButton
|
||||
},
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<div class="field">
|
||||
<div class="box">
|
||||
<h2 class="title">{{ $t('suno.name.extend') }}</h2>
|
||||
<div class="input-wrapper">
|
||||
<el-input-number
|
||||
v-model="value"
|
||||
class="value"
|
||||
:min="0"
|
||||
:max="audio?.duration"
|
||||
:controls="false"
|
||||
:placeholder="$t('suno.placeholder.extend.continue_at')"
|
||||
@change="handleChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task">
|
||||
<div class="audio" @click="onClick(audio)">
|
||||
<div v-loading="!audio?.audio_url || !audio?.video_url" class="left">
|
||||
<el-image :src="audio?.image_url" class="cover" fit="cover" />
|
||||
<div
|
||||
v-if="
|
||||
audio?.audio_url &&
|
||||
$store.state?.suno?.audio?.id === audio.id &&
|
||||
$store.state?.suno?.audio?.state === 'playing'
|
||||
"
|
||||
class="overlay"
|
||||
@click="onPause(audio)"
|
||||
>
|
||||
<el-icon><video-pause /></el-icon>
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
audio?.audio_url &&
|
||||
($store.state?.suno?.audio?.id !== audio.id ||
|
||||
($store.state?.suno?.audio?.id === audio.id && $store.state?.suno?.audio?.state === 'paused'))
|
||||
"
|
||||
class="overlay"
|
||||
@click="onPlay(audio)"
|
||||
>
|
||||
<el-icon><video-play /></el-icon>
|
||||
</div>
|
||||
<div v-if="audio?.duration" class="duration">
|
||||
{{ useFormatDuring(audio?.duration) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="info">
|
||||
<h2 class="title">{{ audio?.title }}</h2>
|
||||
<p class="style">{{ audio?.style }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { useFormatDuring } from '@/utils/number';
|
||||
import { ISunoAudio } from '@/models';
|
||||
import { ElImage, ElIcon, ElInputNumber } from 'element-plus';
|
||||
import { VideoPlay, VideoPause } from '@element-plus/icons-vue';
|
||||
|
||||
export const DEFAULT_LYRIC = '';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ExtendFromInput',
|
||||
components: {
|
||||
ElImage,
|
||||
ElIcon,
|
||||
ElInputNumber,
|
||||
VideoPlay,
|
||||
VideoPause
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
// @ts-ignore
|
||||
audio() {
|
||||
// @ts-ignore
|
||||
return this.$store.state.suno?.config?.audio;
|
||||
},
|
||||
value: {
|
||||
get() {
|
||||
return this.$store.state.suno?.config?.continue_at;
|
||||
},
|
||||
set(val: string) {
|
||||
console.debug('set continue_at', val);
|
||||
this.$store.commit('suno/setConfig', {
|
||||
...this.$store.state.suno?.config,
|
||||
continue_at: val ? parseInt(val) : undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.value) {
|
||||
this.value = undefined;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange(val: number) {
|
||||
if (val < 0) {
|
||||
this.value = 0;
|
||||
// @ts-ignore
|
||||
} else if (val > this.audio?.duration) {
|
||||
this.value = this.audio?.duration;
|
||||
} else {
|
||||
this.value = val;
|
||||
}
|
||||
},
|
||||
useFormatDuring,
|
||||
onPlay(audio: ISunoAudio) {
|
||||
this.$store.dispatch('suno/setAudio', {
|
||||
...this.$store.state.suno.audio,
|
||||
...audio,
|
||||
state: 'playing'
|
||||
});
|
||||
console.log('on play');
|
||||
},
|
||||
onPause(audio: ISunoAudio) {
|
||||
this.$store.dispatch('suno/setAudio', {
|
||||
...this.$store.state.suno.audio,
|
||||
...audio,
|
||||
state: 'paused'
|
||||
});
|
||||
console.log('on pause');
|
||||
},
|
||||
onClick(audio: ISunoAudio) {
|
||||
if (this.$store.state?.suno?.audio?.id !== audio.id) {
|
||||
this.onPlay({
|
||||
...audio,
|
||||
progress: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.field {
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between; // 添加这行
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.input-wrapper {
|
||||
width: 150px; // 根据需要调整宽度
|
||||
margin-left: 30px; // 增加左边距
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -5,6 +5,7 @@
|
||||
<info-icon :content="$t('suno.description.lyrics')" class="info" />
|
||||
</div>
|
||||
<el-input
|
||||
v-if="config?.action !== 'extend'"
|
||||
v-model="lyric"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
@@ -13,6 +14,16 @@
|
||||
:maxlength="3000"
|
||||
show-word-limit
|
||||
/>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="lyric"
|
||||
:rows="3"
|
||||
type="textarea"
|
||||
class="lyrics"
|
||||
:placeholder="$t('suno.placeholder.extend.lyrics')"
|
||||
:maxlength="3000"
|
||||
show-word-limit
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<p class="style">{{ audio?.style }}</p>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-button size="small" round @click="onExtend($event, audio)">{{ $t('suno.button.extend') }}</el-button>
|
||||
<el-tooltip effect="dark" :content="$t('suno.button.download')" placement="top">
|
||||
<font-awesome-icon
|
||||
v-if="audio?.audio_url"
|
||||
@@ -59,7 +60,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useFormatDuring } from '@/utils/number';
|
||||
import { ISunoAudio, ISunoTask } from '@/models';
|
||||
import { ElImage, ElIcon, ElTooltip } from 'element-plus';
|
||||
import { ElImage, ElIcon, ElTooltip, ElButton } from 'element-plus';
|
||||
import { VideoPlay, VideoPause } from '@element-plus/icons-vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
|
||||
@@ -69,6 +70,7 @@ export default defineComponent({
|
||||
ElImage,
|
||||
ElIcon,
|
||||
ElTooltip,
|
||||
ElButton,
|
||||
FontAwesomeIcon,
|
||||
VideoPlay,
|
||||
VideoPause
|
||||
@@ -130,6 +132,23 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
},
|
||||
onExtend(event: MouseEvent, audio: ISunoAudio) {
|
||||
event.stopPropagation();
|
||||
console.log('on extend');
|
||||
// download url here
|
||||
console.debug('set config', audio);
|
||||
this.$store.commit('suno/setConfig', {
|
||||
...this.$store.state.suno?.config,
|
||||
model: audio.model,
|
||||
custom: true,
|
||||
instrumental: false,
|
||||
style: audio.style,
|
||||
action: 'extend',
|
||||
audio: audio,
|
||||
audio_id: audio.id,
|
||||
continue_at: audio.duration
|
||||
});
|
||||
},
|
||||
onDownload(event: MouseEvent, audioUrl: string) {
|
||||
event.stopPropagation();
|
||||
console.log('on download');
|
||||
@@ -223,16 +242,20 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
.right {
|
||||
width: 60px;
|
||||
width: 120px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-content: flex-end;
|
||||
padding-right: 1px;
|
||||
.icon {
|
||||
display: block;
|
||||
z-index: 100;
|
||||
cursor: pointer;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.el-button {
|
||||
margin-right: 15px; /* Add margin to the right of the button */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"button.extend": {
|
||||
"message": "继续生成",
|
||||
"description": "继续生成按钮文本"
|
||||
},
|
||||
"button.download": {
|
||||
"message": "下载",
|
||||
"description": "下载按钮文本"
|
||||
@@ -35,6 +39,10 @@
|
||||
"message": "歌曲描述",
|
||||
"description": "内容输入的提示"
|
||||
},
|
||||
"name.extend": {
|
||||
"message": "扩展歌曲来自",
|
||||
"description": "内容输入的提示"
|
||||
},
|
||||
"name.lyrics": {
|
||||
"message": "歌词内容",
|
||||
"description": "歌词内容输入的提示"
|
||||
@@ -91,6 +99,14 @@
|
||||
"message": "请输入歌词...",
|
||||
"description": "填充级别的占位符"
|
||||
},
|
||||
"placeholder.extend.lyrics": {
|
||||
"message": "请输入需要扩展的歌词...",
|
||||
"description": "填充级别的占位符"
|
||||
},
|
||||
"placeholder.extend.continue_at": {
|
||||
"message": "请输入需要从歌曲哪秒进行扩展...",
|
||||
"description": "填充级别的占位符"
|
||||
},
|
||||
"placeholder.style": {
|
||||
"message": "请输入要生成的歌曲风格的提示词,例如 acoustic pop",
|
||||
"description": "提示字段中的占位文本"
|
||||
|
||||
@@ -63,6 +63,9 @@ export interface ISunoConfig {
|
||||
title?: string;
|
||||
style?: string;
|
||||
action?: string;
|
||||
audio?: ISunoAudio | undefined;
|
||||
audio_id?: string;
|
||||
continue_at: number;
|
||||
}
|
||||
export interface ISunoAudioRequest {
|
||||
action?: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IApplication, ICredential, IService, ISunoAudio, Status } from '@/models';
|
||||
import { ISunoConfig, ISunoTask, Song } from '@/models';
|
||||
import { ISunoConfig, ISunoTask } from '@/models';
|
||||
|
||||
export interface ISunoState {
|
||||
application: IApplication | undefined;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export default ['suno.config', 'suno.credential', 'suno.application', 'suno.tasks'];
|
||||
export default ['suno.credential', 'suno.application', 'suno.tasks'];
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ISunoState } from './models';
|
||||
import { Status, Song } from '@/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default (): ISunoState => {
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user