Ridealist commited on
Commit
f2f52ca
2 Parent(s): a91ca13 c52d065

Merge remote-tracking branch 'upstream/master' into page_4to6_ui

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. modules/whisper_modules.py +3 -3
  3. requirements.txt +2 -1
  4. vocal_app.py +26 -1
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  __pycache__/
2
  .env
3
  *.mp3
 
4
  /audio
 
1
  __pycache__/
2
  .env
3
  *.mp3
4
+ *.wav
5
  /audio
modules/whisper_modules.py CHANGED
@@ -63,10 +63,10 @@ def debate_in_sound(audio):
63
 
64
 
65
  def transcribe(audio):
66
- os.rename(audio, audio + '.wav')
67
- file = open(audio + '.wav', "rb")
68
 
69
- result = openai.Audio.transcribe("whisper-1", file).text
 
 
70
 
71
  return result
72
 
 
63
 
64
 
65
  def transcribe(audio):
 
 
66
 
67
+ audio_file= open("./audio.mp3", "rb")
68
+
69
+ result = openai.Audio.transcribe("whisper-1", audio_file).text
70
 
71
  return result
72
 
requirements.txt CHANGED
@@ -5,4 +5,5 @@ langchain
5
  python-dotenv
6
  gradio
7
  git+https://github.com/openai/whisper.git
8
- pymilvus
 
 
5
  python-dotenv
6
  gradio
7
  git+https://github.com/openai/whisper.git
8
+ pymilvus
9
+ streamlit-audiorecorder
vocal_app.py CHANGED
@@ -6,6 +6,20 @@ from streamlit_chat import message
6
  from modules.gpt_modules import gpt_call
7
  from bots.judgement_bot import debate_judgement
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Page Configuration
11
  st.set_page_config(page_title="Streamlit App")
@@ -321,7 +335,18 @@ def page4():
321
 
322
  with container:
323
  #TODO (웅기형) : STT 붙이는 부분
324
- #TODO user_input에 음성인식된 text를 전달해주면
 
 
 
 
 
 
 
 
 
 
 
325
  with st.form(key='my_form', clear_on_submit=True):
326
  user_input = st.text_area("You:", key='input', height=100)
327
  submit_buttom = st.form_submit_button(label='Send')
 
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
16
+ #from modules.whisper_modules import transcribe
17
+
18
+ config = dotenv_values(".env")
19
+
20
+ openai.organization = config.get('OPENAI_ORGANIZATION')
21
+ openai.api_key = config.get('OPENAI_API_KEY')
22
+
23
 
24
  # Page Configuration
25
  st.set_page_config(page_title="Streamlit App")
 
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')