1
0
forked from erp-dev/erp

feat: big

This commit is contained in:
2026-07-01 11:51:13 +08:00
parent 7c9b77afb0
commit 5170700234
28 changed files with 933 additions and 37 deletions

View File

@@ -31,6 +31,8 @@ def play_speech(
content = (text or '').strip()
if not content:
raise ValueError('text 不能为空')
if not getattr(settings, 'SPEECH_ENABLED', True):
return SpeakResponse(status_code=0, raw={'status': 'disabled'})
url = (endpoint or getattr(settings, 'SPEAK_ENDPOINT', '') or '').strip()
if not url:
@@ -38,10 +40,14 @@ def play_speech(
payload = {'text': content}
data = json.dumps(payload, ensure_ascii=False).encode('utf-8')
headers = {'Content-Type': 'application/json'}
api_key = (getattr(settings, 'SPEAK_API_KEY', '') or '').strip()
if api_key:
headers['X-Api-Key'] = api_key
req = Request(
url=url,
data=data,
headers={'Content-Type': 'application/json'},
headers=headers,
method='POST',
)