Spaces:
Sleeping
Sleeping
Create audio_recorder.py
Browse files
src/ui/components/audio_recorder.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# src/ui/components/audio_recorder.py
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from audio_recorder_streamlit import audio_recorder
|
| 4 |
+
|
| 5 |
+
class AudioRecorder:
|
| 6 |
+
def __init__(self):
|
| 7 |
+
"""Initialize audio recorder component"""
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
+
def show(self):
|
| 11 |
+
"""Display audio recorder component"""
|
| 12 |
+
st.write("🎙️ Record Meeting Audio")
|
| 13 |
+
|
| 14 |
+
# Using audio_recorder_streamlit package
|
| 15 |
+
audio_bytes = audio_recorder(
|
| 16 |
+
text="Click to record",
|
| 17 |
+
recording_color="#e74c3c",
|
| 18 |
+
neutral_color="#3498db",
|
| 19 |
+
icon_name="mic"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if audio_bytes:
|
| 23 |
+
st.audio(audio_bytes, format="audio/wav")
|
| 24 |
+
return audio_bytes
|
| 25 |
+
|
| 26 |
+
return None
|
| 27 |
+
|
| 28 |
+
@staticmethod
|
| 29 |
+
def save_audio(audio_bytes, filename: str):
|
| 30 |
+
"""Save recorded audio to file"""
|
| 31 |
+
if audio_bytes:
|
| 32 |
+
with open(filename, "wb") as f:
|
| 33 |
+
f.write(audio_bytes)
|