Update goai_helpers/utils.py
Browse files- goai_helpers/utils.py +0 -36
goai_helpers/utils.py
CHANGED
@@ -14,8 +14,6 @@ from TTS.tts.layers.xtts.tokenizer import VoiceBpeTokenizer
|
|
14 |
from TTS.tts.configs.xtts_config import XttsConfig
|
15 |
from TTS.tts.models.xtts import Xtts
|
16 |
|
17 |
-
from resemble_enhance.enhancer.inference import denoise, enhance
|
18 |
-
|
19 |
|
20 |
def download_file(url: str, destination: str, token: str = None):
|
21 |
"""
|
@@ -74,37 +72,3 @@ def diviser_phrases_moore(texte: str) -> list:
|
|
74 |
|
75 |
return phrases
|
76 |
|
77 |
-
|
78 |
-
# function to enhance speech
|
79 |
-
@spaces.GPU
|
80 |
-
def enhance_speech(audio_array, sampling_rate, solver, nfe, tau, denoise_before_enhancement):
|
81 |
-
solver = solver.lower()
|
82 |
-
nfe = int(nfe)
|
83 |
-
lambd = 0.9 if denoise_before_enhancement else 0.1
|
84 |
-
|
85 |
-
# device
|
86 |
-
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
87 |
-
|
88 |
-
def denoise_audio():
|
89 |
-
try:
|
90 |
-
return denoise(audio_array, sampling_rate, device)
|
91 |
-
except Exception as e:
|
92 |
-
print("> Error while denoising : ", str(e))
|
93 |
-
return audio_array, sampling_rate
|
94 |
-
|
95 |
-
def enhance_audio():
|
96 |
-
try:
|
97 |
-
return enhance(audio_array, sampling_rate, device, nfe=nfe, solver=solver, lambd=lambd, tau=tau)
|
98 |
-
except Exception as e:
|
99 |
-
print("> Error while enhancement : ", str(e))
|
100 |
-
return audio_array, sampling_rate
|
101 |
-
|
102 |
-
with concurrent.futures.ThreadPoolExecutor() as executor:
|
103 |
-
future_denoise = executor.submit(denoise_audio)
|
104 |
-
future_enhance = executor.submit(enhance_audio)
|
105 |
-
|
106 |
-
denoised_audio, new_sr1 = future_denoise.result()
|
107 |
-
enhanced_audio, new_sr2 = future_enhance.result()
|
108 |
-
|
109 |
-
# convert to numpy and return
|
110 |
-
return (new_sr1, denoised_audio.cpu().numpy()), (new_sr2, enhanced_audio.cpu().numpy())
|
|
|
14 |
from TTS.tts.configs.xtts_config import XttsConfig
|
15 |
from TTS.tts.models.xtts import Xtts
|
16 |
|
|
|
|
|
17 |
|
18 |
def download_file(url: str, destination: str, token: str = None):
|
19 |
"""
|
|
|
72 |
|
73 |
return phrases
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|