Spaces:
Sleeping
Sleeping
Update home.py
Browse files
home.py
CHANGED
|
@@ -1,49 +1,19 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
st.header("V's Gradio Sandbox")
|
| 12 |
-
st.subheader("test...test...test")
|
| 13 |
-
|
| 14 |
-
# display the menu
|
| 15 |
-
show_pages(
|
| 16 |
-
[
|
| 17 |
-
Page("Home.py", "Home"),
|
| 18 |
-
Page("pages/grAudioRecorder.py", "Streaming Audio Test"),
|
| 19 |
-
Page("pages/grRealtimeTranscriber.py", "Realtime Transcriber"),
|
| 20 |
-
]
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
##
|
| 24 |
-
## selected brand
|
| 25 |
-
##
|
| 26 |
-
if 'selected_brand' not in st.session_state:
|
| 27 |
-
st.session_state['selected_brand'] = "Taco Bell"
|
| 28 |
-
|
| 29 |
-
selectOptions = ["Taco Bell", "KFC", "Habit Burger", "Pizza Hut"]
|
| 30 |
-
selectedIndex = selectOptions.index(st.session_state['selected_brand'])
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
)
|
| 38 |
-
# Update the session state with the newly selected option
|
| 39 |
-
st.session_state['selected_brand'] = selected_brand
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
st.markdown(
|
| 44 |
-
"""
|
| 45 |
-
This is a test of the Emergency broadcast system. If this were a real test then this would not be a test.
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
"""
|
| 49 |
-
)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import soundfile as sf
|
| 3 |
+
import numpy as np
|
| 4 |
|
| 5 |
+
def save_audio(audio):
|
| 6 |
+
# audio is a tuple of (sample_rate, data)
|
| 7 |
+
sample_rate, data = audio
|
| 8 |
+
sf.write('recorded_audio.wav', data, sample_rate)
|
| 9 |
+
return "Audio saved successfully!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Create the Gradio interface
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=save_audio,
|
| 14 |
+
inputs=gr.Audio("microphone",type="numpy"),
|
| 15 |
+
outputs="text"
|
| 16 |
)
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|