Spaces:
Runtime error
Runtime error
refactor: edit structure
Browse files- vocal_app.py +27 -18
vocal_app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
from gtts import gTTS
|
4 |
from collections import Counter
|
5 |
from streamlit_chat import message
|
6 |
-
from modules.gpt_modules import gpt_call
|
7 |
-
from bots.judgement_bot import debate_judgement
|
8 |
|
9 |
-
from
|
10 |
from bots.judgement_bot import debate_judgement
|
11 |
from collections import Counter
|
12 |
from audiorecorder import audiorecorder
|
|
|
13 |
|
14 |
# modules
|
15 |
from modules.gpt_modules import gpt_call
|
@@ -156,10 +156,11 @@ def page2():
|
|
156 |
# add controller
|
157 |
if option_result == "Total Debate":
|
158 |
page_control_func = page_2_3_controller
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
163 |
|
164 |
if st.button(
|
165 |
label='Submit all information',
|
@@ -335,22 +336,30 @@ def page4():
|
|
335 |
|
336 |
with container:
|
337 |
#TODO (์
๊ธฐํ) : STT ๋ถ์ด๋ ๋ถ๋ถ
|
338 |
-
|
339 |
-
|
340 |
-
if audio:
|
341 |
|
|
|
342 |
wav_file = open("audio.wav", "wb")
|
343 |
-
wav_file.write(
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
349 |
-
|
350 |
with st.form(key='my_form', clear_on_submit=True):
|
351 |
-
|
|
|
|
|
|
|
352 |
submit_buttom = st.form_submit_button(label='Send')
|
353 |
-
|
354 |
if submit_buttom and user_input:
|
355 |
output = generate_response(user_input)
|
356 |
st.session_state['user_debate_history'].append(user_input)
|
|
|
1 |
import streamlit as st
|
2 |
+
import openai
|
3 |
|
4 |
from gtts import gTTS
|
5 |
from collections import Counter
|
6 |
from streamlit_chat import message
|
|
|
|
|
7 |
|
8 |
+
from dotenv import dotenv_values
|
9 |
from bots.judgement_bot import debate_judgement
|
10 |
from collections import Counter
|
11 |
from audiorecorder import audiorecorder
|
12 |
+
from st_custom_components import st_audiorec
|
13 |
|
14 |
# modules
|
15 |
from modules.gpt_modules import gpt_call
|
|
|
156 |
# add controller
|
157 |
if option_result == "Total Debate":
|
158 |
page_control_func = page_2_3_controller
|
159 |
+
#TODO page_2_7_controller, page_2_8_controller ๋ง๋ค๊ธฐ!
|
160 |
+
# elif option_result == "Evaluation Only":
|
161 |
+
# page_control_func = page_2_7_controller
|
162 |
+
# elif option_result == "Analyzing Utterances":
|
163 |
+
# page_control_func = page_2_8_controller
|
164 |
|
165 |
if st.button(
|
166 |
label='Submit all information',
|
|
|
336 |
|
337 |
with container:
|
338 |
#TODO (์
๊ธฐํ) : STT ๋ถ์ด๋ ๋ถ๋ถ
|
339 |
+
# audio_data = st_audiorec()
|
340 |
+
audio_data = audiorecorder("Click to record", "Recording...")
|
|
|
341 |
|
342 |
+
if audio_data is not None:
|
343 |
wav_file = open("audio.wav", "wb")
|
344 |
+
wav_file.write(audio_data.tobytes())
|
345 |
+
wav_file.close()
|
346 |
+
|
347 |
+
with open("audio.wav", "rb") as audio_file:
|
348 |
+
whisper_result = openai.Audio.transcribe(
|
349 |
+
model = "whisper-1",
|
350 |
+
file = audio_file,
|
351 |
+
response_format = "text",
|
352 |
+
language = "en"
|
353 |
+
)
|
354 |
+
print(whisper_result)
|
355 |
|
|
|
356 |
with st.form(key='my_form', clear_on_submit=True):
|
357 |
+
if whisper_result:
|
358 |
+
user_input = whisper_result
|
359 |
+
else:
|
360 |
+
user_input = st.text_area("You:", key='input', height=100)
|
361 |
submit_buttom = st.form_submit_button(label='Send')
|
362 |
+
|
363 |
if submit_buttom and user_input:
|
364 |
output = generate_response(user_input)
|
365 |
st.session_state['user_debate_history'].append(user_input)
|