feat : tts 和 asr 重构暂存

This commit is contained in:
2025-12-26 16:44:11 +08:00
parent 29615c394a
commit 2c5ff4220a
5 changed files with 1677 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
// useAudioSpeak.js
import { ref } from 'vue'
import globalConfig from '@/config.js';
import useUserStore from '@/stores/useUserStore';
/**
* TTS语音合成Hook
@@ -10,7 +12,8 @@ import { ref } from 'vue'
*/
export const useAudioSpeak = (config = {}) => {
const {
apiUrl = 'http://39.98.44.136:19527/synthesize',
// apiUrl = 'http://39.98.44.136:19527/synthesize',
apiUrl = `${globalConfig.baseUrl}/app/synthesize`,
maxSegmentLength = 30
} = config
@@ -112,11 +115,16 @@ export const useAudioSpeak = (config = {}) => {
const fetchAudioSegment = async (text, index) => {
try {
console.log(`📶正在请求第${index + 1}段音频: "${text}"`)
let Authorization = ''
if (useUserStore().token) {
Authorization = `${useUserStore().token}`
}
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization':encodeURIComponent(Authorization)
},
body: JSON.stringify({
text: text,