refactor: 播放语音增加tts_type区分不同类型
This commit is contained in:
parent
b2a8c039b4
commit
bbeed0e276
@ -93,7 +93,8 @@ const props = defineProps({
|
|||||||
type: Boolean
|
type: Boolean
|
||||||
},
|
},
|
||||||
log: Boolean,
|
log: Boolean,
|
||||||
tts: Boolean
|
tts: Boolean,
|
||||||
|
tts_type: String
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:data', 'regeneration'])
|
const emit = defineEmits(['update:data', 'regeneration'])
|
||||||
@ -116,15 +117,15 @@ function voteHandle(val: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const playAnswerText = (text: string) => {
|
const playAnswerText = (text: string) => {
|
||||||
if (props.data.tts_type === 'BROWSER') {
|
if (props.tts_type === 'BROWSER') {
|
||||||
// 创建一个新的 SpeechSynthesisUtterance 实例
|
// 创建一个新的 SpeechSynthesisUtterance 实例
|
||||||
const utterance = new SpeechSynthesisUtterance(text)
|
const utterance = new SpeechSynthesisUtterance(text)
|
||||||
// 调用浏览器的朗读功能
|
// 调用浏览器的朗读功能
|
||||||
window.speechSynthesis.speak(utterance)
|
window.speechSynthesis.speak(utterance)
|
||||||
}
|
}
|
||||||
if (props.data.tts_type === 'TTS') {
|
if (props.tts_type === 'TTS') {
|
||||||
applicationApi
|
applicationApi
|
||||||
.postTextToSpeech(props.data.id as string, { text: text }, loading)
|
.postTextToSpeech(props.applicationId as string, { text: text }, loading)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
// 假设我们有一个 MP3 文件的字节数组
|
// 假设我们有一个 MP3 文件的字节数组
|
||||||
// 创建 Blob 对象
|
// 创建 Blob 对象
|
||||||
|
|||||||
@ -150,6 +150,7 @@
|
|||||||
<div v-if="item.write_ed && props.appId && 500 != item.status" class="flex-between">
|
<div v-if="item.write_ed && props.appId && 500 != item.status" class="flex-between">
|
||||||
<OperationButton
|
<OperationButton
|
||||||
:tts="props.data.tts_model_enable"
|
:tts="props.data.tts_model_enable"
|
||||||
|
:tts_type="props.data.tts_type"
|
||||||
:data="item"
|
:data="item"
|
||||||
:applicationId="appId"
|
:applicationId="appId"
|
||||||
:chatId="chartOpenId"
|
:chatId="chartOpenId"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user