Ridealist commited on
Commit
5b7bee5
โ€ข
1 Parent(s): f2f52ca

refactor: edit structure

Browse files
Files changed (1) hide show
  1. 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 langchain.prompts import PromptTemplate
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
- elif option_result == "Evaluation Only":
160
- page_control_func = page_2_7_controller
161
- elif option_result == "Analyzing Utterances":
162
- page_control_func = page_2_8_controller
 
163
 
164
  if st.button(
165
  label='Submit all information',
@@ -335,22 +336,30 @@ def page4():
335
 
336
  with container:
337
  #TODO (์›…๊ธฐํ˜•) : STT ๋ถ™์ด๋Š” ๋ถ€๋ถ„
338
- audio = audiorecorder("Click to record", "Recording...")
339
-
340
- if audio:
341
 
 
342
  wav_file = open("audio.wav", "wb")
343
- wav_file.write(audio.tobytes())
344
-
345
- audio_file= open("audio.wav", "rb")
346
-
347
- whisper_result = openai.Audio.transcribe("whisper-1", audio_file).text
 
 
 
 
 
 
348
 
349
-
350
  with st.form(key='my_form', clear_on_submit=True):
351
- user_input = st.text_area("You:", key='input', height=100)
 
 
 
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)