Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/audio_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ def clean_wav_files(
denoise_applied = snr_db < 20.0
if denoise_applied:
samples = _spectral_denoise(samples, voice_start, voice_end)
# <8 dB il rumore è troppo alto - riprova
warnings.append("low_snr_retry_recommended")
if snr_db < 8.0:
warnings.append("low_snr_retry_recommended")

# 7. rimozione pezzi senza voce, lasciando 120 ms di padding per testa e coda
padding = round(PADDING_MS * TARGET_SAMPLE_RATE / 1000)
Expand Down
27 changes: 0 additions & 27 deletions app/redis_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,6 @@ def probe_capabilities(
)


def get_json(key: str, *, redis_client: Redis | None = None) -> Any | None:
"""Read a disposable JSON cache value."""
cache = redis_client or client
cached = cache.get(key)
if cached is None:
return None
if isinstance(cached, bytes):
cached = cached.decode("utf-8")
return json.loads(cached)


def set_json(
key: str,
value: Any,
*,
ttl_seconds: int,
redis_client: Redis | None = None,
) -> None:
"""Write a JSON cache value with a mandatory finite lifetime."""
if ttl_seconds <= 0:
raise ValueError("ttl_seconds must be positive")
cache = redis_client or client
cache.setex(
key,
ttl_seconds,
json.dumps(value, ensure_ascii=False),
)


def publish_audio_frame(
Expand Down
137 changes: 0 additions & 137 deletions app/sentence_repository.py

This file was deleted.

13 changes: 13 additions & 0 deletions app/streaming_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def __init__(
else None
)
self._emitted_sentence_words: set[int] = set()
def _shutdown_executors(self) -> None:
if self._executor is not None:
self._executor.shutdown(wait=False, cancel_futures=True)
if self._sentence_executor is not None:
self._sentence_executor.shutdown(wait=False, cancel_futures=True)

def __del__(self) -> None:
self._shutdown_executors()

@property
def pcm(self) -> bytes:
Expand Down Expand Up @@ -324,6 +332,11 @@ def push_frame(self, frame: bytes) -> dict:
}
for index, token in enumerate(tokens)
]

if self._emitted_sentence_words:
current_word_index = max(self._emitted_sentence_words) + 1
if current_word_index >= len(tokens):
current_word_index = len(tokens) - 1
return {
"type": "stream.inference.partial",
"sequence": len(self._frames),
Expand Down
101 changes: 0 additions & 101 deletions app/vector_index.py

This file was deleted.

Loading
Loading