Kangarroar commited on
Commit
3ce3c7f
1 Parent(s): 9216d6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -19
app.py CHANGED
@@ -27,7 +27,7 @@ from infer_tools.infer_tool import *
27
  import io
28
 
29
  clip_completed = False
30
- def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2):
31
  logging.getLogger('numba').setLevel(logging.WARNING)
32
  title = int(title)
33
  title2 = int(title2)
@@ -47,8 +47,8 @@ def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title
47
 
48
  # Show the spinner and run the run_clip function inside the 'with' block
49
  with st.spinner("Rendering Audio..."):
50
- f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=title2, use_crepe=True, use_pe=True, thre=0.05,
51
- use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen)
52
  clip_completed = True
53
  if clip_completed:
54
 
@@ -61,11 +61,10 @@ st.set_page_config(
61
  initial_sidebar_state="expanded",
62
  )
63
  ############
64
- st.title('DIFF-SVC Render')
65
-
66
- ###CKPT LOADER
67
- ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
68
- # Check if user uploaded a CKPT file
69
  if ckpt is not None:
70
  #TEMP FUNCTION
71
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
@@ -80,8 +79,7 @@ if ckpt is not None:
80
  if "ckpt_temp_file" in locals():
81
  st.success("File saved to: {}".format(ckpt_temp_file))
82
  # File uploader
83
- config = st.file_uploader("Choose your config", type= 'yaml')
84
- # Check if user uploaded a config file
85
  if config is not None:
86
  #TEMP FUNCTION
87
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp:
@@ -95,8 +93,8 @@ if config is not None:
95
  # Display the file path
96
  if "config_temp_file" in locals():
97
  st.success("File saved to: {}".format(config_temp_file))
98
- audio = st.file_uploader("Choose your audio", type=["wav"])
99
- # Check if user uploaded an audio file
100
  if audio is not None:
101
  #EMP FUNCTION
102
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
@@ -110,16 +108,30 @@ if audio is not None:
110
  # Display the file path
111
  if "audio_temp_file" in locals():
112
  st.success("File saved to: {}".format(audio_temp_file))
113
- # Add a text input for the title with a default value of 0
114
- title = st.text_input("Key", value="0")
115
- title2 = st.text_input("Speedup", value="20")
116
- password = st.text_input("Enter password")
 
 
 
 
 
 
 
 
 
 
117
  correct_password = os.environ.get("gatepassword")
118
- # Add a button to start the rendering process
119
- # Add a button to start the rendering process
 
 
 
 
120
  if st.button("Render audio"):
121
  if password == correct_password:
122
- render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2)
123
 
124
  else:
125
  st.error("Incorrect password")
 
27
  import io
28
 
29
  clip_completed = False
30
+ def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2, Crepe, noise_step, use_mel_as_base):
31
  logging.getLogger('numba').setLevel(logging.WARNING)
32
  title = int(title)
33
  title2 = int(title2)
 
47
 
48
  # Show the spinner and run the run_clip function inside the 'with' block
49
  with st.spinner("Rendering Audio..."):
50
+ f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=title2, use_crepe=Crepe, use_pe=False, thre=0.05,
51
+ use_gt_mel=use_mel_as_base, add_noise_step=noise_step,project_name=project_name,out_path=wav_gen)
52
  clip_completed = True
53
  if clip_completed:
54
 
 
61
  initial_sidebar_state="expanded",
62
  )
63
  ############
64
+ col1, col2 = st.columns(2)
65
+ col1.title('DIFF-SVC Render')
66
+ col2.title('Settings')
67
+ ckpt = col1.file_uploader("Choose your CKPT", type='ckpt')
 
68
  if ckpt is not None:
69
  #TEMP FUNCTION
70
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
 
79
  if "ckpt_temp_file" in locals():
80
  st.success("File saved to: {}".format(ckpt_temp_file))
81
  # File uploader
82
+ config = col1.file_uploader("Choose your config", type='yaml')
 
83
  if config is not None:
84
  #TEMP FUNCTION
85
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp:
 
93
  # Display the file path
94
  if "config_temp_file" in locals():
95
  st.success("File saved to: {}".format(config_temp_file))
96
+
97
+ audio = col1.file_uploader("Choose your audio", type=["wav"])
98
  if audio is not None:
99
  #EMP FUNCTION
100
  with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
 
108
  # Display the file path
109
  if "audio_temp_file" in locals():
110
  st.success("File saved to: {}".format(audio_temp_file))
111
+
112
+ title = col2.number_input("Key", value=0, step=1, min_value=-12, max_value=12)
113
+ title2 = col2.number_input("Speedup", value=20, step=1, min_value=5, max_value=100)
114
+ title3 = col2.number_input("Gender Flag", value=1.00, step=0.01, min_value=0.70, max_value=1.30, help='Default is 1.0, it works by decimals, setting it at 1.05 will make your render sound more female-ish, setting it to 0.95 will make it sound more masculine, for example.')
115
+ choice = col2.selectbox('Resampler', ('Crepe', 'Harvest'))
116
+ # Create checkbox for using Mel as Base
117
+ use_mel_as_base = col2.checkbox('Use Mel as Base', value=False, help='gt mel: Enabling this will use the input audio as a base and will unlock a new parameter, do not use this if you dont know what it does.')
118
+ noise_step = 600
119
+ # Show "Noise Step" input parameter when checkbox is checked
120
+ if use_mel_as_base:
121
+ noise_step = col2.number_input('Noise Step', value=600, min_value=1, max_value=1000, step=50)
122
+ else:
123
+ noise_step = 600
124
+ password = col2.text_input("Enter password", help='Password can be got by agreeing to TOS and getting allowed after validation, you can go to the TOS here:')
125
  correct_password = os.environ.get("gatepassword")
126
+ if choice == Crepe
127
+ Crepe = True
128
+ else:
129
+ Crepe = False
130
+
131
+ ###
132
  if st.button("Render audio"):
133
  if password == correct_password:
134
+ render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title, title2, noise_step, Crepe, use_mel_as_base)
135
 
136
  else:
137
  st.error("Incorrect password")