Update app.py
Browse files
app.py
CHANGED
|
@@ -119,12 +119,16 @@ def sample_diffusion(mixture, timbre, ddim_steps=50, eta=0, seed=2023, guidance_
|
|
| 119 |
def tse(gt_file_input, text_input, num_infer_steps, eta, seed, guidance_scale, guidance_rescale):
|
| 120 |
reset_scheduler_dtype()
|
| 121 |
with torch.no_grad():
|
| 122 |
-
mixture, _ = librosa.load(gt_file_input, sr=sample_rate)
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
# Check the length of the audio in samples
|
| 130 |
current_length = len(mixture)
|
|
|
|
| 119 |
def tse(gt_file_input, text_input, num_infer_steps, eta, seed, guidance_scale, guidance_rescale):
|
| 120 |
reset_scheduler_dtype()
|
| 121 |
with torch.no_grad():
|
| 122 |
+
# mixture, _ = librosa.load(gt_file_input, sr=sample_rate)
|
| 123 |
+
mixture, sr = torchaudio.load(gt_file_input)
|
| 124 |
+
if sr != sample_rate:
|
| 125 |
+
resampler = torchaudio.transforms.Resample(orig_freq=sr, new_freq=sample_rate)
|
| 126 |
+
mixture = resampler(mixture)
|
| 127 |
+
sr = sample_rate
|
| 128 |
+
if mixture.shape[0] > 1:
|
| 129 |
+
mixture = torch.mean(mixture, dim=0)
|
| 130 |
+
else:
|
| 131 |
+
mixture = mixture[0]
|
| 132 |
|
| 133 |
# Check the length of the audio in samples
|
| 134 |
current_length = len(mixture)
|