change trusting claude
Browse files- demos/melodyflow_app.py +14 -6
demos/melodyflow_app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
# All rights reserved.
|
| 3 |
|
| 4 |
-
# This source code is licensed under
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
import spaces
|
|
@@ -15,6 +15,7 @@ from tempfile import NamedTemporaryFile
|
|
| 15 |
import time
|
| 16 |
import typing as tp
|
| 17 |
import warnings
|
|
|
|
| 18 |
|
| 19 |
import torch
|
| 20 |
import gradio as gr
|
|
@@ -201,11 +202,18 @@ def predict(model, text,
|
|
| 201 |
duration=duration,
|
| 202 |
progress=True,)
|
| 203 |
|
| 204 |
-
# Read the audio file and
|
| 205 |
wav_path = wavs[0]
|
| 206 |
-
|
|
|
|
| 207 |
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
|
| 210 |
|
| 211 |
def toggle_audio_src(choice):
|
|
@@ -272,7 +280,7 @@ def ui_local(launch_kwargs):
|
|
| 272 |
label="Regularization Strength", minimum=0.0, maximum=1.0, value=0.0, interactive=False)
|
| 273 |
with gr.Column():
|
| 274 |
audio_outputs = [
|
| 275 |
-
gr.
|
| 276 |
submit.click(fn=predict,
|
| 277 |
inputs=[model, text,
|
| 278 |
solver,
|
|
@@ -391,7 +399,7 @@ def ui_hf(launch_kwargs):
|
|
| 391 |
label="Regularization Strength", minimum=0.0, maximum=1.0, value=0.0, interactive=False)
|
| 392 |
with gr.Column():
|
| 393 |
audio_outputs = [
|
| 394 |
-
gr.
|
| 395 |
submit.click(fn=predict,
|
| 396 |
inputs=[model, text,
|
| 397 |
solver,
|
|
|
|
| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
# All rights reserved.
|
| 3 |
|
| 4 |
+
# This source code is licensed under the license found in the
|
| 5 |
# LICENSE file in the root directory of this source tree.
|
| 6 |
|
| 7 |
import spaces
|
|
|
|
| 15 |
import time
|
| 16 |
import typing as tp
|
| 17 |
import warnings
|
| 18 |
+
import base64
|
| 19 |
|
| 20 |
import torch
|
| 21 |
import gradio as gr
|
|
|
|
| 202 |
duration=duration,
|
| 203 |
progress=True,)
|
| 204 |
|
| 205 |
+
# Read the audio file and convert to base64
|
| 206 |
wav_path = wavs[0]
|
| 207 |
+
with open(wav_path, 'rb') as f:
|
| 208 |
+
audio_bytes = f.read()
|
| 209 |
|
| 210 |
+
audio_base64 = base64.b64encode(audio_bytes).decode('utf-8')
|
| 211 |
+
|
| 212 |
+
# Return as a dictionary with base64 data
|
| 213 |
+
return {
|
| 214 |
+
"audio": audio_base64,
|
| 215 |
+
"format": "wav"
|
| 216 |
+
}
|
| 217 |
|
| 218 |
|
| 219 |
def toggle_audio_src(choice):
|
|
|
|
| 280 |
label="Regularization Strength", minimum=0.0, maximum=1.0, value=0.0, interactive=False)
|
| 281 |
with gr.Column():
|
| 282 |
audio_outputs = [
|
| 283 |
+
gr.JSON(label=f"Generated Audio - variation {i+1}") for i in range(N_REPEATS)]
|
| 284 |
submit.click(fn=predict,
|
| 285 |
inputs=[model, text,
|
| 286 |
solver,
|
|
|
|
| 399 |
label="Regularization Strength", minimum=0.0, maximum=1.0, value=0.0, interactive=False)
|
| 400 |
with gr.Column():
|
| 401 |
audio_outputs = [
|
| 402 |
+
gr.JSON(label=f"Generated Audio - variation {i+1}") for i in range(N_REPEATS)]
|
| 403 |
submit.click(fn=predict,
|
| 404 |
inputs=[model, text,
|
| 405 |
solver,
|