initial: silero-tts-service + README
This commit is contained in:
1 parent
8c60c25ad2
commit
984b1fec6d
18 files changed
+2080
No files matched your search
Executable
+35
@@ -0,0 +1,35 @@
|
||||
"""Prometheus метрики и rate limiter для TTS API."""
|
||||
import time
|
||||
from prometheus_client import Counter, Histogram, generate_latest, CONTENT_TYPE_LATEST
|
||||
from slowapi import Limiter
|
||||
from slowapi.util import get_remote_address
|
||||
|
||||
# ─── Prometheus метрики ─────────────────────────────────────────
|
||||
|
||||
_request_counter = Counter(
|
||||
"tts_requests_total",
|
||||
"Общее число запросов к TTS API",
|
||||
["endpoint", "status"],
|
||||
)
|
||||
|
||||
_synthesis_latency = Histogram(
|
||||
"tts_synthesis_seconds",
|
||||
"Время синтеза речи",
|
||||
["voice"],
|
||||
)
|
||||
|
||||
_audio_size_bytes = Histogram(
|
||||
"tts_audio_size_bytes",
|
||||
"Размер сгенерированного аудио в байтах",
|
||||
["voice"],
|
||||
)
|
||||
|
||||
_errors_total = Counter(
|
||||
"tts_errors_total",
|
||||
"Количество ошибок синтеза",
|
||||
["error_type"],
|
||||
)
|
||||
|
||||
# ─── Rate Limiter ─────────────────────────────────────────────────
|
||||
|
||||
limiter = Limiter(key_func=get_remote_address, default_limits=["100 per minute"])
|
||||
Reference in new issue
Block a user