Xin Zhang
commited on
Commit
·
8ba9c84
1
Parent(s):
f71be4e
[fix]: remove frontend ref audio.
Browse files- frontend/src/assets/ref_audios/bys_ref.wav +0 -3
- frontend/src/assets/ref_audios/cove_ref.wav +0 -3
- frontend/src/assets/ref_audios/doubao_ref.wav +0 -3
- frontend/src/assets/ref_audios/ellen_ref.wav +0 -3
- frontend/src/assets/ref_audios/juniper_ref.wav +0 -3
- frontend/src/assets/ref_audios/luoxiang_ref.wav +0 -3
- frontend/src/assets/ref_audios/mabaoguo_ref.wav +0 -3
- frontend/src/assets/ref_audios/maple_ref.wav +0 -3
- frontend/src/assets/ref_audios/mayun_ref.wav +0 -3
- frontend/src/assets/ref_audios/shenyi_ref.wav +0 -3
- frontend/src/assets/ref_audios/trump_ref.wav +0 -3
- frontend/src/assets/ref_audios/yangmi_ref.wav +0 -3
- frontend/src/assets/ref_audios/zhoujielun_ref.wav +0 -3
- frontend/src/views/Welcome/index.vue +131 -9
frontend/src/assets/ref_audios/bys_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:742e4310a8635740e8cfee99b10c14c40acb189e1985283991447d87631685ed
|
| 3 |
-
size 418604
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/cove_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2879a08a134b812245cf67afb4cb1a330d4fc59b43bb68a2fe20efbab10df759
|
| 3 |
-
size 479404
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/doubao_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a5c8581b8b7a857f5ecbdce36a558b12f7eefc36dbbc96e7cf7a99615627f6e6
|
| 3 |
-
size 844878
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/ellen_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:692552ea483214b0b08e66f6ff684696ecd9fc96da40ee6925415359bdff83d0
|
| 3 |
-
size 599084
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/juniper_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b59af2dc6f7163084b9d72a7ceb60fe03789c096129d1007231c9514c5df7fd7
|
| 3 |
-
size 314924
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/luoxiang_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f9c271fe6e3590741a38b21bdd4462bd87a8a4c4711013e90071d761a41f18c3
|
| 3 |
-
size 316204
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/mabaoguo_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:65f76b00d87c2598f6a2ba59716cf58af6e2f6682ae79a90496771be91f3515f
|
| 3 |
-
size 476238
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/maple_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:da780b24686c3b065a594d6d35380a99bac519608e4c93753acf165b68041e50
|
| 3 |
-
size 422444
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/mayun_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3e55c3989e5f4910a039d2e3c5d769b30129a4d7c0c97f0c6a905009382a9456
|
| 3 |
-
size 630274
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/shenyi_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:4a43131724444f933a800971ce50515d91d31e333287ad40e10a7d4a4e1eaef0
|
| 3 |
-
size 661518
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/trump_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:20735d336d61194773c248982937872515589f0987efb2827f6addbc391faa11
|
| 3 |
-
size 427244
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/yangmi_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:7b37d93794958b71184b48c6358eadcdc7cc782805761ac867c2c7bd32081426
|
| 3 |
-
size 865038
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/assets/ref_audios/zhoujielun_ref.wav
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:584e95f902b3b244c8ee46eee54f4238d0286d3d9687b753f738b353b7267c09
|
| 3 |
-
size 475278
|
|
|
|
|
|
|
|
|
|
|
|
frontend/src/views/Welcome/index.vue
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
|
| 3 |
import router from "@/router.ts";
|
| 4 |
import { useSettingsStore } from "@/stores/config.ts";
|
| 5 |
-
import { onMounted, ref, reactive, computed, h } from "vue";
|
| 6 |
import { Modal } from 'ant-design-vue';
|
| 7 |
-
import { SoundTwoTone } from "@ant-design/icons-vue";
|
| 8 |
import axios from "axios";
|
| 9 |
import PromptText from "./Components/PromptText.vue";
|
| 10 |
|
|
@@ -202,11 +202,82 @@ const togglePopover = (item: string) => {
|
|
| 202 |
const popoverVisible = ref<boolean>(false);
|
| 203 |
const promptModelOpen = ref<boolean>(false);
|
| 204 |
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
console.log('Playing reference audio for role:', id);
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
};
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
</script>
|
| 212 |
|
|
@@ -280,14 +351,29 @@ const playRefAudio = (id: string) => {
|
|
| 280 |
<a-radio-group size="large" v-model:value="role">
|
| 281 |
<a-radio v-for="r in filteredRoles" :style="radioStyle" :value="r['id']" :key="r['id']">
|
| 282 |
<div style="display: flex; justify-content: space-between; align-items: center; width:450px;">
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
</a-radio>
|
| 290 |
</a-radio-group>
|
|
|
|
| 291 |
</div>
|
| 292 |
</div>
|
| 293 |
</a-modal>
|
|
@@ -309,6 +395,42 @@ const playRefAudio = (id: string) => {
|
|
| 309 |
}
|
| 310 |
}
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
.btn-groups {
|
| 313 |
margin-top: 36px;
|
| 314 |
display: flex;
|
|
|
|
| 2 |
|
| 3 |
import router from "@/router.ts";
|
| 4 |
import { useSettingsStore } from "@/stores/config.ts";
|
| 5 |
+
import { onMounted, onUnmounted, ref, reactive, computed, h } from "vue";
|
| 6 |
import { Modal } from 'ant-design-vue';
|
| 7 |
+
import { SoundTwoTone, SoundOutlined } from "@ant-design/icons-vue";
|
| 8 |
import axios from "axios";
|
| 9 |
import PromptText from "./Components/PromptText.vue";
|
| 10 |
|
|
|
|
| 202 |
const popoverVisible = ref<boolean>(false);
|
| 203 |
const promptModelOpen = ref<boolean>(false);
|
| 204 |
|
| 205 |
+
// 音频播放状态管理
|
| 206 |
+
const currentPlayingId = ref<string | null>(null);
|
| 207 |
+
const currentAudio = ref<HTMLAudioElement | null>(null);
|
| 208 |
+
|
| 209 |
+
// 修改音频播放逻辑
|
| 210 |
+
const playRefAudio = async (id: string, e: Event) => {
|
| 211 |
console.log('Playing reference audio for role:', id);
|
| 212 |
+
|
| 213 |
+
e.stopPropagation();
|
| 214 |
+
e.preventDefault();
|
| 215 |
+
|
| 216 |
+
try {
|
| 217 |
+
// 如果点击的是当前正在播放的音频,则停止播放
|
| 218 |
+
if (currentPlayingId.value === id && currentAudio.value) {
|
| 219 |
+
currentAudio.value.pause();
|
| 220 |
+
currentAudio.value = null;
|
| 221 |
+
currentPlayingId.value = null;
|
| 222 |
+
console.log('Audio stopped');
|
| 223 |
+
return;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
// 如果有其他音频正在播放,先停止它
|
| 227 |
+
if (currentAudio.value) {
|
| 228 |
+
currentAudio.value.pause();
|
| 229 |
+
currentAudio.value = null;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
// 创建新的音频实例
|
| 233 |
+
const audio = new Audio(`${base_url}/tts/models/${id}/reference-audio`);
|
| 234 |
+
|
| 235 |
+
// 设置音频事件监听
|
| 236 |
+
audio.addEventListener('ended', () => {
|
| 237 |
+
currentPlayingId.value = null;
|
| 238 |
+
currentAudio.value = null;
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
audio.addEventListener('error', (error) => {
|
| 242 |
+
console.error('Audio playback error:', error);
|
| 243 |
+
currentPlayingId.value = null;
|
| 244 |
+
currentAudio.value = null;
|
| 245 |
+
Modal.error({
|
| 246 |
+
title: 'Error',
|
| 247 |
+
content: 'Failed to play reference audio',
|
| 248 |
+
});
|
| 249 |
+
});
|
| 250 |
+
|
| 251 |
+
// 开始播放
|
| 252 |
+
await audio.play();
|
| 253 |
+
currentPlayingId.value = id;
|
| 254 |
+
currentAudio.value = audio;
|
| 255 |
+
console.log('Audio played successfully');
|
| 256 |
+
|
| 257 |
+
} catch (error) {
|
| 258 |
+
console.error('Error playing audio:', error);
|
| 259 |
+
currentPlayingId.value = null;
|
| 260 |
+
currentAudio.value = null;
|
| 261 |
+
Modal.error({
|
| 262 |
+
title: 'Error',
|
| 263 |
+
content: 'Failed to play reference audio',
|
| 264 |
+
});
|
| 265 |
+
}
|
| 266 |
};
|
| 267 |
|
| 268 |
+
// 组件卸载时清理音频
|
| 269 |
+
onUnmounted(() => {
|
| 270 |
+
if (currentAudio.value) {
|
| 271 |
+
currentAudio.value.pause();
|
| 272 |
+
currentAudio.value = null;
|
| 273 |
+
}
|
| 274 |
+
currentPlayingId.value = null;
|
| 275 |
+
});
|
| 276 |
+
|
| 277 |
+
// 计算属性:判断是否正在播放
|
| 278 |
+
const isPlaying = (id: string) => {
|
| 279 |
+
return currentPlayingId.value === id;
|
| 280 |
+
};
|
| 281 |
|
| 282 |
</script>
|
| 283 |
|
|
|
|
| 351 |
<a-radio-group size="large" v-model:value="role">
|
| 352 |
<a-radio v-for="r in filteredRoles" :style="radioStyle" :value="r['id']" :key="r['id']">
|
| 353 |
<div style="display: flex; justify-content: space-between; align-items: center; width:450px;">
|
| 354 |
+
{{ r['character_name'] }}
|
| 355 |
+
<a-button
|
| 356 |
+
:key="r['id']"
|
| 357 |
+
type="text"
|
| 358 |
+
@click="playRefAudio(r['id'], $event)"
|
| 359 |
+
class="audio-play-btn"
|
| 360 |
+
:class="{ 'playing': isPlaying(r['id']) }"
|
| 361 |
+
>
|
| 362 |
+
<SoundTwoTone
|
| 363 |
+
v-if="isPlaying(r['id'])"
|
| 364 |
+
style="font-size: 18px; color: #52c41a;"
|
| 365 |
+
class="playing-icon"
|
| 366 |
+
/>
|
| 367 |
+
<SoundOutlined
|
| 368 |
+
v-else
|
| 369 |
+
style="font-size: 18px; color: #1890ff;"
|
| 370 |
+
/>
|
| 371 |
+
</a-button>
|
| 372 |
+
</div>
|
| 373 |
|
| 374 |
</a-radio>
|
| 375 |
</a-radio-group>
|
| 376 |
+
|
| 377 |
</div>
|
| 378 |
</div>
|
| 379 |
</a-modal>
|
|
|
|
| 395 |
}
|
| 396 |
}
|
| 397 |
|
| 398 |
+
.audio-play-btn {
|
| 399 |
+
padding: 0px 8px;
|
| 400 |
+
padding-top:2px;
|
| 401 |
+
border-radius: 4px;
|
| 402 |
+
transition: all 0.2s;
|
| 403 |
+
height: 40px;
|
| 404 |
+
|
| 405 |
+
&:hover {
|
| 406 |
+
background-color: #f0f0f0;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
&.playing {
|
| 410 |
+
background-color: #f6ffed;
|
| 411 |
+
border-color: #1890ff;
|
| 412 |
+
|
| 413 |
+
.playing-icon {
|
| 414 |
+
animation: pulse 1.5s infinite;
|
| 415 |
+
}
|
| 416 |
+
}
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
@keyframes pulse {
|
| 420 |
+
0% {
|
| 421 |
+
opacity: 1;
|
| 422 |
+
transform: scale(1);
|
| 423 |
+
}
|
| 424 |
+
50% {
|
| 425 |
+
opacity: 0.7;
|
| 426 |
+
transform: scale(1.1);
|
| 427 |
+
}
|
| 428 |
+
100% {
|
| 429 |
+
opacity: 1;
|
| 430 |
+
transform: scale(1);
|
| 431 |
+
}
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
.btn-groups {
|
| 435 |
margin-top: 36px;
|
| 436 |
display: flex;
|