Spaces:
Sleeping
Sleeping
Sarthak-Dayal
commited on
Commit
·
8a3ce6e
1
Parent(s):
dd6635f
Simplify for testing
Browse files
app.py
CHANGED
@@ -1,39 +1,9 @@
|
|
1 |
-
import json
|
2 |
-
|
3 |
import streamlit as st
|
4 |
-
|
5 |
-
import requests
|
6 |
|
7 |
STT_API_KEY = 0 #see discord
|
8 |
STT_URL = 0 #see discord
|
9 |
|
10 |
st.markdown("<h1 style='text-align: center;'>Tell us how you feel</h1>", unsafe_allow_html=True)
|
11 |
|
12 |
-
st.write("<h3 style='text-align: center; color: lightSeaGreen;'>we'll generate the insights</h3>", unsafe_allow_html=True)
|
13 |
-
|
14 |
-
audio = audiorecorder("Click to record", "Click to stop recording")
|
15 |
-
|
16 |
-
|
17 |
-
if not audio.empty():
|
18 |
-
# To play audio in frontend:
|
19 |
-
st.audio(audio.export().read())
|
20 |
-
|
21 |
-
# To save audio to a file, use pydub export method:
|
22 |
-
audio.export("audio.wav", format="wav")
|
23 |
-
|
24 |
-
# Convert audio to text
|
25 |
-
|
26 |
-
headers = {
|
27 |
-
"Content-Type": "audio/wav"
|
28 |
-
}
|
29 |
-
|
30 |
-
with open("audio.wav", "rb") as f:
|
31 |
-
response = requests.post(STT_URL, auth=("apikey", STT_API_KEY), headers=headers, files={'audio.wav': f})
|
32 |
-
|
33 |
-
response_json = response.json()
|
34 |
-
response_text = json.dumps(response_json)
|
35 |
-
|
36 |
-
# To get audio properties, use pydub AudioSegment properties:
|
37 |
-
st.text_area(label="Output",
|
38 |
-
value=f"Frame rate: {audio.frame_rate}, Frame width: {audio.frame_width}, Duration: {audio.duration_seconds} seconds, JSON: {response_text}",
|
39 |
-
height=300)
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
|
|
|
3 |
|
4 |
STT_API_KEY = 0 #see discord
|
5 |
STT_URL = 0 #see discord
|
6 |
|
7 |
st.markdown("<h1 style='text-align: center;'>Tell us how you feel</h1>", unsafe_allow_html=True)
|
8 |
|
9 |
+
st.write("<h3 style='text-align: center; color: lightSeaGreen;'>we'll generate the insights</h3>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|