Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -129,7 +129,7 @@ def generate_audio_elevenlabs(text):
|
|
129 |
|
130 |
# Define the template for generating responses based on context
|
131 |
template = """I am a guide for Birmingham, Alabama. I can provide recommendations and insights about the city, including events and activities.
|
132 |
-
Ask your question directly, and I'll provide a precise and quick,short and crisp response in a conversational way without any Greet.
|
133 |
Context:
|
134 |
{context}
|
135 |
|
@@ -139,14 +139,6 @@ Answer concisely:"""
|
|
139 |
# Create a prompt object using the template
|
140 |
prompt = ChatPromptTemplate.from_template(template)
|
141 |
|
142 |
-
# Function to generate a response using the prompt and the context
|
143 |
-
#def generate_response_with_prompt(context, question):
|
144 |
-
#response = prompt.format(
|
145 |
-
#context=context,
|
146 |
-
#question=question
|
147 |
-
#)
|
148 |
-
#return response
|
149 |
-
|
150 |
# Function to generate a response using the prompt and the context
|
151 |
def generate_response_with_prompt(context, question):
|
152 |
formatted_prompt = prompt.format(
|
@@ -201,8 +193,9 @@ def process_audio_query(audio_input):
|
|
201 |
# Create Gradio interface for audio input and output
|
202 |
interface = gr.Interface(
|
203 |
fn=process_audio_query,
|
204 |
-
inputs=gr.Audio(sources="microphone", type="numpy"),
|
205 |
-
outputs="
|
|
|
206 |
live=True,
|
207 |
description="Ask questions via audio and receive audio responses."
|
208 |
)
|
|
|
129 |
|
130 |
# Define the template for generating responses based on context
|
131 |
template = """I am a guide for Birmingham, Alabama. I can provide recommendations and insights about the city, including events and activities.
|
132 |
+
Ask your question directly, and I'll provide a precise and quick,short and crisp response in a conversational and straight-foreward way without any Greet.
|
133 |
Context:
|
134 |
{context}
|
135 |
|
|
|
139 |
# Create a prompt object using the template
|
140 |
prompt = ChatPromptTemplate.from_template(template)
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
# Function to generate a response using the prompt and the context
|
143 |
def generate_response_with_prompt(context, question):
|
144 |
formatted_prompt = prompt.format(
|
|
|
193 |
# Create Gradio interface for audio input and output
|
194 |
interface = gr.Interface(
|
195 |
fn=process_audio_query,
|
196 |
+
inputs=gr.Audio(sources="microphone", type="numpy",streaming=True,every=0.1),
|
197 |
+
outputs=gr.Audio(type="auto", autoplay=True),
|
198 |
+
#outputs="audio",
|
199 |
live=True,
|
200 |
description="Ask questions via audio and receive audio responses."
|
201 |
)
|