Spaces:
Build error
Build error
Commit
·
9191a09
1
Parent(s):
db84215
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from audiorecorder import audiorecorder
|
3 |
+
|
4 |
+
|
5 |
+
st.markdown("<h1 style='text-align: center;'>Tell us how you feel</h1>", unsafe_allow_html=True)
|
6 |
+
|
7 |
+
st.write("<h3 style='text-align: center; color: lightSeaGreen;'>we'll generate the insights</h3>", unsafe_allow_html=True)
|
8 |
+
|
9 |
+
audio = audiorecorder("Click to record", "Click to stop recording")
|
10 |
+
|
11 |
+
|
12 |
+
if not audio.empty():
|
13 |
+
# To play audio in frontend:
|
14 |
+
st.audio(audio.export().read())
|
15 |
+
|
16 |
+
# To save audio to a file, use pydub export method:
|
17 |
+
audio.export("audio.wav", format="wav")
|
18 |
+
|
19 |
+
# To get audio properties, use pydub AudioSegment properties:
|
20 |
+
st.text_area(label="Output",
|
21 |
+
value=f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds",
|
22 |
+
height=300)
|