Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from peft import PeftModel
|
|
3 |
import transformers
|
4 |
import gradio as gr
|
5 |
import os
|
|
|
6 |
os.system('pip install voicefixer --upgrade')
|
7 |
from voicefixer import VoiceFixer
|
8 |
voicefixer = VoiceFixer()
|
@@ -153,7 +154,9 @@ def evaluate(
|
|
153 |
s = generation_output.sequences[0]
|
154 |
output = tokenizer.decode(s)
|
155 |
|
156 |
-
tts.tts_to_file(output.split("### Response:")[1].strip(), speaker_wav = upload, language="en", file_path="output.wav")
|
|
|
|
|
157 |
|
158 |
voicefixer.restore(input="output.wav", # input wav file path
|
159 |
output="audio1.wav", # output wav file path
|
@@ -167,7 +170,7 @@ def evaluate(
|
|
167 |
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
168 |
torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
|
169 |
|
170 |
-
return [result.text,
|
171 |
|
172 |
|
173 |
c1 = gr.Interface(
|
|
|
3 |
import transformers
|
4 |
import gradio as gr
|
5 |
import os
|
6 |
+
import re
|
7 |
os.system('pip install voicefixer --upgrade')
|
8 |
from voicefixer import VoiceFixer
|
9 |
voicefixer = VoiceFixer()
|
|
|
154 |
s = generation_output.sequences[0]
|
155 |
output = tokenizer.decode(s)
|
156 |
|
157 |
+
# tts.tts_to_file(output.split("### Response:")[1].strip(), speaker_wav = upload, language="en", file_path="output.wav")
|
158 |
+
|
159 |
+
tts.tts_to_file(re.split('### Response:|### Instruction:',output)[1].strip(), speaker_wav = upload, language="en", file_path="output.wav")
|
160 |
|
161 |
voicefixer.restore(input="output.wav", # input wav file path
|
162 |
output="audio1.wav", # output wav file path
|
|
|
170 |
enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
|
171 |
torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
|
172 |
|
173 |
+
return [result.text, re.split('### Response:|### Instruction:',output)[1].strip(), "enhanced.wav"]
|
174 |
|
175 |
|
176 |
c1 = gr.Interface(
|