Spaces:
Running
Running
mmccanse commited on
Commit ·
87a8f85
1
Parent(s): 91fc0ef
update code to reconfigure formatting and layout.
Browse files- __pycache__/functions_mm.cpython-311.pyc +0 -0
- app.py +49 -37
__pycache__/functions_mm.cpython-311.pyc
ADDED
|
Binary file (10.7 kB). View file
|
|
|
app.py
CHANGED
|
@@ -41,57 +41,69 @@ from functions_mm import handle_query, transcribe_audio_original, submit_questio
|
|
| 41 |
|
| 42 |
|
| 43 |
# Load environment variables.
|
| 44 |
-
load_dotenv()
|
| 45 |
|
| 46 |
-
# Set the model name for our LLMs.
|
| 47 |
-
OPENAI_MODEL = "gpt-3.5-turbo"
|
| 48 |
-
# Store the API key in a variable.
|
| 49 |
-
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 50 |
|
| 51 |
|
| 52 |
# In[5]:
|
| 53 |
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
instructions = """
|
| 56 |
-
# Diabetes Chatbot
|
| 57 |
-
#### Step 1: Record your audio OR input text (NOT both!) -- Step 2: Would you like response in new language? Choose your language
|
| 58 |
-
#### Step 3: Submit question -- Step 4: Translate response -- Step 5: Clear inputs and start fresh
|
| 59 |
-
"""
|
| 60 |
|
| 61 |
-
|
| 62 |
-
with gr.Blocks() as app2:
|
| 63 |
|
| 64 |
with gr.Row():
|
| 65 |
gr.Markdown(instructions)
|
| 66 |
|
| 67 |
with gr.Row():
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
#Divide the screen horizontally into 2 columns
|
| 81 |
with gr.Row():
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
query_text = gr.Textbox(label="Type your question here. If there is audio recorded AND question text, app will submit question text. Click transcribe button to populate with audio text")
|
| 85 |
-
# output_original_speech = gr.Audio(label="Text to speech here")
|
| 86 |
-
|
| 87 |
-
with gr.Column():
|
| 88 |
-
response_text = gr.Textbox(label="Chatbot response")
|
| 89 |
-
response_speech = gr.Audio(label="Chatbot response speech")
|
| 90 |
-
|
| 91 |
-
#This column will be on the right side of screen
|
| 92 |
-
with gr.Column():
|
| 93 |
-
output_translated = gr.Textbox(label="Translated text")
|
| 94 |
-
output_translated_speech = gr.Audio(label="Translated speech")
|
| 95 |
|
| 96 |
# Audio transcription
|
| 97 |
transcribe_button.click(
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# Load environment variables.
|
| 44 |
+
# load_dotenv()
|
| 45 |
|
| 46 |
+
# # Set the model name for our LLMs.
|
| 47 |
+
# OPENAI_MODEL = "gpt-3.5-turbo"
|
| 48 |
+
# # Store the API key in a variable.
|
| 49 |
+
# OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 50 |
|
| 51 |
|
| 52 |
# In[5]:
|
| 53 |
|
| 54 |
+
instructions="""
|
| 55 |
+
# Diabetes Chatbot!
|
| 56 |
+
## Ask a question through audio recording/text. Receive a response. Translate to selected language."""
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
with gr.Blocks(theme=theme) as app2:
|
|
|
|
| 60 |
|
| 61 |
with gr.Row():
|
| 62 |
gr.Markdown(instructions)
|
| 63 |
|
| 64 |
with gr.Row():
|
| 65 |
+
with gr.Column(variant="panel", scale=1):
|
| 66 |
+
# gr.Markdown("## Step 1: Enter question by recording audio")
|
| 67 |
+
input_audio = gr.Audio(
|
| 68 |
+
label="Click the microphone to record audio",
|
| 69 |
+
type="filepath",
|
| 70 |
+
waveform_options=gr.WaveformOptions(
|
| 71 |
+
waveform_color="#01C6FF",
|
| 72 |
+
waveform_progress_color="#0066B4",
|
| 73 |
+
skip_length=2,
|
| 74 |
+
show_controls=False,)
|
| 75 |
+
)
|
| 76 |
+
# gr.Markdown("## Step 2: Transcribe audio into text")
|
| 77 |
+
transcribe_button = gr.Button("Transcribe audio", variant="primary")
|
| 78 |
+
# gr.Markdown("## Step 3: Transcribed audio appears here. Or, type your question here.")
|
| 79 |
+
query_text = gr.Textbox(placeholder="transcribed audio appears here. Or, type a question here.")
|
| 80 |
+
# gr.Markdown("## Submit your question")
|
| 81 |
+
submit_button = gr.Button("Submit your question", variant="primary")
|
| 82 |
+
|
| 83 |
+
with gr.Column(variant="panel", scale=2):
|
| 84 |
+
response_text = gr.Textbox(label="Chatbot response")
|
| 85 |
+
response_speech = gr.Audio(label="Chatbot response speech",
|
| 86 |
+
waveform_options=gr.WaveformOptions(
|
| 87 |
+
waveform_color="#01C6FF",
|
| 88 |
+
waveform_progress_color="#0066B4",
|
| 89 |
+
skip_length=2,
|
| 90 |
+
show_controls=False,))
|
| 91 |
+
|
| 92 |
+
with gr.Column(variant="panel", scale=2):
|
| 93 |
+
language_dropdown = gr.Dropdown(label="Click the middle of the dropdown bar to select translation language",
|
| 94 |
+
choices=list(language_map.keys()), value=default_language, type='value')
|
| 95 |
+
translate_button = gr.Button("Translate the response", variant="primary")
|
| 96 |
+
output_translated = gr.Textbox(label="Translated text")
|
| 97 |
+
output_translated_speech = gr.Audio(label="Translated speech",
|
| 98 |
+
waveform_options=gr.WaveformOptions(
|
| 99 |
+
waveform_color="#01C6FF",
|
| 100 |
+
waveform_progress_color="#0066B4",
|
| 101 |
+
skip_length=2,
|
| 102 |
+
show_controls=False,))
|
| 103 |
|
|
|
|
| 104 |
with gr.Row():
|
| 105 |
+
clear_button = gr.Button("Clear All", variant="primary")
|
| 106 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Audio transcription
|
| 109 |
transcribe_button.click(
|