awacke1 commited on
Commit
bdcc27e
·
1 Parent(s): e4971d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -68,14 +68,6 @@ def save_and_play_audio(audio_recorder):
68
  return filename
69
  return None
70
 
71
- filename = save_and_play_audio(audio_recorder)
72
- if filename is not None:
73
- #if st.button("Transcribe"):
74
-
75
- transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
76
- st.write(transcription)
77
- chat_with_model(transcription, '') # push transcript through as prompt
78
-
79
  def create_file(filename, prompt, response):
80
  if filename.endswith(".txt"):
81
  with open(filename, 'w') as file:
@@ -86,13 +78,10 @@ def create_file(filename, prompt, response):
86
  elif filename.endswith(".md"):
87
  with open(filename, 'w') as file:
88
  file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
89
-
90
  def truncate_document(document, length):
91
  return document[:length]
92
-
93
  def divide_document(document, max_length):
94
  return [document[i:i+max_length] for i in range(0, len(document), max_length)]
95
-
96
  def get_table_download_link(file_path):
97
  with open(file_path, 'r') as file:
98
  data = file.read()
@@ -110,6 +99,22 @@ def get_table_download_link(file_path):
110
  href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
111
  return href
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  def CompressXML(xml_text):
114
  root = ET.fromstring(xml_text)
115
  for elem in list(root.iter()):
 
68
  return filename
69
  return None
70
 
 
 
 
 
 
 
 
 
71
  def create_file(filename, prompt, response):
72
  if filename.endswith(".txt"):
73
  with open(filename, 'w') as file:
 
78
  elif filename.endswith(".md"):
79
  with open(filename, 'w') as file:
80
  file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
 
81
  def truncate_document(document, length):
82
  return document[:length]
 
83
  def divide_document(document, max_length):
84
  return [document[i:i+max_length] for i in range(0, len(document), max_length)]
 
85
  def get_table_download_link(file_path):
86
  with open(file_path, 'r') as file:
87
  data = file.read()
 
99
  href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
100
  return href
101
 
102
+
103
+
104
+ # Audio, transcribe, GPT:
105
+ filename = save_and_play_audio(audio_recorder)
106
+ if filename is not None:
107
+ transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
108
+ st.write(transcription)
109
+ gptOutput = chat_with_model(transcription, '') # push transcript through as prompt
110
+ filename = generate_filename(transcription, choice)
111
+ create_file(filename, transcription, gptOutput)
112
+ st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
113
+
114
+
115
+
116
+
117
+
118
  def CompressXML(xml_text):
119
  root = ET.fromstring(xml_text)
120
  for elem in list(root.iter()):