Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -40,13 +40,13 @@ from TTS.tts.models.vits import *
|
|
40 |
|
41 |
import whisper
|
42 |
model = whisper.load_model("base")
|
43 |
-
|
44 |
os.system('pip install voicefixer --upgrade')
|
45 |
from voicefixer import VoiceFixer
|
46 |
voicefixer = VoiceFixer()
|
47 |
-
|
48 |
import openai
|
49 |
-
|
50 |
import torchaudio
|
51 |
from speechbrain.pretrained import SpectralMaskEnhancement
|
52 |
|
@@ -135,7 +135,7 @@ def compute_spec(ref_file):
|
|
135 |
|
136 |
|
137 |
|
138 |
-
def greet(apikey,Voicetoclone,VoiceMicrophone, audio, choice1):
|
139 |
|
140 |
openai.api_key = apikey
|
141 |
|
@@ -175,7 +175,7 @@ def greet(apikey,Voicetoclone,VoiceMicrophone, audio, choice1):
|
|
175 |
|
176 |
messages.append({"role": "assistant", "content": chat_response})
|
177 |
|
178 |
-
text
|
179 |
if Voicetoclone is not None:
|
180 |
reference_files= "%s" % (Voicetoclone)
|
181 |
print("path url")
|
@@ -226,21 +226,21 @@ def greet(apikey,Voicetoclone,VoiceMicrophone, audio, choice1):
|
|
226 |
print(" > Saving output to {}".format(out_path))
|
227 |
ap.save_wav(wav, out_path)
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
|
234 |
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
|
240 |
-
|
241 |
-
|
242 |
|
243 |
-
return [result.text, chat_response,
|
244 |
|
245 |
output_1 = gr.Textbox(label="Speech to Text")
|
246 |
output_2 = gr.Textbox(label="ChatGPT Output")
|
|
|
40 |
|
41 |
import whisper
|
42 |
model = whisper.load_model("base")
|
43 |
+
|
44 |
os.system('pip install voicefixer --upgrade')
|
45 |
from voicefixer import VoiceFixer
|
46 |
voicefixer = VoiceFixer()
|
47 |
+
|
48 |
import openai
|
49 |
+
|
50 |
import torchaudio
|
51 |
from speechbrain.pretrained import SpectralMaskEnhancement
|
52 |
|
|
|
135 |
|
136 |
|
137 |
|
138 |
+
def greet(apikey, Voicetoclone, VoiceMicrophone, audio, choice1):
|
139 |
|
140 |
openai.api_key = apikey
|
141 |
|
|
|
175 |
|
176 |
messages.append({"role": "assistant", "content": chat_response})
|
177 |
|
178 |
+
text= "%s" % (chat_response)
|
179 |
if Voicetoclone is not None:
|
180 |
reference_files= "%s" % (Voicetoclone)
|
181 |
print("path url")
|
|
|
226 |
print(" > Saving output to {}".format(out_path))
|
227 |
ap.save_wav(wav, out_path)
|
228 |
|
229 |
+
voicefixer.restore(input=out_path, # input wav file path
|
230 |
+
output="audio1.wav", # output wav file path
|
231 |
+
cuda=True, # whether to use gpu acceleration
|
232 |
+
mode = 0) # You can try out mode 0, 1 to find out the best result
|
233 |
|
234 |
|
235 |
|
236 |
+
noisy = enhance_model.load_audio(
|
237 |
+
"audio1.wav"
|
238 |
+
).unsqueeze(0)
|
239 |
|
240 |
+
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
241 |
+
torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
|
242 |
|
243 |
+
return [result.text, chat_response, "enhanced.wav"]
|
244 |
|
245 |
output_1 = gr.Textbox(label="Speech to Text")
|
246 |
output_2 = gr.Textbox(label="ChatGPT Output")
|