codingchild commited on
Commit
c52d065
1 Parent(s): 16a6f2b

stt complete

Browse files
Files changed (4) hide show
  1. audio.wav +0 -0
  2. modules/whisper_modules.py +3 -3
  3. requirements.txt +2 -1
  4. vocal_app.py +26 -3
audio.wav ADDED
Binary file (13.1 kB). View file
 
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
@@ -3,13 +3,25 @@ import openai
3
 
4
  from dotenv import dotenv_values
5
  from streamlit_chat import message
6
- from modules.gpt_modules import gpt_call
7
  from langchain.prompts import PromptTemplate
8
  from bots.judgement_bot import debate_judgement
9
  import numpy as np
10
  from collections import Counter
11
  import re
12
- #import SessionState
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Page Configuration
15
  st.set_page_config(page_title="Streamlit App")
@@ -356,7 +368,18 @@ def page4():
356
 
357
  with container:
358
  #TODO (웅기형) : STT 붙이는 부분
359
- #TODO user_input에 음성인식된 text를 전달해주면
 
 
 
 
 
 
 
 
 
 
 
360
  with st.form(key='my_form', clear_on_submit=True):
361
  user_input = st.text_area("You:", key='input', height=100)
362
  submit_buttom = st.form_submit_button(label='Send')
 
3
 
4
  from dotenv import dotenv_values
5
  from streamlit_chat import message
6
+
7
  from langchain.prompts import PromptTemplate
8
  from bots.judgement_bot import debate_judgement
9
  import numpy as np
10
  from collections import Counter
11
  import re
12
+ from audiorecorder import audiorecorder
13
+
14
+ config = dotenv_values(".env")
15
+
16
+ # modules
17
+ from modules.gpt_modules import gpt_call
18
+ #from modules.whisper_modules import transcribe
19
+
20
+ openai.organization = config.get('OPENAI_ORGANIZATION')
21
+ openai.api_key = config.get('OPENAI_API_KEY')
22
+
23
+
24
+
25
 
26
  # Page Configuration
27
  st.set_page_config(page_title="Streamlit App")
 
368
 
369
  with container:
370
  #TODO (웅기형) : STT 붙이는 부분
371
+ audio = audiorecorder("Click to record", "Recording...")
372
+
373
+ if audio:
374
+
375
+ wav_file = open("audio.wav", "wb")
376
+ wav_file.write(audio.tobytes())
377
+
378
+ audio_file= open("audio.wav", "rb")
379
+
380
+ whisper_result = openai.Audio.transcribe("whisper-1", audio_file).text
381
+
382
+
383
  with st.form(key='my_form', clear_on_submit=True):
384
  user_input = st.text_area("You:", key='input', height=100)
385
  submit_buttom = st.form_submit_button(label='Send')