AdrianLambdaVerde commited on
Commit
cabf3df
·
1 Parent(s): 2b30df7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -6,17 +6,17 @@ st.markdown("<h1 style='text-align: center;'>Tell us how you feel</h1>", unsafe_
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)
 
6
 
7
  st.write("<h3 style='text-align: center; color: lightSeaGreen;'>we'll generate the insights</h3>", unsafe_allow_html=True)
8
 
9
+ # Create a speech_recorder component.
10
+ speech_recorder = hf.spaces.component("speech_recorder", language="en", sampling_rate=16000)
11
 
12
+ # Add a button to the app that allows users to start and stop recording.
13
+ button = st.button("Record speech")
14
 
15
+ # When the user clicks the button, start recording the user's speech.
16
+ if button.clicked:
17
+ speech_recorder.start()
18
 
19
+ # When the user stops recording, return a transcript of the user's speech.
20
+ if speech_recorder.is_finished:
21
+ transcript = speech_recorder.get_transcript()
22
+ st.write(transcript)