awacke1 commited on
Commit
2593d8b
·
1 Parent(s): cdd13de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -14
app.py CHANGED
@@ -61,23 +61,13 @@ def transcribe_audio(openai_key, file_path, model):
61
  st.write('Reasoning with your transcription..')
62
  st.write(response.json())
63
  response2 = chat_with_model(response.json().get('text'), '') # send transcript to ChatGPT
 
64
  return response2
65
  else:
66
  st.write(response.json())
67
  st.error("Error in API call.")
68
  return None
69
 
70
- def create_file(filename, prompt, response):
71
- if filename.endswith(".txt"):
72
- with open(filename, 'w') as file:
73
- file.write(f"Prompt:\n{prompt}\nResponse:\n{response}")
74
- elif filename.endswith(".htm"):
75
- with open(filename, 'w') as file:
76
- file.write(f"<h1>Prompt:</h1> <p>{prompt}</p> <h1>Response:</h1> <p>{response}</p>")
77
- elif filename.endswith(".md"):
78
- with open(filename, 'w') as file:
79
- file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
80
-
81
  def save_and_play_audio(audio_recorder):
82
  audio_bytes = audio_recorder()
83
  if audio_bytes:
@@ -95,9 +85,6 @@ if filename is not None:
95
  transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
96
  st.markdown('### Transcription:')
97
  st.write(transcription)
98
- #chat_with_model(transcription, '') # push transcript through as prompt
99
- #response2 = chat_with_model(transcription.json().get('text'), '')
100
-
101
 
102
  def truncate_document(document, length):
103
  return document[:length]
 
61
  st.write('Reasoning with your transcription..')
62
  st.write(response.json())
63
  response2 = chat_with_model(response.json().get('text'), '') # send transcript to ChatGPT
64
+ create_file(filename, response, response2)
65
  return response2
66
  else:
67
  st.write(response.json())
68
  st.error("Error in API call.")
69
  return None
70
 
 
 
 
 
 
 
 
 
 
 
 
71
  def save_and_play_audio(audio_recorder):
72
  audio_bytes = audio_recorder()
73
  if audio_bytes:
 
85
  transcription = transcribe_audio(openai.api_key, filename, "whisper-1")
86
  st.markdown('### Transcription:')
87
  st.write(transcription)
 
 
 
88
 
89
  def truncate_document(document, length):
90
  return document[:length]