Spaces:
Running
Running
mrfakename
commited on
Commit
•
ebd29b9
1
Parent(s):
b7f8e0c
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ from huggingface_hub import CommitScheduler, delete_file, hf_hub_download
|
|
8 |
from gradio_client import Client
|
9 |
import pyloudnorm as pyln
|
10 |
import soundfile as sf
|
|
|
11 |
from detoxify import Detoxify
|
12 |
toxicity = Detoxify('original')
|
13 |
with open('harvard_sentences.txt') as f:
|
@@ -515,6 +516,12 @@ def doloudnorm(path):
|
|
515 |
loudness = meter.integrated_loudness(data)
|
516 |
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
|
517 |
sf.write(path, loudness_normalized_audio, rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
##########################
|
519 |
# 2x speedup (hopefully) #
|
520 |
##########################
|
@@ -550,6 +557,10 @@ def synthandreturn(text):
|
|
550 |
raise gr.Error('Unable to call API, please try again :)')
|
551 |
print('Done with', model)
|
552 |
result_storage[model] = result
|
|
|
|
|
|
|
|
|
553 |
# try:
|
554 |
# doloudnorm(result)
|
555 |
# except:
|
|
|
8 |
from gradio_client import Client
|
9 |
import pyloudnorm as pyln
|
10 |
import soundfile as sf
|
11 |
+
import librosa
|
12 |
from detoxify import Detoxify
|
13 |
toxicity = Detoxify('original')
|
14 |
with open('harvard_sentences.txt') as f:
|
|
|
516 |
loudness = meter.integrated_loudness(data)
|
517 |
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
|
518 |
sf.write(path, loudness_normalized_audio, rate)
|
519 |
+
def doresample(path_to_wav):
|
520 |
+
y, sr = librosa.load(path_to_wav, sr=None)
|
521 |
+
if sr > 24000:
|
522 |
+
y_resampled = librosa.resample(y, sr, 24000)
|
523 |
+
librosa.output.write_wav(path_to_wav, y_resampled, 24000)
|
524 |
+
|
525 |
##########################
|
526 |
# 2x speedup (hopefully) #
|
527 |
##########################
|
|
|
557 |
raise gr.Error('Unable to call API, please try again :)')
|
558 |
print('Done with', model)
|
559 |
result_storage[model] = result
|
560 |
+
try:
|
561 |
+
doresample(result)
|
562 |
+
except:
|
563 |
+
pass
|
564 |
# try:
|
565 |
# doloudnorm(result)
|
566 |
# except:
|