Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,6 +39,9 @@ async def generate1(prompt):
|
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
communicate = edge_tts.Communicate(output)
|
| 43 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 44 |
tmp_path = tmp_file.name
|
|
@@ -64,6 +67,9 @@ async def generate2(prompt):
|
|
| 64 |
for response in stream:
|
| 65 |
output += response.token.text
|
| 66 |
|
|
|
|
|
|
|
|
|
|
| 67 |
communicate = edge_tts.Communicate(output)
|
| 68 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 69 |
tmp_path = tmp_file.name
|
|
@@ -72,7 +78,7 @@ async def generate2(prompt):
|
|
| 72 |
|
| 73 |
client3 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
| 74 |
|
| 75 |
-
system_instructions3 = "[SYSTEM]The text provided is a request for a specific type of response from me, the virtual assistant. The request asks me to provide detailed and friendly responses as if I am the character Jarvis, inspired by 'Tony Stark.' The expectation is that I will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, my task is to generate responses that appear as if they are created by the user and not an AI-powered assistant.[USER]"
|
| 76 |
|
| 77 |
async def generate3(prompt):
|
| 78 |
generate_kwargs = dict(
|
|
@@ -89,6 +95,9 @@ async def generate3(prompt):
|
|
| 89 |
for response in stream:
|
| 90 |
output += response.token.text
|
| 91 |
|
|
|
|
|
|
|
|
|
|
| 92 |
communicate = edge_tts.Communicate(output)
|
| 93 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 94 |
tmp_path = tmp_file.name
|
|
@@ -101,9 +110,9 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 101 |
user_input = gr.Textbox(label="Type Your Question", value="")
|
| 102 |
input_text = gr.Textbox(label="Input Text", elem_id="important")
|
| 103 |
output_audio = gr.Audio(label="Womener AI", type="filepath",
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
with gr.Row():
|
| 108 |
translate_btn = gr.Button("Response")
|
| 109 |
translate_btn.click(fn=generate1, inputs=user_input,
|
|
@@ -112,4 +121,4 @@ with gr.Blocks(css="style.css") as demo:
|
|
| 112 |
gr.Markdown(MORE)
|
| 113 |
|
| 114 |
if __name__ == "__main__":
|
| 115 |
-
demo.queue(max_size=200).launch()
|
|
|
|
| 39 |
for response in stream:
|
| 40 |
output += response.token.text
|
| 41 |
|
| 42 |
+
# Clean the output to remove extraneous characters
|
| 43 |
+
output = re.sub(r'\s+', ' ', output).strip()
|
| 44 |
+
|
| 45 |
communicate = edge_tts.Communicate(output)
|
| 46 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 47 |
tmp_path = tmp_file.name
|
|
|
|
| 67 |
for response in stream:
|
| 68 |
output += response.token.text
|
| 69 |
|
| 70 |
+
# Clean the output to remove extraneous characters
|
| 71 |
+
output = re.sub(r'\s+', ' ', output).strip()
|
| 72 |
+
|
| 73 |
communicate = edge_tts.Communicate(output)
|
| 74 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 75 |
tmp_path = tmp_file.name
|
|
|
|
| 78 |
|
| 79 |
client3 = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
|
| 80 |
|
| 81 |
+
system_instructions3 = "[SYSTEM] The text provided is a request for a specific type of response from me, the virtual assistant. The request asks me to provide detailed and friendly responses as if I am the character Jarvis, inspired by 'Tony Stark.' The expectation is that I will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI-powered assistant, my task is to generate responses that appear as if they are created by the user and not an AI-powered assistant. [USER]"
|
| 82 |
|
| 83 |
async def generate3(prompt):
|
| 84 |
generate_kwargs = dict(
|
|
|
|
| 95 |
for response in stream:
|
| 96 |
output += response.token.text
|
| 97 |
|
| 98 |
+
# Clean the output to remove extraneous characters
|
| 99 |
+
output = re.sub(r'\s+', ' ', output).strip()
|
| 100 |
+
|
| 101 |
communicate = edge_tts.Communicate(output)
|
| 102 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
| 103 |
tmp_path = tmp_file.name
|
|
|
|
| 110 |
user_input = gr.Textbox(label="Type Your Question", value="")
|
| 111 |
input_text = gr.Textbox(label="Input Text", elem_id="important")
|
| 112 |
output_audio = gr.Audio(label="Womener AI", type="filepath",
|
| 113 |
+
interactive=False,
|
| 114 |
+
autoplay=True,
|
| 115 |
+
elem_classes="audio")
|
| 116 |
with gr.Row():
|
| 117 |
translate_btn = gr.Button("Response")
|
| 118 |
translate_btn.click(fn=generate1, inputs=user_input,
|
|
|
|
| 121 |
gr.Markdown(MORE)
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
| 124 |
+
demo.queue(max_size=200).launch()
|