Spaces:
Running
Running
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -6,17 +6,20 @@ from gradio_client import Client
|
|
6 |
image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
7 |
|
8 |
def generate_music(prompt):
|
|
|
9 |
client = Client("https://haoheliu-audioldm-48k-text-to-hifiaudio-generation.hf.space/")
|
10 |
result = client.predict(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
17 |
)
|
18 |
print(result)
|
19 |
-
|
|
|
20 |
|
21 |
def generate_voice(prompt):
|
22 |
# Tango APIλ₯Ό μ¬μ©νμ¬ μμ± μμ±
|
@@ -35,12 +38,10 @@ def classify_and_generate_voice(uploaded_image):
|
|
35 |
# μ΄λ―Έμ§ λΆλ₯
|
36 |
predictions = image_model(uploaded_image)
|
37 |
top_prediction = predictions[0]['label'] # κ°μ₯ νλ₯ μ΄ λμ λΆλ₯ κ²°κ³Ό
|
38 |
-
|
39 |
# μμ± μμ±
|
40 |
voice_result = generate_voice("this is " + top_prediction)
|
41 |
# μμ
μμ±
|
42 |
music_result = generate_music("The rnb beat of 85BPM drums." + top_prediction + ".")
|
43 |
-
|
44 |
# λ°νλ μμ± λ° μμ
κ²°κ³Όλ₯Ό Gradio μΈν°νμ΄μ€λ‘ μ λ¬
|
45 |
# μ: voice_result['url'] λλ voice_result['audio_data'] λ±
|
46 |
return top_prediction, voice_result, music_result
|
|
|
6 |
image_model = pipeline("image-classification", model="google/vit-base-patch16-224")
|
7 |
|
8 |
def generate_music(prompt):
|
9 |
+
# audioldm API μ¬μ©νμ¬ μμ
μμ± API νΈμΆ
|
10 |
client = Client("https://haoheliu-audioldm-48k-text-to-hifiaudio-generation.hf.space/")
|
11 |
result = client.predict(
|
12 |
+
"playing piano.", # str in 'Input text' Textbox component
|
13 |
+
"Low quality.", # str in 'Negative prompt' Textbox component
|
14 |
+
5, # int | float (numeric value between 5 and 15) in 'Duration (seconds)' Slider component
|
15 |
+
5.5, # int | float (numeric value between 0 and 7) in 'Guidance scale' Slider component
|
16 |
+
5, # int | float in 'Seed' Number component
|
17 |
+
3, # int | float (numeric value between 1 and 5) in 'Number waveforms to generate' Slider component
|
18 |
+
api_name="/text2audio"
|
19 |
)
|
20 |
print(result)
|
21 |
+
#audio_result = extract_audio(result)
|
22 |
+
return result
|
23 |
|
24 |
def generate_voice(prompt):
|
25 |
# Tango APIλ₯Ό μ¬μ©νμ¬ μμ± μμ±
|
|
|
38 |
# μ΄λ―Έμ§ λΆλ₯
|
39 |
predictions = image_model(uploaded_image)
|
40 |
top_prediction = predictions[0]['label'] # κ°μ₯ νλ₯ μ΄ λμ λΆλ₯ κ²°κ³Ό
|
|
|
41 |
# μμ± μμ±
|
42 |
voice_result = generate_voice("this is " + top_prediction)
|
43 |
# μμ
μμ±
|
44 |
music_result = generate_music("The rnb beat of 85BPM drums." + top_prediction + ".")
|
|
|
45 |
# λ°νλ μμ± λ° μμ
κ²°κ³Όλ₯Ό Gradio μΈν°νμ΄μ€λ‘ μ λ¬
|
46 |
# μ: voice_result['url'] λλ voice_result['audio_data'] λ±
|
47 |
return top_prediction, voice_result, music_result
|