Spaces:
Running
Running
Merge remote-tracking branch 'origin/main'
Browse files
app.py
CHANGED
|
@@ -581,12 +581,9 @@ def doloudnorm(path):
|
|
| 581 |
loudness = meter.integrated_loudness(data)
|
| 582 |
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
|
| 583 |
sf.write(path, loudness_normalized_audio, rate)
|
| 584 |
-
def doresample(path_to_wav):
|
| 585 |
-
y, sr = librosa.load(path_to_wav, sr=None)
|
| 586 |
-
if sr > 24000:
|
| 587 |
-
y_resampled = librosa.resample(y, sr, 24000)
|
| 588 |
-
librosa.output.write_wav(path_to_wav, y_resampled, 24000)
|
| 589 |
|
|
|
|
|
|
|
| 590 |
##########################
|
| 591 |
# 2x speedup (hopefully) #
|
| 592 |
##########################
|
|
@@ -660,13 +657,16 @@ def synthandreturn(text):
|
|
| 660 |
except:
|
| 661 |
raise gr.Error('Unable to call API, please try again :)')
|
| 662 |
print('Done with', model)
|
| 663 |
-
try:
|
| 664 |
-
|
| 665 |
-
except:
|
| 666 |
-
|
| 667 |
try:
|
| 668 |
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
|
| 669 |
audio = AudioSegment.from_file(result)
|
|
|
|
|
|
|
|
|
|
| 670 |
try:
|
| 671 |
print('Trying to normalize audio')
|
| 672 |
audio = match_target_amplitude(audio, -20)
|
|
|
|
| 581 |
loudness = meter.integrated_loudness(data)
|
| 582 |
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
|
| 583 |
sf.write(path, loudness_normalized_audio, rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
|
| 585 |
+
def doresample(path_to_wav):
|
| 586 |
+
pass
|
| 587 |
##########################
|
| 588 |
# 2x speedup (hopefully) #
|
| 589 |
##########################
|
|
|
|
| 657 |
except:
|
| 658 |
raise gr.Error('Unable to call API, please try again :)')
|
| 659 |
print('Done with', model)
|
| 660 |
+
# try:
|
| 661 |
+
# doresample(result)
|
| 662 |
+
# except:
|
| 663 |
+
# pass
|
| 664 |
try:
|
| 665 |
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
|
| 666 |
audio = AudioSegment.from_file(result)
|
| 667 |
+
current_sr = audio.frame_rate
|
| 668 |
+
if current_sr > 24000:
|
| 669 |
+
audio = audio.set_frame_rate(24000)
|
| 670 |
try:
|
| 671 |
print('Trying to normalize audio')
|
| 672 |
audio = match_target_amplitude(audio, -20)
|