forked from erp-dev/erp
feat: big
This commit is contained in:
@@ -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',
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user