23 lines
619 B
Python
23 lines
619 B
Python
"""
|
||
NovaAi – TTS-Engine-Hub
|
||
utils/cache.py
|
||
Version: v0.0.1
|
||
|
||
Description:
|
||
Caching utilities for TTS requests (cache key generation, etc).
|
||
|
||
Author: Abby (ChatGPT)
|
||
Date: 2025-07-23
|
||
Canvas: utils/cache.py
|
||
"""
|
||
|
||
import hashlib
|
||
|
||
# Für die API: Wichtig! req muss mindestens die Felder .text, .engine, .model, .speaker, .format, .chunking haben.
|
||
def build_cache_key(req) -> str:
|
||
"""
|
||
Build a cache key from all relevant TTS request parameters.
|
||
"""
|
||
data = f"{req.text}|{req.engine}|{req.model}|{req.speaker}|{req.format}|{getattr(req, 'chunking', False)}"
|
||
return hashlib.sha256(data.encode()).hexdigest()
|