AbdullaShafeeg commited on
Commit
063e974
·
1 Parent(s): 301baa4

updated app

Browse files
Files changed (2) hide show
  1. app.py +16 -4
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,5 +1,8 @@
1
  import streamlit as st
2
  from st_audiorec import st_audiorec
 
 
 
3
 
4
  # Session state
5
  if 'text' not in st.session_state:
@@ -42,10 +45,19 @@ with st.expander('About this App'):
42
  # col3.button('Stop', on_click=stop_monitoring)
43
  # record_button = col3.button('Monitor')
44
  wav_audio_data = st_audiorec()
45
- while True:
46
- if wav_audio_data is not None:
47
- st.audio(wav_audio_data, format=FORMAT, sample_rate=16000)
48
- print(type(wav_audio_data))
 
 
 
 
 
 
 
 
 
49
  # audio_chunk = stream.read(FRAMES_PER_BUFFER)
50
  # audio_data.append(np.frombuffer(audio_chunk, dtype=np.int16))
51
 
 
1
  import streamlit as st
2
  from st_audiorec import st_audiorec
3
+ import matplotlib.pyplot as plt
4
+ import sounddevice as sd
5
+ import numpy as np
6
 
7
  # Session state
8
  if 'text' not in st.session_state:
 
45
  # col3.button('Stop', on_click=stop_monitoring)
46
  # record_button = col3.button('Monitor')
47
  wav_audio_data = st_audiorec()
48
+ if wav_audio_data is not None:
49
+ np_wav = np.frombuffer(wav_audio_data, dtype=np.int16)
50
+ time_axis = np.linspace(0, len(np_wav) / 16000, num=len(np_wav))
51
+
52
+ plt.figure(figsize=(10, 4))
53
+ plt.plot(time_axis, np_wav)
54
+ plt.title("Original Waveform")
55
+ plt.xlabel("Time (s)")
56
+ plt.ylabel("Amplitude")
57
+ st.pyplot(plt)
58
+ # if wav_audio_data is not None:
59
+ # st.audio(wav_audio_data, format=FORMAT, sample_rate=16000)
60
+
61
  # audio_chunk = stream.read(FRAMES_PER_BUFFER)
62
  # audio_data.append(np.frombuffer(audio_chunk, dtype=np.int16))
63
 
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
  pyaudio
2
- streamlit-audiorec
 
 
 
1
  pyaudio
2
+ streamlit-audiorec
3
+ matplotlib
4
+ sounddevice