shukdevdatta123 commited on
Commit
da27666
·
verified ·
1 Parent(s): 15132bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -71,10 +71,14 @@ def detect_emotion(text):
71
  def plot_waveform(audio_file):
72
  with wave.open(audio_file, 'r') as w:
73
  signal = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16)
 
 
 
 
74
  plt.figure(figsize=(10, 4))
75
- plt.plot(signal)
76
  plt.title("Audio Waveform")
77
- plt.xlabel("Sample")
78
  plt.ylabel("Amplitude")
79
  st.pyplot(plt)
80
 
 
71
  def plot_waveform(audio_file):
72
  with wave.open(audio_file, 'r') as w:
73
  signal = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16)
74
+ framerate = w.getframerate()
75
+ duration = len(signal) / framerate
76
+ time = np.linspace(0., duration, len(signal))
77
+
78
  plt.figure(figsize=(10, 4))
79
+ plt.plot(time, signal)
80
  plt.title("Audio Waveform")
81
+ plt.xlabel("Duration (seconds)")
82
  plt.ylabel("Amplitude")
83
  st.pyplot(plt)
84