Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,13 @@ 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Audio record and transcribe:
|
28 |
def transcribe_audio_ui(openai_key, file_path):
|
29 |
OPENAI_API_KEY = openai_key
|
@@ -51,8 +58,7 @@ def transcribe_audio_ui(openai_key, file_path):
|
|
51 |
def save_and_play_audio(audio_recorder):
|
52 |
audio_bytes = audio_recorder()
|
53 |
if audio_bytes:
|
54 |
-
|
55 |
-
filename = f"audio_{now.strftime('%Y%m%d_%H%M%S')}.wav"
|
56 |
with open(filename, 'wb') as f:
|
57 |
f.write(audio_bytes)
|
58 |
st.audio(audio_bytes, format="audio/wav")
|
@@ -75,12 +81,6 @@ def chat_with_model(prompt, document_section):
|
|
75 |
response = openai.ChatCompletion.create(model=model, messages=conversation)
|
76 |
return response['choices'][0]['message']['content']
|
77 |
|
78 |
-
def generate_filename(prompt, file_type):
|
79 |
-
central = pytz.timezone('US/Central')
|
80 |
-
safe_date_time = datetime.now(central).strftime("%m%d_%I%M")
|
81 |
-
safe_prompt = "".join(x for x in prompt if x.isalnum())[:45]
|
82 |
-
return f"{safe_date_time}_{safe_prompt}.{file_type}"
|
83 |
-
|
84 |
def create_file(filename, prompt, response):
|
85 |
if filename.endswith(".txt"):
|
86 |
with open(filename, 'w') as file:
|
|
|
24 |
model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
|
25 |
|
26 |
|
27 |
+
def generate_filename(prompt, file_type):
|
28 |
+
central = pytz.timezone('US/Central')
|
29 |
+
safe_date_time = datetime.now(central).strftime("%m%d_%I%M")
|
30 |
+
safe_prompt = "".join(x for x in prompt if x.isalnum())[:45]
|
31 |
+
return f"{safe_date_time}_{safe_prompt}.{file_type}"
|
32 |
+
|
33 |
+
|
34 |
# Audio record and transcribe:
|
35 |
def transcribe_audio_ui(openai_key, file_path):
|
36 |
OPENAI_API_KEY = openai_key
|
|
|
58 |
def save_and_play_audio(audio_recorder):
|
59 |
audio_bytes = audio_recorder()
|
60 |
if audio_bytes:
|
61 |
+
filename = generate_filename("Recording", "wav")
|
|
|
62 |
with open(filename, 'wb') as f:
|
63 |
f.write(audio_bytes)
|
64 |
st.audio(audio_bytes, format="audio/wav")
|
|
|
81 |
response = openai.ChatCompletion.create(model=model, messages=conversation)
|
82 |
return response['choices'][0]['message']['content']
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
def create_file(filename, prompt, response):
|
85 |
if filename.endswith(".txt"):
|
86 |
with open(filename, 'w') as file:
|