Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,20 +102,20 @@ def main():
|
|
102 |
|
103 |
audio_data = mic_recorder(start_prompt="▶️", stop_prompt="🛑", key='recorder')
|
104 |
|
105 |
-
if audio_data
|
106 |
-
st.audio(audio_data
|
107 |
|
108 |
-
sample_width = audio_data
|
109 |
-
sample_rate = audio_data
|
110 |
num_channels = 1
|
111 |
|
112 |
with wave.open(temp_audio_file_path, 'w') as wave_file:
|
113 |
wave_file.setnchannels(num_channels)
|
114 |
wave_file.setsampwidth(sample_width)
|
115 |
wave_file.setframerate(sample_rate)
|
116 |
-
wave_file.writeframes(audio_data
|
117 |
|
118 |
-
audio_text = recognize_speech(audio_data
|
119 |
formatted_prompt = format_prompt(audio_text, st.session_state.history)
|
120 |
response, audio_file = generate(formatted_prompt, st.session_state.history)
|
121 |
display_recognition_result(audio_text, response, audio_file)
|
|
|
102 |
|
103 |
audio_data = mic_recorder(start_prompt="▶️", stop_prompt="🛑", key='recorder')
|
104 |
|
105 |
+
if audio_data:
|
106 |
+
st.audio(audio_data['bytes'])
|
107 |
|
108 |
+
sample_width = audio_data["sample_width"]
|
109 |
+
sample_rate = audio_data["sample_rate"]
|
110 |
num_channels = 1
|
111 |
|
112 |
with wave.open(temp_audio_file_path, 'w') as wave_file:
|
113 |
wave_file.setnchannels(num_channels)
|
114 |
wave_file.setsampwidth(sample_width)
|
115 |
wave_file.setframerate(sample_rate)
|
116 |
+
wave_file.writeframes(audio_data["frame_data"])
|
117 |
|
118 |
+
audio_text = recognize_speech(audio_data["frame_data"])
|
119 |
formatted_prompt = format_prompt(audio_text, st.session_state.history)
|
120 |
response, audio_file = generate(formatted_prompt, st.session_state.history)
|
121 |
display_recognition_result(audio_text, response, audio_file)
|