feat : tts 和 asr 重构暂存
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user