forked from erp-dev/erp
28 lines
744 B
Python
28 lines
744 B
Python
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),
|
|
}
|