Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -114,6 +114,7 @@ def stream(session_id: str) -> str:
|
|
| 114 |
emitted = 0
|
| 115 |
t0 = time.time()
|
| 116 |
buf_log, buf_t = [], t0
|
|
|
|
| 117 |
while time.time() - t0 < 55.0:
|
| 118 |
c = read_slot(session_id)
|
| 119 |
if c is None:
|
|
@@ -130,8 +131,9 @@ def stream(session_id: str) -> str:
|
|
| 130 |
c = read_slot(session_id) or c
|
| 131 |
tokens = c["style_tokens"]
|
| 132 |
active = c.get("notes") or []
|
| 133 |
-
if tokens != cur_tokens or active != cur_notes
|
| 134 |
cur_tokens, cur_notes = tokens, active
|
|
|
|
| 135 |
aset = set(active)
|
| 136 |
notes = [8 if i in aset else -1 for i in range(128)]
|
| 137 |
cfgs = [discretize_cfg(c.get("cfg_musiccoca", 3.0), 0.2, 40),
|
|
|
|
| 114 |
emitted = 0
|
| 115 |
t0 = time.time()
|
| 116 |
buf_log, buf_t = [], t0
|
| 117 |
+
last_enc = 0.0
|
| 118 |
while time.time() - t0 < 55.0:
|
| 119 |
c = read_slot(session_id)
|
| 120 |
if c is None:
|
|
|
|
| 131 |
c = read_slot(session_id) or c
|
| 132 |
tokens = c["style_tokens"]
|
| 133 |
active = c.get("notes") or []
|
| 134 |
+
if source is None or ((tokens != cur_tokens or active != cur_notes) and time.time() - last_enc >= 0.2):
|
| 135 |
cur_tokens, cur_notes = tokens, active
|
| 136 |
+
last_enc = time.time()
|
| 137 |
aset = set(active)
|
| 138 |
notes = [8 if i in aset else -1 for i in range(128)]
|
| 139 |
cfgs = [discretize_cfg(c.get("cfg_musiccoca", 3.0), 0.2, 40),
|