Kevin676 commited on
Commit
33b0017
1 Parent(s): 8a2ba1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -8,6 +8,12 @@ from voicefixer import VoiceFixer
8
  voicefixer = VoiceFixer()
9
  import gradio as gr
10
  import openai
 
 
 
 
 
 
11
 
12
  mes1 = [
13
  {"role": "system", "content": "You are a TOEFL examiner. Help me improve my oral Englsih and give me feedback."}
@@ -70,9 +76,14 @@ def transcribe(apikey, upload, audio, choice1):
70
  voicefixer.restore(input="output.wav", # input wav file path
71
  output="audio1.wav", # output wav file path
72
  cuda=True, # whether to use gpu acceleration
73
- mode = 1) # You can try out mode 0, 1 to find out the best result
 
 
 
 
 
74
 
75
- return [result.text, chat_response, "audio1.wav"]
76
 
77
  output_1 = gr.Textbox(label="Speech to Text")
78
  output_2 = gr.Textbox(label="ChatGPT Output")
 
8
  voicefixer = VoiceFixer()
9
  import gradio as gr
10
  import openai
11
+ import torchaudio
12
+ from speechbrain.pretrained import WaveformEnhancement
13
+ enhance_model = WaveformEnhancement.from_hparams(
14
+ source="speechbrain/mtl-mimic-voicebank",
15
+ savedir="pretrained_models/mtl-mimic-voicebank",
16
+ )
17
 
18
  mes1 = [
19
  {"role": "system", "content": "You are a TOEFL examiner. Help me improve my oral Englsih and give me feedback."}
 
76
  voicefixer.restore(input="output.wav", # input wav file path
77
  output="audio1.wav", # output wav file path
78
  cuda=True, # whether to use gpu acceleration
79
+ mode = 2) # You can try out mode 0, 1, or 2 to find out the best result
80
+
81
+ enhanced = enhance_model.enhance_file("audio1.wav")
82
+
83
+ # Saving enhanced signal on disk
84
+ torchaudio.save("enhanced.wav", enhanced.unsqueeze(0).cpu(), 16000)
85
 
86
+ return [result.text, chat_response, "enhanced.wav"]
87
 
88
  output_1 = gr.Textbox(label="Speech to Text")
89
  output_2 = gr.Textbox(label="ChatGPT Output")