Files
gsfdc/demo-dify/dify/api/services/app_audio_service.py
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

33 lines
1.2 KiB
Python

"""Audio operations for an admitted app, independent of its entry point."""
from typing import Protocol
from services.audio_types import AudioAppRef, AudioOutput, AudioUpload
class AppAudio(Protocol):
def transcript_asr(self, *, app: AudioAppRef, audio: AudioUpload | None) -> dict[str, str]: ...
def transcript_tts(
self,
*,
app: AudioAppRef,
account_id: str,
text: str | None,
voice: str | None,
message_id: str | None,
) -> AudioOutput | None:
"""Synthesize a message answer or explicit text for the admitted app.
A non-empty ``message_id`` takes precedence over ``text`` and selects
a message belonging to this app and ``account_id``. When ``message_id``
is None or empty, ``text`` is required; None raises ValueError.
Return None without invoking the provider when the message ID is not
a valid UUID, no owned message exists, or its answer is empty while its
status is NORMAL or PAUSED. This means no message audio is available;
it does not fall back to ``text``. Configuration and provider failures
raise their corresponding exceptions instead of returning None.
"""
...