palbha commited on
Commit
df33bb7
·
verified ·
1 Parent(s): b9e169a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -15,7 +15,7 @@ def transcribe_audio(audio_path):
15
  try:
16
  # Upload the audio file
17
  #uploaded_file = client.files.upload(file=audio_path)
18
-
19
  # Send the file to Gemini for transcription
20
  response = client.models.generate_content(
21
  model='gemini-2.0-flash',
@@ -42,7 +42,7 @@ def chat_with_gemini(user_input, history):
42
  """
43
  if history is None or not isinstance(history, list): # Ensure history is initialized
44
  history = []
45
-
46
  # Initialize or continue conversation
47
  chat = client.chats.create(model="gemini-2.0-flash") if not history else history[-1]
48
 
@@ -118,8 +118,8 @@ with gr.Blocks(title="Gemini Audio Chatbot") as demo:
118
  label="Audio Input"
119
  )
120
 
121
- with gr.Row():
122
- text_input = gr.Textbox(label="Type your message here")
123
 
124
  with gr.Row():
125
  response_text = gr.Textbox(label="Assistant's Response")
@@ -142,15 +142,15 @@ with gr.Blocks(title="Gemini Audio Chatbot") as demo:
142
  outputs=[chat_display]
143
  )
144
 
145
- text_input.submit(
146
- process_text,
147
- inputs=[text_input, history],
148
- outputs=[response_text, history, audio_output]
149
- ).then(
150
- display_history,
151
- inputs=[history],
152
- outputs=[chat_display]
153
- )
154
 
155
  # Clear conversation
156
  clear_btn.click(
 
15
  try:
16
  # Upload the audio file
17
  #uploaded_file = client.files.upload(file=audio_path)
18
+ print("Audio Path is",audio_path)
19
  # Send the file to Gemini for transcription
20
  response = client.models.generate_content(
21
  model='gemini-2.0-flash',
 
42
  """
43
  if history is None or not isinstance(history, list): # Ensure history is initialized
44
  history = []
45
+ global chat
46
  # Initialize or continue conversation
47
  chat = client.chats.create(model="gemini-2.0-flash") if not history else history[-1]
48
 
 
118
  label="Audio Input"
119
  )
120
 
121
+ # with gr.Row():
122
+ # text_input = gr.Textbox(label="Type your message here")
123
 
124
  with gr.Row():
125
  response_text = gr.Textbox(label="Assistant's Response")
 
142
  outputs=[chat_display]
143
  )
144
 
145
+ # text_input.submit(
146
+ # process_text,
147
+ # inputs=[text_input, history],
148
+ # outputs=[response_text, history, audio_output]
149
+ # ).then(
150
+ # display_history,
151
+ # inputs=[history],
152
+ # outputs=[chat_display]
153
+ # )
154
 
155
  # Clear conversation
156
  clear_btn.click(