diff --git a/src/components/infer/model_card.vue b/src/components/infer/model_card.vue
index 806f2ad..b854a8a 100644
--- a/src/components/infer/model_card.vue
+++ b/src/components/infer/model_card.vue
@@ -140,6 +140,22 @@ export default {
style="margin-left: 16px"
/>
+
+
+
emotion
+
+
+
+
+
+
+
diff --git a/src/infer.vue b/src/infer.vue
index 8c9ef5f..1995074 100644
--- a/src/infer.vue
+++ b/src/infer.vue
@@ -27,6 +27,9 @@ export default {
global_noisew_selected: false,
global_length: 1.0,
global_length_selected: false,
+ global_emotion: 0,
+ global_emotion_selected: false,
+ global_use_reference_audio: false,
global_speaker: "",
global_speaker_selected: false,
global_language: "",
@@ -47,8 +50,10 @@ export default {
data: {
text: "",
src: "",
- speaker: ""
- }
+ speaker: "",
+ name: ""
+ },
+ audio_file: null
},
auto_translate: false,
auto_split: false,
@@ -56,7 +61,7 @@ export default {
random_speaker: false,
random_language: "ZH",
txt: [],
- card_width : 8
+ card_width: 8
}
},
mounted() {
@@ -97,6 +102,7 @@ export default {
noisew: 0.9,
length: 1,
language: data[model_id]["language"],
+ emotion: 0,
selected: false,
audio: {
loading: false,
@@ -142,11 +148,18 @@ export default {
length: model.length,
language: model.language,
auto_translate: this.auto_translate,
- auto_split: auto_split
+ auto_split: auto_split,
+ emotion: model.emotion
+ }
+ let formData = new FormData()
+ formData.append("text", texts)
+ // 仅当使用参考音频且音频有效时生效
+ if (this.global_use_reference_audio && this.random_audio.valid && this.random_audio.audio_file !== null) {
+ formData.append("reference_audio", this.random_audio.audio_file)
}
try {
model.audio.loading = true
- let response = await axios.post(url, {"text": texts}, {
+ let response = await axios.post(url, formData, {
params: params,
responseType: "blob"
})
@@ -227,6 +240,7 @@ export default {
this.global_noise_selected = true
this.global_noisew_selected = true
this.global_length_selected = true
+ this.global_emotion_selected = true
this.global_speaker_selected = true
this.global_language_selected = true
} else {
@@ -294,6 +308,9 @@ export default {
if (this.global_length_selected === true) {
model.length = this.global_length
}
+ if (this.global_emotion_selected === true) {
+ model.emotion = this.global_emotion
+ }
if (this.global_speaker_selected === true) {
if (model.speakers.includes(this.global_speaker)) {
model.speaker_name = this.global_speaker
@@ -332,8 +349,17 @@ export default {
this.random_audio.data.speaker = data["speaker"]
this.random_audio.data.text = data["text"]
this.texts = data["text"]
- this.random_audio.valid = true
this.random_audio.data.src = `tools/get_audio?path=${data["audio"]}`
+ // 下载音频
+ try {
+ const response = await axios.get(`tools/get_audio?path=${data["audio"]}`, {responseType: 'blob'})
+ const blob = new Blob([response.data])
+ this.random_audio.audio_file = new File([blob], "random.mp3")
+ this.random_audio.valid = true
+ this.random_audio.data.name = ""
+ console.log(this.random_audio.audio_file)
+ } catch (error) {
+ }
}
} catch (error) {
console.error(`音频获取失败`, error)
@@ -347,6 +373,16 @@ export default {
};
reader.readAsText(file)
return false
+ },
+
+ get_audio(file) {
+ if (file) {
+ this.random_audio.audio_file = file
+ console.log(this.random_audio.audio_file)
+ this.random_audio.data.src = URL.createObjectURL(file)
+ this.random_audio.valid = true
+ this.random_audio.data.name = file.name
+ }
}
},
computed: {
@@ -442,6 +478,24 @@ export default {
style="margin-left: 16px"
/>
+
+
+ emotion
+
+
+
+
+
+
+
+
+
@@ -594,13 +648,30 @@ export default {
+
+
+
+
+
+ 上传音频
+
+
+
+ {{ global_use_reference_audio ? "取消emo音频" : "作为emo音频" }}
+
+
+ :download=" random_audio.data.name===''? random_audio.data.speaker + ': ' + texts + '.wav' : random_audio.data.name">