mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
获取音色数据的接口实现,优化AudioPlayer警告
This commit is contained in:
@@ -4,13 +4,15 @@ import agent from './module/agent.js'
|
||||
import device from './module/device.js'
|
||||
import model from './module/model.js'
|
||||
import user from './module/user.js'
|
||||
import timbre from "./module/timbre.js";
|
||||
|
||||
/**
|
||||
* 接口地址
|
||||
* 开发时自动读取使用.env.development文件
|
||||
* 编译时自动读取使用.env.production文件
|
||||
*/
|
||||
const DEV_API_SERVICE = process.env.VUE_APP_API_BASE_URL
|
||||
// const DEV_API_SERVICE = process.env.VUE_APP_API_BASE_URL
|
||||
const DEV_API_SERVICE = 'https://2662r3426b.vicp.fun/xiaozhi'
|
||||
|
||||
/**
|
||||
* 根据开发环境返回接口url
|
||||
@@ -29,4 +31,5 @@ export default {
|
||||
agent,
|
||||
device,
|
||||
model,
|
||||
timbre,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// timbre.js
|
||||
import { getServiceUrl } from '../api';
|
||||
import RequestService from '../httpRequest';
|
||||
|
||||
export default {
|
||||
getVoiceList(params, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
ttsModelId: params.ttsModelId,
|
||||
page: params.page || 1,
|
||||
limit: params.limit || 10,
|
||||
name: params.name || ''
|
||||
}).toString();
|
||||
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice?${queryParams}`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res.data || []);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取音色列表失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getVoiceList(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user