awacke1 commited on
Commit
354ca3a
·
1 Parent(s): 5cb2168

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -23,6 +23,29 @@ menu = ["txt", "htm", "md", "py"]
23
  choice = st.sidebar.selectbox("Output File Type:", menu)
24
  model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  def generate_filename(prompt, file_type):
27
  central = pytz.timezone('US/Central')
28
  safe_date_time = datetime.now(central).strftime("%m%d_%I%M")
 
23
  choice = st.sidebar.selectbox("Output File Type:", menu)
24
  model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
25
 
26
+ audio_enabled = st.sidebar.checkbox("Audio", value=False)
27
+
28
+ if audio_enabled:
29
+ def save_and_play_audio(audio_recorder):
30
+ audio_bytes = audio_recorder()
31
+ if audio_bytes:
32
+ filename = generate_filename("Recording", "wav")
33
+ with open(filename, 'wb') as f:
34
+ f.write(audio_bytes)
35
+ st.sidebar.audio(audio_bytes, format="audio/wav")
36
+ return filename
37
+ return None
38
+
39
+ # Updated to call direct from transcription to chat inference.
40
+ filename = save_and_play_audio(audio_recorder)
41
+ if filename is not None:
42
+ transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
43
+ st.sidebar.markdown('### Transcription:')
44
+ st.sidebar.write(transcription)
45
+
46
+ # max_length moved to the sidebar
47
+ max_length = st.sidebar.slider("File section length for large files", min_value=1000, max_value=128000, value=12000, step=1000)
48
+
49
  def generate_filename(prompt, file_type):
50
  central = pytz.timezone('US/Central')
51
  safe_date_time = datetime.now(central).strftime("%m%d_%I%M")