dont run all tokens for short dur
Browse files
app.py
CHANGED
|
@@ -17,13 +17,13 @@ def audionar_tts(text='frogs',
|
|
| 17 |
if text and text.strip():
|
| 18 |
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
background_audio = audiogen.generate(
|
| 23 |
-
text[:64],
|
| 24 |
-
duration=
|
| 25 |
-
max_tokens=max(7, int(max_tokens)), # kv cache lowest n_preserve
|
| 26 |
-
cache_lim=max(6, int(cache_lim)),
|
| 27 |
).numpy()
|
| 28 |
|
| 29 |
else:
|
|
@@ -48,14 +48,14 @@ with gr.Blocks() as demo:
|
|
| 48 |
)
|
| 49 |
duration = gr.Number(
|
| 50 |
label="Duration (s)",
|
| 51 |
-
value=7.
|
| 52 |
)
|
| 53 |
n_tokens = gr.Number(
|
| 54 |
label="Tokens",
|
| 55 |
value=24,
|
| 56 |
)
|
| 57 |
cache_lim = gr.Number(
|
| 58 |
-
label="kv
|
| 59 |
value=71,
|
| 60 |
)
|
| 61 |
generate_button = gr.Button("Generate Audio",
|
|
|
|
| 17 |
if text and text.strip():
|
| 18 |
|
| 19 |
|
| 20 |
+
duration = max(duration + 0.74, 2.0)
|
| 21 |
+
|
| 22 |
background_audio = audiogen.generate(
|
| 23 |
+
text[:64], # soundscape text - discard if too long cross attention
|
| 24 |
+
duration=duration, # dont use all A/R tokens if duration is shorter than tokens<<
|
| 25 |
+
max_tokens=min(max(7, int(max_tokens)), int(duration * 50)) # kv cache lowest n_preserve
|
| 26 |
+
cache_lim=max(6, int(cache_lim)), # Sink Attn
|
| 27 |
).numpy()
|
| 28 |
|
| 29 |
else:
|
|
|
|
| 48 |
)
|
| 49 |
duration = gr.Number(
|
| 50 |
label="Duration (s)",
|
| 51 |
+
value=7.24,
|
| 52 |
)
|
| 53 |
n_tokens = gr.Number(
|
| 54 |
label="Tokens",
|
| 55 |
value=24,
|
| 56 |
)
|
| 57 |
cache_lim = gr.Number(
|
| 58 |
+
label="kv Flush",
|
| 59 |
value=71,
|
| 60 |
)
|
| 61 |
generate_button = gr.Button("Generate Audio",
|