[ci]add merge ci for streaming input (#2965)

Signed-off-by: CHEN <116010019@link.cuhk.edu.cn>
This commit is contained in:
ChenWenjing authored and GitHub committed 2026-04-22 12:08:56 +08:00
1 parent 8e1bbc9ab5
commit e82c0a5e1d
3 files changed
+64 -18

No files matched your search

+9 -4
View File
@@ -3,6 +3,7 @@
import base64
import concurrent.futures
import gc
import hashlib
import io
import logging
import math
@@ -66,6 +67,7 @@ def generate_synthetic_audio(
num_channels: int,
sample_rate: int = 48000,
*,
phrase_text: str = "test",
force_regenerate: bool = False,
cache_dir: Path | str | None = None,
) -> dict[str, Any]:
@@ -74,12 +76,16 @@ def generate_synthetic_audio(
Caches the WAV under ``cache_dir`` when given, else under the default temp
subdirectory. Reuses the file when the same
``duration`` / ``num_channels`` / ``sample_rate`` are requested unless
``force_regenerate`` is true.
``duration`` / ``num_channels`` / ``sample_rate`` / ``phrase_text`` are
requested unless ``force_regenerate`` is true.
The cache filename includes a SHA-256 digest of ``phrase_text`` so different
phrases never share a WAV cache entry.
"""
root = _resolve_synthetic_media_cache_dir(cache_dir)
root.mkdir(parents=True, exist_ok=True)
cache_path = root / f"synth_audio_d{duration}_ch{num_channels}_sr{sample_rate}.wav"
phrase_key = hashlib.sha256(phrase_text.encode("utf-8")).hexdigest()
cache_path = root / f"synth_audio_d{duration}_ch{num_channels}_sr{sample_rate}_pt{phrase_key}.wav"
if not force_regenerate and cache_path.is_file():
data, _sr = sf.read(str(cache_path), dtype="float32", always_2d=True)
@@ -204,7 +210,6 @@ def generate_synthetic_audio(
enhanced = enhanced / peak * 0.95
return enhanced.astype(np.float32)
phrase_text = "test"
num_samples = int(sample_rate * max(1, duration))
audio_data = np.zeros((num_samples, num_channels), dtype=np.float32)