j-tobias commited on
Commit
68cdf36
·
1 Parent(s): d0e52bb

small changes

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -59,7 +59,7 @@ def getBeats(audiodata:np.ndarray, sr:int):
59
 
60
  def getHRV(beattimes: np.ndarray) -> np.ndarray:
61
  # Calculate instantaneous heart rate
62
- instantaneous_hr = 60 / np.diff(beattimes)
63
 
64
  # # Calculate moving average heart rate (e.g., over 10 beats)
65
  # window_size = 10
@@ -176,15 +176,15 @@ def analyze_single(audio:gr.Audio):
176
 
177
  # Your analysis code goes here
178
  # For example, you could print basic information:
179
- print(f"Audio length: {len(audiodata) / sr:.2f} seconds")
180
- print(f"Sample rate: {sr} Hz")
181
 
182
  zcr = librosa.feature.zero_crossing_rate(audiodata)[0]
183
- print(f"Mean Zero Crossing Rate: {np.mean(zcr):.4f}")
184
 
185
  # Calculate RMS Energy
186
  rms = librosa.feature.rms(y=audiodata)[0]
187
- print(f"Mean RMS Energy: {np.mean(rms):.4f}")
188
 
189
  tempo, beattimes = getBeats(audiodata, sr)
190
  spectogram_wave = plotCombined(audiodata, sr)
@@ -340,7 +340,13 @@ with gr.Blocks() as app:
340
 
341
  analyzebtn2.click(analyze_double, inputs=[audioone,audiotwo], outputs=spectogram_wave2)
342
 
343
- # Add gr.Examples for the Two Audios tab
 
 
 
 
 
 
344
 
345
 
346
  app.launch()
 
59
 
60
  def getHRV(beattimes: np.ndarray) -> np.ndarray:
61
  # Calculate instantaneous heart rate
62
+ instantaneous_hr = 60 * np.diff(beattimes)
63
 
64
  # # Calculate moving average heart rate (e.g., over 10 beats)
65
  # window_size = 10
 
176
 
177
  # Your analysis code goes here
178
  # For example, you could print basic information:
179
+ # print(f"Audio length: {len(audiodata) / sr:.2f} seconds")
180
+ # print(f"Sample rate: {sr} Hz")
181
 
182
  zcr = librosa.feature.zero_crossing_rate(audiodata)[0]
183
+ # print(f"Mean Zero Crossing Rate: {np.mean(zcr):.4f}")
184
 
185
  # Calculate RMS Energy
186
  rms = librosa.feature.rms(y=audiodata)[0]
187
+ # print(f"Mean RMS Energy: {np.mean(rms):.4f}")
188
 
189
  tempo, beattimes = getBeats(audiodata, sr)
190
  spectogram_wave = plotCombined(audiodata, sr)
 
340
 
341
  analyzebtn2.click(analyze_double, inputs=[audioone,audiotwo], outputs=spectogram_wave2)
342
 
343
+ gr.Examples(
344
+ examples=example_pairs,
345
+ inputs=[audioone, audiotwo],
346
+ outputs=spectogram_wave2,
347
+ fn=analyze_double,
348
+ cache_examples=False
349
+ )
350
 
351
 
352
  app.launch()