Liusuthu commited on
Commit
3744361
Β·
verified Β·
1 Parent(s): 0b5cf3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -34,13 +34,13 @@ def classify_continuous(audio):
34
  sample_rate, signal = audio # θΏ™ζ˜―θ―­ιŸ³ηš„θΎ“ε…₯
35
  signal = signal.astype(np.float32)
36
  signal /= np.max(np.abs(signal))
37
- sf.write("a.wav", signal, sample_rate)
38
- signal, sample_rate = torchaudio.load("a.wav")
39
  signal1 = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)(
40
  signal
41
  )
42
- torchaudio.save("out.wav", signal1, 16000, encoding="PCM_S", bits_per_sample=16)
43
- Audio = "out.wav"
44
  speech, sample_rate = AudioReader.read_wav_file(Audio)
45
  if signal == "none":
46
  return "none", "none", "haha"
@@ -96,7 +96,6 @@ with gr.Blocks(css="app.css") as video:
96
  out1=gr.Textbox(label="θ―­ιŸ³εˆ†ζžη»“ζžœ")
97
  out2=gr.Textbox(label="ιŸ³ι’‘ζƒ…ζ„Ÿθ―†εˆ«1")
98
  out3=gr.Textbox(label="ιŸ³ι’‘ζƒ…ζ„Ÿθ―†εˆ«2")
99
- internal_audio=gr.Audio(interactive=False)
100
  gr.Examples(
101
  [
102
  "videos/video1.mp4",
@@ -132,7 +131,7 @@ with gr.Blocks(css="app.css") as video:
132
  audio_test_button.click(
133
  fn=classify_continuous,
134
  inputs=output_audio,
135
- outputs=[out1,out2,out3,internal_audio]
136
  )
137
 
138
  ####################################
 
34
  sample_rate, signal = audio # θΏ™ζ˜―θ―­ιŸ³ηš„θΎ“ε…₯
35
  signal = signal.astype(np.float32)
36
  signal /= np.max(np.abs(signal))
37
+ sf.write("data/a.wav", signal, sample_rate)
38
+ signal, sample_rate = torchaudio.load("data/a.wav")
39
  signal1 = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)(
40
  signal
41
  )
42
+ torchaudio.save("data/out.wav", signal1, 16000, encoding="PCM_S", bits_per_sample=16)
43
+ Audio = "data/out.wav"
44
  speech, sample_rate = AudioReader.read_wav_file(Audio)
45
  if signal == "none":
46
  return "none", "none", "haha"
 
96
  out1=gr.Textbox(label="θ―­ιŸ³εˆ†ζžη»“ζžœ")
97
  out2=gr.Textbox(label="ιŸ³ι’‘ζƒ…ζ„Ÿθ―†εˆ«1")
98
  out3=gr.Textbox(label="ιŸ³ι’‘ζƒ…ζ„Ÿθ―†εˆ«2")
 
99
  gr.Examples(
100
  [
101
  "videos/video1.mp4",
 
131
  audio_test_button.click(
132
  fn=classify_continuous,
133
  inputs=output_audio,
134
+ outputs=[out1,out2,out3]
135
  )
136
 
137
  ####################################