fantaxy commited on
Commit
c866b24
โ€ข
1 Parent(s): 054b0cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -5,6 +5,7 @@ import gradio as gr
5
  import spaces
6
  import os
7
  import uuid
 
8
 
9
  # Importing the model-related functions
10
  from stable_audio_tools import get_pretrained_model
@@ -17,12 +18,18 @@ def load_model():
17
  print("Model loaded successfully.")
18
  return model, model_config
19
 
 
 
 
20
  # Function to set up, generate, and process the audio
21
  @spaces.GPU(duration=120) # Allocate GPU only when this function is called
22
  def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
23
- print(f"Prompt received: {prompt}")
24
- print(f"Settings: Duration={seconds_total}s, Steps={steps}, CFG Scale={cfg_scale}")
25
 
 
 
 
 
26
  device = "cuda" if torch.cuda.is_available() else "cpu"
27
  print(f"Using device: {device}")
28
 
@@ -42,7 +49,7 @@ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
42
 
43
  # Set up text and timing conditioning
44
  conditioning = [{
45
- "prompt": prompt,
46
  "seconds_start": 0,
47
  "seconds_total": seconds_total
48
  }]
@@ -88,17 +95,16 @@ footer {
88
  }
89
  """
90
 
91
-
92
  # Setting up the Gradio Interface
93
  interface = gr.Interface(theme="Nymbo/Nymbo_Theme", css=css,
94
  fn=generate_audio,
95
  inputs=[
96
- gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
97
- gr.Slider(0, 47, value=30, label="Duration in Seconds"),
98
- gr.Slider(10, 150, value=100, step=10, label="Number of Diffusion Steps"),
99
- gr.Slider(1, 15, value=7, step=0.1, label="CFG Scale")
100
  ],
101
- outputs=gr.Audio(type="filepath", label="Generated Audio"),
102
  )
103
 
104
  # Pre-load the model to avoid multiprocessing issues
 
5
  import spaces
6
  import os
7
  import uuid
8
+ from transformers import pipeline
9
 
10
  # Importing the model-related functions
11
  from stable_audio_tools import get_pretrained_model
 
18
  print("Model loaded successfully.")
19
  return model, model_config
20
 
21
+ # ๋ฒˆ์—ญ ๋ชจ๋ธ ๋กœ๋“œ
22
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
23
+
24
  # Function to set up, generate, and process the audio
25
  @spaces.GPU(duration=120) # Allocate GPU only when this function is called
26
  def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
27
+ print(f"Original Prompt: {prompt}")
 
28
 
29
+ # ํ•œ๊ธ€ ํ…์ŠคํŠธ๋ฅผ ์˜์–ด๋กœ ๋ฒˆ์—ญ
30
+ translated_prompt = translator(prompt, max_length=512)[0]['translation_text']
31
+ print(f"Translated Prompt: {translated_prompt}")
32
+
33
  device = "cuda" if torch.cuda.is_available() else "cpu"
34
  print(f"Using device: {device}")
35
 
 
49
 
50
  # Set up text and timing conditioning
51
  conditioning = [{
52
+ "prompt": translated_prompt,
53
  "seconds_start": 0,
54
  "seconds_total": seconds_total
55
  }]
 
95
  }
96
  """
97
 
 
98
  # Setting up the Gradio Interface
99
  interface = gr.Interface(theme="Nymbo/Nymbo_Theme", css=css,
100
  fn=generate_audio,
101
  inputs=[
102
+ gr.Textbox(label="ํ”„๋กฌํ”„ํŠธ", placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”"),
103
+ gr.Slider(0, 47, value=30, label="์˜ค๋””์˜ค ๊ธธ์ด (์ดˆ)"),
104
+ gr.Slider(10, 150, value=100, step=10, label="๋””ํ“จ์ „ ๋‹จ๊ณ„ ์ˆ˜"),
105
+ gr.Slider(1, 15, value=7, step=0.1, label="CFG ์Šค์ผ€์ผ")
106
  ],
107
+ outputs=gr.Audio(type="filepath", label="์ƒ์„ฑ๋œ ์˜ค๋””์˜ค"),
108
  )
109
 
110
  # Pre-load the model to avoid multiprocessing issues