Dimsumcat commited on
Commit
5f353bd
·
verified ·
1 Parent(s): 33006c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import tensorflow as tf
3
  import librosa
 
4
  import numpy as np
5
  import matplotlib.pyplot as plt
6
  import sounddevice as sd
@@ -54,14 +55,15 @@ def process_audio(audio_file, breath_in_time, breath_out_time):
54
  plt.title("Audio Waveform with Inhale/Exhale Segments")
55
  plt.xlabel("Time (s)")
56
  plt.ylabel("Amplitude")
57
- plt.savefig("waveform_highlighted.png")
 
58
  plt.close()
59
 
60
  result_table = "Segment\tType\tDuration (s)\tAmplitude\n" + "\n".join(
61
  f"{row['Segment']}\t{row['Type']}\t{row['Duration (s)']}\t{row['Amplitude']}" for row in results
62
  )
63
 
64
- return result_table, "waveform_highlighted.png"
65
 
66
  except Exception as e:
67
  return f"Error: {str(e)}", None
@@ -125,8 +127,7 @@ with gr.Blocks() as demo:
125
  }
126
  </script>
127
  """):
128
- pass # Ensure this is indented properly
129
-
130
 
131
  def handle_record_and_visualize(breath_in, breath_out):
132
  total_duration = breath_in + breath_out
 
1
  import gradio as gr
2
  import tensorflow as tf
3
  import librosa
4
+ import librosa.display
5
  import numpy as np
6
  import matplotlib.pyplot as plt
7
  import sounddevice as sd
 
55
  plt.title("Audio Waveform with Inhale/Exhale Segments")
56
  plt.xlabel("Time (s)")
57
  plt.ylabel("Amplitude")
58
+ waveform_file = "waveform_highlighted.png"
59
+ plt.savefig(waveform_file)
60
  plt.close()
61
 
62
  result_table = "Segment\tType\tDuration (s)\tAmplitude\n" + "\n".join(
63
  f"{row['Segment']}\t{row['Type']}\t{row['Duration (s)']}\t{row['Amplitude']}" for row in results
64
  )
65
 
66
+ return result_table, waveform_file
67
 
68
  except Exception as e:
69
  return f"Error: {str(e)}", None
 
127
  }
128
  </script>
129
  """):
130
+ pass # Ensure this is indented properly
 
131
 
132
  def handle_record_and_visualize(breath_in, breath_out):
133
  total_duration = breath_in + breath_out