mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-23 03:19:41 +00:00
Merge branch 'main' into fix-model-name
This commit is contained in:
commit
ced7103639
30 changed files with 1009 additions and 201 deletions
|
|
@ -0,0 +1,4 @@
|
|||
UPDATE `sys_params`
|
||||
SET `param_value` = '15'
|
||||
WHERE `param_code` = 'tts_timeout'
|
||||
AND `param_value` = '10';
|
||||
|
|
@ -732,3 +732,10 @@ databaseChangeLog:
|
|||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202608061800.sql
|
||||
- changeSet:
|
||||
id: 202608131030
|
||||
author: tykechen
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202608131030.sql
|
||||
|
|
|
|||
|
|
@ -656,6 +656,7 @@ export default {
|
|||
.drawer-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
z-index: 2;
|
||||
width: 100%;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
|
|
@ -894,4 +895,4 @@ export default {
|
|||
padding: 10px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': 'Suchen',
|
||||
'paramManagement.paramCode': 'Parameter-Code',
|
||||
'paramManagement.paramValue': 'Parameter-Wert',
|
||||
'paramManagement.valueType': 'Typ',
|
||||
'paramManagement.remark': 'Bemerkung',
|
||||
'paramManagement.operation': 'Operation',
|
||||
'paramManagement.select': 'Auswahl',
|
||||
'paramManagement.hide': 'Ausblenden',
|
||||
'paramManagement.view': 'Anzeigen',
|
||||
'paramManagement.deselectAll': 'Alle abwählen',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': 'Hinzufügen',
|
||||
'paramManagement.delete': 'Löschen',
|
||||
'paramManagement.edit': 'Bearbeiten',
|
||||
'paramManagement.refresh': 'Aktualisieren',
|
||||
'paramManagement.itemsPerPage': 'Einträge/Seite',
|
||||
'paramManagement.firstPage': 'Erste Seite',
|
||||
'paramManagement.prevPage': 'Vorherige Seite',
|
||||
'paramManagement.nextPage': 'Nächste Seite',
|
||||
'paramManagement.totalRecords': 'Insgesamt {total} Datensätze',
|
||||
'paramManagement.totalRecords': '{total} insgesamt',
|
||||
'paramManagement.selectedCount': '{count} ausgewählt',
|
||||
'paramManagement.groupHint': 'Nach Namespace gruppiert',
|
||||
'paramManagement.emptyResult': 'Keine passenden Parameter',
|
||||
'paramManagement.group.all': 'Alle',
|
||||
'paramManagement.group.server': 'Server',
|
||||
'paramManagement.group.plugins': 'Plugins',
|
||||
'paramManagement.group.log': 'Logging',
|
||||
'paramManagement.group.session': 'Sitzung',
|
||||
'paramManagement.group.general': 'Allgemein',
|
||||
'paramManagement.subgroup.root': 'Basis',
|
||||
'paramManagement.subgroup.auth': 'Auth',
|
||||
'paramManagement.subgroup.connection': 'Verbindung',
|
||||
'paramManagement.subgroup.registry': 'Registry',
|
||||
'paramManagement.subgroup.resilience': 'Resilience',
|
||||
'paramManagement.subgroup.metrics': 'Metriken',
|
||||
'paramManagement.subgroup.tracing': 'Tracing',
|
||||
'paramManagement.subgroup.plugin': 'Plugin · {name}',
|
||||
'paramManagement.addParam': 'Parameter hinzufügen',
|
||||
'paramManagement.editParam': 'Parameter bearbeiten',
|
||||
'paramManagement.getParamsListFailed': 'Parameterliste konnte nicht abgerufen werden',
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': 'Search',
|
||||
'paramManagement.paramCode': 'Parameter Code',
|
||||
'paramManagement.paramValue': 'Parameter Value',
|
||||
'paramManagement.valueType': 'Type',
|
||||
'paramManagement.remark': 'Remark',
|
||||
'paramManagement.operation': 'Operation',
|
||||
'paramManagement.select': 'Select',
|
||||
'paramManagement.hide': 'Hide',
|
||||
'paramManagement.view': 'View',
|
||||
'paramManagement.deselectAll': 'Deselect All',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': 'Add',
|
||||
'paramManagement.delete': 'Delete',
|
||||
'paramManagement.edit': 'Edit',
|
||||
'paramManagement.refresh': 'Refresh',
|
||||
'paramManagement.itemsPerPage': 'items/page',
|
||||
'paramManagement.firstPage': 'First Page',
|
||||
'paramManagement.prevPage': 'Previous Page',
|
||||
'paramManagement.nextPage': 'Next Page',
|
||||
'paramManagement.totalRecords': 'Total {total} records',
|
||||
'paramManagement.totalRecords': '{total} total',
|
||||
'paramManagement.selectedCount': '{count} selected',
|
||||
'paramManagement.groupHint': 'Grouped by namespace',
|
||||
'paramManagement.emptyResult': 'No matching parameters',
|
||||
'paramManagement.group.all': 'All',
|
||||
'paramManagement.group.server': 'Server',
|
||||
'paramManagement.group.plugins': 'Plugins',
|
||||
'paramManagement.group.log': 'Logging',
|
||||
'paramManagement.group.session': 'Session',
|
||||
'paramManagement.group.general': 'General',
|
||||
'paramManagement.subgroup.root': 'Basics',
|
||||
'paramManagement.subgroup.auth': 'Auth',
|
||||
'paramManagement.subgroup.connection': 'Connection',
|
||||
'paramManagement.subgroup.registry': 'Registry',
|
||||
'paramManagement.subgroup.resilience': 'Resilience',
|
||||
'paramManagement.subgroup.metrics': 'Metrics',
|
||||
'paramManagement.subgroup.tracing': 'Tracing',
|
||||
'paramManagement.subgroup.plugin': 'Plugin · {name}',
|
||||
'paramManagement.addParam': 'Add Parameter',
|
||||
'paramManagement.editParam': 'Edit Parameter',
|
||||
'paramManagement.getParamsListFailed': 'Failed to get parameter list',
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': 'Pesquisar',
|
||||
'paramManagement.paramCode': 'Código do Parâmetro',
|
||||
'paramManagement.paramValue': 'Valor do Parâmetro',
|
||||
'paramManagement.valueType': 'Tipo',
|
||||
'paramManagement.remark': 'Observação',
|
||||
'paramManagement.operation': 'Operação',
|
||||
'paramManagement.select': 'Selecionar',
|
||||
'paramManagement.hide': 'Ocultar',
|
||||
'paramManagement.view': 'Visualizar',
|
||||
'paramManagement.deselectAll': 'Desmarcar Tudo',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': 'Adicionar',
|
||||
'paramManagement.delete': 'Excluir',
|
||||
'paramManagement.edit': 'Editar',
|
||||
'paramManagement.refresh': 'Atualizar',
|
||||
'paramManagement.itemsPerPage': 'itens/página',
|
||||
'paramManagement.firstPage': 'Primeira Página',
|
||||
'paramManagement.prevPage': 'Página Anterior',
|
||||
'paramManagement.nextPage': 'Próxima Página',
|
||||
'paramManagement.totalRecords': 'Total de {total} registros',
|
||||
'paramManagement.totalRecords': '{total} no total',
|
||||
'paramManagement.selectedCount': '{count} selecionados',
|
||||
'paramManagement.groupHint': 'Agrupado por namespace',
|
||||
'paramManagement.emptyResult': 'Nenhum parâmetro correspondente',
|
||||
'paramManagement.group.all': 'Todos',
|
||||
'paramManagement.group.server': 'Servidor',
|
||||
'paramManagement.group.plugins': 'Plugins',
|
||||
'paramManagement.group.log': 'Logs',
|
||||
'paramManagement.group.session': 'Sessão',
|
||||
'paramManagement.group.general': 'Geral',
|
||||
'paramManagement.subgroup.root': 'Básico',
|
||||
'paramManagement.subgroup.auth': 'Auth',
|
||||
'paramManagement.subgroup.connection': 'Conexão',
|
||||
'paramManagement.subgroup.registry': 'Registry',
|
||||
'paramManagement.subgroup.resilience': 'Resilience',
|
||||
'paramManagement.subgroup.metrics': 'Métricas',
|
||||
'paramManagement.subgroup.tracing': 'Tracing',
|
||||
'paramManagement.subgroup.plugin': 'Plugin · {name}',
|
||||
'paramManagement.addParam': 'Adicionar Parâmetro',
|
||||
'paramManagement.editParam': 'Editar Parâmetro',
|
||||
'paramManagement.getParamsListFailed': 'Falha ao obter lista de parâmetros',
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': 'Tìm kiếm',
|
||||
'paramManagement.paramCode': 'Mã tham số',
|
||||
'paramManagement.paramValue': 'Giá trị tham số',
|
||||
'paramManagement.valueType': 'Loại',
|
||||
'paramManagement.remark': 'Ghi chú',
|
||||
'paramManagement.operation': 'Thao tác',
|
||||
'paramManagement.select': 'Chọn',
|
||||
'paramManagement.hide': 'Ẩn',
|
||||
'paramManagement.view': 'Xem',
|
||||
'paramManagement.deselectAll': 'Bỏ chọn tất cả',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': 'Thêm',
|
||||
'paramManagement.delete': 'Xóa',
|
||||
'paramManagement.edit': 'Chỉnh sửa',
|
||||
'paramManagement.refresh': 'Làm mới',
|
||||
'paramManagement.itemsPerPage': 'mục/trang',
|
||||
'paramManagement.firstPage': 'Trang đầu',
|
||||
'paramManagement.prevPage': 'Trang trước',
|
||||
'paramManagement.nextPage': 'Trang sau',
|
||||
'paramManagement.totalRecords': 'Tổng cộng {total} bản ghi',
|
||||
'paramManagement.totalRecords': 'Tổng {total}',
|
||||
'paramManagement.selectedCount': 'Đã chọn {count}',
|
||||
'paramManagement.groupHint': 'Nhóm theo namespace',
|
||||
'paramManagement.emptyResult': 'Không có tham số phù hợp',
|
||||
'paramManagement.group.all': 'Tất cả',
|
||||
'paramManagement.group.server': 'Máy chủ',
|
||||
'paramManagement.group.plugins': 'Plugin',
|
||||
'paramManagement.group.log': 'Nhật ký',
|
||||
'paramManagement.group.session': 'Phiên',
|
||||
'paramManagement.group.general': 'Chung',
|
||||
'paramManagement.subgroup.root': 'Cơ bản',
|
||||
'paramManagement.subgroup.auth': 'Xác thực',
|
||||
'paramManagement.subgroup.connection': 'Kết nối',
|
||||
'paramManagement.subgroup.registry': 'Đăng ký',
|
||||
'paramManagement.subgroup.resilience': 'Resilience',
|
||||
'paramManagement.subgroup.metrics': 'Chỉ số',
|
||||
'paramManagement.subgroup.tracing': 'Tracing',
|
||||
'paramManagement.subgroup.plugin': 'Plugin · {name}',
|
||||
'paramManagement.addParam': 'Thêm tham số',
|
||||
'paramManagement.editParam': 'Chỉnh sửa tham số',
|
||||
'paramManagement.getParamsListFailed': 'Không thể lấy danh sách tham số',
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': '搜索',
|
||||
'paramManagement.paramCode': '参数编码',
|
||||
'paramManagement.paramValue': '参数值',
|
||||
'paramManagement.valueType': '类型',
|
||||
'paramManagement.remark': '备注',
|
||||
'paramManagement.operation': '操作',
|
||||
'paramManagement.select': '选择',
|
||||
'paramManagement.hide': '隐藏',
|
||||
'paramManagement.view': '查看',
|
||||
'paramManagement.deselectAll': '取消全选',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': '新增',
|
||||
'paramManagement.delete': '删除',
|
||||
'paramManagement.edit': '编辑',
|
||||
'paramManagement.refresh': '刷新',
|
||||
'paramManagement.itemsPerPage': '条/页',
|
||||
'paramManagement.firstPage': '首页',
|
||||
'paramManagement.prevPage': '上一页',
|
||||
'paramManagement.nextPage': '下一页',
|
||||
'paramManagement.totalRecords': '共{total}条记录',
|
||||
'paramManagement.totalRecords': '共{total}条',
|
||||
'paramManagement.selectedCount': '已选 {count} 项',
|
||||
'paramManagement.groupHint': '按命名空间聚合展示',
|
||||
'paramManagement.emptyResult': '没有匹配的参数',
|
||||
'paramManagement.group.all': '全部',
|
||||
'paramManagement.group.server': '服务端',
|
||||
'paramManagement.group.plugins': '插件',
|
||||
'paramManagement.group.log': '日志',
|
||||
'paramManagement.group.session': '会话',
|
||||
'paramManagement.group.general': '通用',
|
||||
'paramManagement.subgroup.root': '基础配置',
|
||||
'paramManagement.subgroup.auth': '鉴权',
|
||||
'paramManagement.subgroup.connection': '连接',
|
||||
'paramManagement.subgroup.registry': '实例注册',
|
||||
'paramManagement.subgroup.resilience': '韧性 / 熔断',
|
||||
'paramManagement.subgroup.metrics': '指标',
|
||||
'paramManagement.subgroup.tracing': '链路追踪',
|
||||
'paramManagement.subgroup.plugin': '插件 · {name}',
|
||||
'paramManagement.addParam': '新增参数',
|
||||
'paramManagement.editParam': '编辑参数',
|
||||
'paramManagement.getParamsListFailed': '获取参数列表失败',
|
||||
|
|
|
|||
|
|
@ -752,8 +752,10 @@ export default {
|
|||
'paramManagement.search': '搜索',
|
||||
'paramManagement.paramCode': '參數編碼',
|
||||
'paramManagement.paramValue': '參數值',
|
||||
'paramManagement.valueType': '類型',
|
||||
'paramManagement.remark': '備註',
|
||||
'paramManagement.operation': '操作',
|
||||
'paramManagement.select': '選擇',
|
||||
'paramManagement.hide': '隱藏',
|
||||
'paramManagement.view': '查看',
|
||||
'paramManagement.deselectAll': '取消全選',
|
||||
|
|
@ -761,11 +763,29 @@ export default {
|
|||
'paramManagement.add': '新增',
|
||||
'paramManagement.delete': '刪除',
|
||||
'paramManagement.edit': '編輯',
|
||||
'paramManagement.refresh': '重新整理',
|
||||
'paramManagement.itemsPerPage': '條/頁',
|
||||
'paramManagement.firstPage': '首頁',
|
||||
'paramManagement.prevPage': '上一頁',
|
||||
'paramManagement.nextPage': '下一頁',
|
||||
'paramManagement.totalRecords': '共{total}條記錄',
|
||||
'paramManagement.totalRecords': '共{total}條',
|
||||
'paramManagement.selectedCount': '已選 {count} 項',
|
||||
'paramManagement.groupHint': '依命名空間聚合顯示',
|
||||
'paramManagement.emptyResult': '沒有符合的參數',
|
||||
'paramManagement.group.all': '全部',
|
||||
'paramManagement.group.server': '服務端',
|
||||
'paramManagement.group.plugins': '外掛',
|
||||
'paramManagement.group.log': '日誌',
|
||||
'paramManagement.group.session': '會話',
|
||||
'paramManagement.group.general': '通用',
|
||||
'paramManagement.subgroup.root': '基礎設定',
|
||||
'paramManagement.subgroup.auth': '鑑權',
|
||||
'paramManagement.subgroup.connection': '連線',
|
||||
'paramManagement.subgroup.registry': '實例註冊',
|
||||
'paramManagement.subgroup.resilience': '韌性 / 熔斷',
|
||||
'paramManagement.subgroup.metrics': '指標',
|
||||
'paramManagement.subgroup.tracing': '鏈路追蹤',
|
||||
'paramManagement.subgroup.plugin': '外掛 · {name}',
|
||||
'paramManagement.addParam': '新增參數',
|
||||
'paramManagement.editParam': '編輯參數',
|
||||
'paramManagement.getParamsListFailed': '獲取參數列表失敗',
|
||||
|
|
|
|||
|
|
@ -148,6 +148,8 @@
|
|||
:title="$t('knowledgeFileUpload.uploadDocument')"
|
||||
:visible.sync="uploadDialogVisible"
|
||||
width="800px"
|
||||
:close-on-click-modal="false"
|
||||
:confirmLoading="uploading"
|
||||
@close="handleUploadDialogClose"
|
||||
@confirm="handleBatchUploadSubmit"
|
||||
>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -10,6 +10,10 @@ const correctWordApiSource = await readFile(
|
|||
new URL('../src/apis/module/correctWord.js', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
const functionDialogSource = await readFile(
|
||||
new URL('../src/components/FunctionDialog.vue', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
test('address-book permission state consistently uses the target device MAC', () => {
|
||||
assert.match(
|
||||
|
|
@ -61,3 +65,16 @@ test('correct-word pagination maps the UI page size to the backend limit query',
|
|||
);
|
||||
assert.doesNotMatch(correctWordApiSource, /pageSize: params\.pageSize/);
|
||||
});
|
||||
|
||||
test('function dialog footer stays above the expanding MCP tools section', () => {
|
||||
const mcpLayer = functionDialogSource.match(
|
||||
/\.mcp-access-point\s*\{[^}]*z-index:\s*(\d+);/s,
|
||||
);
|
||||
const footerLayer = functionDialogSource.match(
|
||||
/\.drawer-footer\s*\{[^}]*z-index:\s*(\d+);/s,
|
||||
);
|
||||
|
||||
assert.ok(mcpLayer, 'MCP section should define its stacking layer');
|
||||
assert.ok(footerLayer, 'drawer footer should define its stacking layer');
|
||||
assert.ok(Number(footerLayer[1]) > Number(mcpLayer[1]));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ delete_audio: true
|
|||
# 没有语音输入多久后断开连接(秒),默认2分钟,即120秒
|
||||
close_connection_no_voice_time: 120
|
||||
# TTS请求超时时间(秒)
|
||||
tts_timeout: 10
|
||||
tts_timeout: 15
|
||||
# 工具调用超时时间(秒)
|
||||
tool_call_timeout: 30
|
||||
# 开启唤醒词加速
|
||||
|
|
|
|||
|
|
@ -808,6 +808,7 @@ class ConnectionHandler:
|
|||
self.headers.get("client-id", self.headers.get("device-id")),
|
||||
)
|
||||
private_config["delete_audio"] = bool(self.config.get("delete_audio", True))
|
||||
private_config["tts_timeout"] = self.config.get("tts_timeout", 15)
|
||||
self.logger.bind(tag=TAG).info(
|
||||
f"{time.time() - begin_time} 秒,异步获取差异化配置成功: {json.dumps(filter_sensitive_info(private_config), ensure_ascii=False)}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class AccessToken:
|
|||
return encoded_text.replace("+", "%20").replace("*", "%2A").replace("%7E", "~")
|
||||
|
||||
@staticmethod
|
||||
def create_token(access_key_id, access_key_secret):
|
||||
def create_token(access_key_id, access_key_secret, timeout):
|
||||
parameters = {
|
||||
"AccessKeyId": access_key_id,
|
||||
"Action": "CreateToken",
|
||||
|
|
@ -73,7 +73,7 @@ class AccessToken:
|
|||
)
|
||||
# print('url: %s' % full_url)
|
||||
# 提交HTTP GET请求
|
||||
response = requests.get(full_url)
|
||||
response = requests.get(full_url, timeout=timeout)
|
||||
if response.ok:
|
||||
root_obj = response.json()
|
||||
key = "Token"
|
||||
|
|
@ -135,7 +135,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"""刷新Token并记录过期时间"""
|
||||
if self.access_key_id and self.access_key_secret:
|
||||
self.token, expire_time_str = AccessToken.create_token(
|
||||
self.access_key_id, self.access_key_secret
|
||||
self.access_key_id, self.access_key_secret, self.tts_timeout
|
||||
)
|
||||
if not expire_time_str:
|
||||
raise ValueError("无法获取有效的Token过期时间")
|
||||
|
|
@ -189,12 +189,18 @@ class TTSProvider(TTSProviderBase):
|
|||
# print(self.api_url, json.dumps(request_json, ensure_ascii=False))
|
||||
try:
|
||||
resp = requests.post(
|
||||
self.api_url, json.dumps(request_json), headers=self.header
|
||||
self.api_url,
|
||||
json.dumps(request_json),
|
||||
headers=self.header,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
if resp.status_code == 401: # Token过期特殊处理
|
||||
self._refresh_token()
|
||||
resp = requests.post(
|
||||
self.api_url, json.dumps(request_json), headers=self.header
|
||||
self.api_url,
|
||||
json.dumps(request_json),
|
||||
headers=self.header,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
# 检查返回请求数据的mime类型是否是audio/***,是则保存到指定路径下;返回的是binary格式的
|
||||
if resp.headers["Content-Type"].startswith("audio/"):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class AccessToken:
|
|||
return encoded_text.replace("+", "%20").replace("*", "%2A").replace("%7E", "~")
|
||||
|
||||
@staticmethod
|
||||
def create_token(access_key_id, access_key_secret):
|
||||
def create_token(access_key_id, access_key_secret, timeout):
|
||||
parameters = {
|
||||
"AccessKeyId": access_key_id,
|
||||
"Action": "CreateToken",
|
||||
|
|
@ -75,7 +75,7 @@ class AccessToken:
|
|||
|
||||
import requests
|
||||
|
||||
response = requests.get(full_url)
|
||||
response = requests.get(full_url, timeout=timeout)
|
||||
if response.ok:
|
||||
root_obj = response.json()
|
||||
key = "Token"
|
||||
|
|
@ -152,7 +152,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"""刷新Token并记录过期时间"""
|
||||
if self.access_key_id and self.access_key_secret:
|
||||
self.token, expire_time_str = AccessToken.create_token(
|
||||
self.access_key_id, self.access_key_secret
|
||||
self.access_key_id, self.access_key_secret, self.tts_timeout
|
||||
)
|
||||
if not expire_time_str:
|
||||
raise ValueError("无法获取有效的Token过期时间")
|
||||
|
|
@ -646,4 +646,4 @@ class TTSProvider(TTSProviderBase):
|
|||
return audio_data
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"生成音频数据失败: {str(e)}")
|
||||
return []
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import re
|
||||
import math
|
||||
import uuid
|
||||
import queue
|
||||
import asyncio
|
||||
|
|
@ -37,7 +38,9 @@ class TTSProviderBase(ABC):
|
|||
self.delete_audio_file = delete_audio_file
|
||||
self.audio_file_type = "wav"
|
||||
self.output_file = config.get("output_dir", "tmp/")
|
||||
self.tts_timeout = int(config.get("tts_timeout", 15))
|
||||
self.tts_timeout = float(config.get("tts_timeout", 15))
|
||||
if not math.isfinite(self.tts_timeout) or self.tts_timeout <= 0:
|
||||
raise ValueError("tts_timeout must be a positive finite number")
|
||||
self.tts_text_queue = queue.Queue()
|
||||
self.tts_audio_queue = queue.Queue()
|
||||
self.tts_audio_first_sentence = True
|
||||
|
|
|
|||
|
|
@ -47,7 +47,11 @@ class TTSProvider(TTSProviderBase):
|
|||
|
||||
try:
|
||||
response = requests.request(
|
||||
"POST", self.api_url, json=request_json, headers=headers
|
||||
"POST",
|
||||
self.api_url,
|
||||
json=request_json,
|
||||
headers=headers,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
data = response.content
|
||||
if output_file:
|
||||
|
|
|
|||
|
|
@ -38,9 +38,19 @@ class TTSProvider(TTSProviderBase):
|
|||
request_params[k] = v
|
||||
|
||||
if self.method.upper() == "POST":
|
||||
resp = requests.post(self.url, json=request_params, headers=self.headers)
|
||||
resp = requests.post(
|
||||
self.url,
|
||||
json=request_params,
|
||||
headers=self.headers,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
else:
|
||||
resp = requests.get(self.url, params=request_params, headers=self.headers)
|
||||
resp = requests.get(
|
||||
self.url,
|
||||
params=request_params,
|
||||
headers=self.headers,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
if output_file:
|
||||
with open(output_file, "wb") as file:
|
||||
|
|
|
|||
|
|
@ -80,7 +80,10 @@ class TTSProvider(TTSProviderBase):
|
|||
|
||||
try:
|
||||
resp = requests.post(
|
||||
self.api_url, json.dumps(request_json), headers=self.header
|
||||
self.api_url,
|
||||
json.dumps(request_json),
|
||||
headers=self.header,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
if "data" in resp.json():
|
||||
data = resp.json()["data"]
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"Authorization": f"Bearer {self.api_key}",
|
||||
"Content-Type": "application/msgpack",
|
||||
},
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
|
|
|
|||
|
|
@ -90,7 +90,9 @@ class TTSProvider(TTSProviderBase):
|
|||
"repetition_penalty": self.repetition_penalty,
|
||||
}
|
||||
|
||||
resp = requests.post(self.url, json=request_json)
|
||||
resp = requests.post(
|
||||
self.url, json=request_json, timeout=self.tts_timeout
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
if output_file:
|
||||
with open(output_file, "wb") as file:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ class TTSProvider(TTSProviderBase):
|
|||
"if_sr": self.if_sr,
|
||||
}
|
||||
|
||||
resp = requests.get(self.url, params=request_params)
|
||||
resp = requests.get(
|
||||
self.url, params=request_params, timeout=self.tts_timeout
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
if output_file:
|
||||
with open(output_file, "wb") as file:
|
||||
|
|
|
|||
|
|
@ -130,7 +130,9 @@ class TTSProvider(TTSProviderBase):
|
|||
) # 16-bit = 2 bytes
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(self.api_url, json=payload, timeout=10) as resp:
|
||||
async with session.post(
|
||||
self.api_url, json=payload, timeout=self.tts_timeout
|
||||
) as resp:
|
||||
|
||||
if resp.status != 200:
|
||||
logger.bind(tag=TAG).error(
|
||||
|
|
@ -212,7 +214,9 @@ class TTSProvider(TTSProviderBase):
|
|||
payload = {"text": text, "character": self.voice}
|
||||
|
||||
try:
|
||||
with requests.post(self.api_url, json=payload, timeout=5) as response:
|
||||
with requests.post(
|
||||
self.api_url, json=payload, timeout=self.tts_timeout
|
||||
) as response:
|
||||
if response.status_code != 200:
|
||||
logger.bind(tag=TAG).error(
|
||||
f"TTS请求失败: {response.status_code}, {response.text}"
|
||||
|
|
@ -251,4 +255,4 @@ class TTSProvider(TTSProviderBase):
|
|||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"TTS请求异常: {e}")
|
||||
return []
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class TTSProvider(TTSProviderBase):
|
|||
self.api_url,
|
||||
headers=self.header,
|
||||
data=json.dumps(payload),
|
||||
timeout=10,
|
||||
timeout=self.tts_timeout,
|
||||
) as resp:
|
||||
|
||||
if resp.status != 200:
|
||||
|
|
@ -324,7 +324,10 @@ class TTSProvider(TTSProviderBase):
|
|||
|
||||
try:
|
||||
with requests.post(
|
||||
self.api_url, data=json.dumps(payload), headers=headers, timeout=5
|
||||
self.api_url,
|
||||
data=json.dumps(payload),
|
||||
headers=headers,
|
||||
timeout=self.tts_timeout,
|
||||
) as response:
|
||||
if response.status_code != 200:
|
||||
logger.bind(tag=TAG).error(
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ class TTSProvider(TTSProviderBase):
|
|||
"response_format": self.audio_file_type,
|
||||
"speed": self.speed,
|
||||
}
|
||||
response = requests.post(self.api_url, json=data, headers=headers)
|
||||
response = requests.post(
|
||||
self.api_url, json=data, headers=headers, timeout=self.tts_timeout
|
||||
)
|
||||
if response.status_code == 200:
|
||||
if output_file:
|
||||
with open(output_file, "wb") as audio_file:
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class TTSProvider(TTSProviderBase):
|
|||
await ws.send(json.dumps(data_request))
|
||||
|
||||
audio_chunks = b""
|
||||
timeout_seconds = 60 # 设置超时
|
||||
timeout_seconds = self.tts_timeout
|
||||
try:
|
||||
while True:
|
||||
response = await asyncio.wait_for(ws.recv(), timeout=timeout_seconds)
|
||||
|
|
@ -154,4 +154,4 @@ class TTSProvider(TTSProviderBase):
|
|||
return wav_data
|
||||
|
||||
except Exception as e:
|
||||
raise Exception(f"Error during TTS WebSocket request: {e} while processing text: {text}")
|
||||
raise Exception(f"Error during TTS WebSocket request: {e} while processing text: {text}")
|
||||
|
|
|
|||
|
|
@ -39,8 +39,13 @@ class TTSProvider(TTSProviderBase):
|
|||
}
|
||||
try:
|
||||
response = requests.request(
|
||||
"POST", self.api_url, json=request_json, headers=headers
|
||||
"POST", self.api_url, json=request_json, headers=headers,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
if response.status_code != 200:
|
||||
raise Exception(
|
||||
f"{__name__} HTTP {response.status_code}: {response.text[:200]}"
|
||||
)
|
||||
data = response.content
|
||||
if output_file:
|
||||
with open(output_file, "wb") as file_to_save:
|
||||
|
|
|
|||
|
|
@ -154,7 +154,10 @@ class TTSProvider(TTSProviderBase):
|
|||
|
||||
# 发送请求
|
||||
resp = requests.post(
|
||||
self.api_url, json.dumps(request_json), headers=headers
|
||||
self.api_url,
|
||||
json.dumps(request_json),
|
||||
headers=headers,
|
||||
timeout=self.tts_timeout,
|
||||
)
|
||||
|
||||
# 检查响应
|
||||
|
|
|
|||
|
|
@ -100,14 +100,16 @@ def initialize_modules(
|
|||
|
||||
def initialize_tts(config):
|
||||
select_tts_module = config["selected_module"]["TTS"]
|
||||
tts_config = config["TTS"][select_tts_module].copy()
|
||||
tts_config.setdefault("tts_timeout", config.get("tts_timeout", 15))
|
||||
tts_type = (
|
||||
select_tts_module
|
||||
if "type" not in config["TTS"][select_tts_module]
|
||||
else config["TTS"][select_tts_module]["type"]
|
||||
if "type" not in tts_config
|
||||
else tts_config["type"]
|
||||
)
|
||||
new_tts = tts.create_instance(
|
||||
tts_type,
|
||||
config["TTS"][select_tts_module],
|
||||
tts_config,
|
||||
str(config.get("delete_audio", True)).lower() in ("true", "1", "yes"),
|
||||
)
|
||||
return new_tts
|
||||
|
|
@ -148,4 +150,3 @@ def initialize_voiceprint(asr_instance, config):
|
|||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"动态初始化声纹识别功能失败: {str(e)}")
|
||||
return False
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue