forked from erp-dev/erp
feat: big
This commit is contained in:
27
mission/tasks.py
Normal file
27
mission/tasks.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@shared_task(bind=True)
|
||||
def notify_mission_speech(self, *, text: str) -> Dict[str, Any]:
|
||||
try:
|
||||
from flower.utils import play_speech
|
||||
|
||||
response = play_speech(text=text, timeout_seconds=3.0)
|
||||
return {
|
||||
"status": "sent",
|
||||
"task_id": self.request.id,
|
||||
"status_code": response.status_code,
|
||||
"raw": response.raw,
|
||||
}
|
||||
except Exception as exc:
|
||||
logger.exception("[mission.tasks] 任务语音播报失败(已忽略)")
|
||||
return {
|
||||
"status": "error",
|
||||
"task_id": self.request.id,
|
||||
"error": str(exc),
|
||||
}
|
||||
Reference in New Issue
Block a user