Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -84,23 +84,24 @@ def main():
|
|
84 |
|
85 |
audio_data = mic_recorder(start_prompt="▶️", stop_prompt="🛑", key='recorder')
|
86 |
|
87 |
-
if audio_data:
|
88 |
st.audio(audio_data['bytes'])
|
89 |
|
90 |
-
sample_width = audio_data
|
91 |
-
sample_rate = audio_data
|
92 |
num_channels = 1
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
104 |
|
105 |
if __name__ == "__main__":
|
106 |
main()
|
|
|
84 |
|
85 |
audio_data = mic_recorder(start_prompt="▶️", stop_prompt="🛑", key='recorder')
|
86 |
|
87 |
+
if audio_data and 'bytes' in audio_data:
|
88 |
st.audio(audio_data['bytes'])
|
89 |
|
90 |
+
sample_width = audio_data.get("sample_width")
|
91 |
+
sample_rate = audio_data.get("sample_rate")
|
92 |
num_channels = 1
|
93 |
+
|
94 |
+
if sample_width and sample_rate:
|
95 |
+
with wave.open(temp_audio_file_path, 'w') as wave_file:
|
96 |
+
wave_file.setnchannels(num_channels)
|
97 |
+
wave_file.setsampwidth(sample_width)
|
98 |
+
wave_file.setframerate(sample_rate)
|
99 |
+
wave_file.writeframes(audio_data['bytes'])
|
100 |
+
|
101 |
+
audio_text = recognize_speech(audio_data['bytes'])
|
102 |
+
formatted_prompt = format_prompt(audio_text, st.session_state.history)
|
103 |
+
response, audio_file = generate(formatted_prompt, st.session_state.history)
|
104 |
+
display_recognition_result(audio_text, response, audio_file)
|
105 |
|
106 |
if __name__ == "__main__":
|
107 |
main()
|