Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,11 +27,16 @@ Female_language_dict = {
|
|
| 27 |
'English (Ireland)-Emily- (Female)': 'en-IE-EmilyNeural',
|
| 28 |
}
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
engines = { default_lang: Model(default_lang) }
|
| 35 |
|
| 36 |
def transcribe(audio):
|
| 37 |
lang = "en"
|
|
@@ -39,10 +44,6 @@ def transcribe(audio):
|
|
| 39 |
text = model.stt_file(audio)[0]
|
| 40 |
return text
|
| 41 |
|
| 42 |
-
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 43 |
-
|
| 44 |
-
system_instructions1 = "<s>[SYSTEM] Your name is Sonia an Executive Assistant, answer with a female voice with a London slang and accent. Keep conversation professional. You are the Best Executive Assistant working for RJP Development Studio. You are a Harvard graduate PHD very knowledgeable, professional but friendly female Executive Assistant. You are sexy, femenine with a sharp and interesting personality. You will refer to the USER alternatively as: 'Darling' or 'dear.' or 'sweetheart' or 'honey'. Your role is to help users by answering their questions, providing information, and offering guidance to the best of your abilities. When responding, use a warm and professional tone, and break down complex topics into easy to understand explanations. If you are unsure about an answer, it is okay to say you do not know or you need to research more rather than guess. Generate a comprehensive and informative answer for a given question solely based on your knowledge and any necessary Web Search Results. when answering please use an unbiased and Diplomatic tone. Be concise and action oriented in your responses. Ensure all content is grammatically correct and free of spelling errors."
|
| 45 |
-
|
| 46 |
def model(text):
|
| 47 |
generate_kwargs = dict(
|
| 48 |
temperature=0.5,
|
|
@@ -60,11 +61,8 @@ def model(text):
|
|
| 60 |
for response in stream:
|
| 61 |
if not response.token.text == "</s>":
|
| 62 |
output += response.token.text
|
| 63 |
-
|
| 64 |
return output
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
async def respond(audio):
|
| 69 |
user = transcribe(audio)
|
| 70 |
reply = model(user)
|
|
@@ -77,10 +75,6 @@ async def respond(audio):
|
|
| 77 |
await communicate.save(tmp_path)
|
| 78 |
yield tmp_path
|
| 79 |
|
| 80 |
-
#client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 81 |
-
#system_instructions1 = "<s>[SYSTEM] Answer as Sonia Executive Assistant, with a female voice and a London slang and accent. Keep conversation professional, interesting, clear, friendly, and concise. The text provided is a request for a specific type of response from you, the best virtual executive assistant. You will refer to the USER alternatively as: 'Darling' or 'dear.' or 'sweetheart' or 'honey'. The expectation is that you will avoid introductions and start answering the query directly, elaborating on all aspects of the request. As an AI powered Executive Assistant, your task is to generate responses that appear as if they are created by a human, A Real Person, and not by an AI powered assistant. Do Not use * or **.[USER]"
|
| 82 |
-
|
| 83 |
-
|
| 84 |
async def generate1(prompt):
|
| 85 |
generate_kwargs = dict(
|
| 86 |
temperature=0.5,
|
|
@@ -108,26 +102,24 @@ async def generate1(prompt):
|
|
| 108 |
|
| 109 |
|
| 110 |
with gr.Blocks(gr.themes.Glass()) as demo:
|
| 111 |
-
|
| 112 |
gr.HTML(""" <img src='https://huggingface.co/spaces/Isidorophp/Executive-Assistant/resolve/main/logo.png' alt='RJP DEV STUDIO logo' style='height:60px'> """
|
| 113 |
-
""" <center> <h1> I am Sonia π±πΎββοΈ
|
| 114 |
-
""" <center> <h3>
|
| 115 |
-
|
| 116 |
-
|
| 117 |
with gr.Tab("Talk to Sonia"):
|
| 118 |
with gr.Row():
|
| 119 |
us_input = gr.Audio(label="Your Voice Chat", type="filepath", interactive=True, sources="microphone", waveform_options=None, scale=2,)
|
| 120 |
-
us_output = gr.Audio(label="Sonia", type="filepath", interactive=False, autoplay=True, elem_classes="audio", scale=2,)
|
| 121 |
gr.Interface(fn=respond, inputs=us_input, outputs=us_output, live=False)
|
| 122 |
|
| 123 |
with gr.Tab("Write to Sonia"):
|
| 124 |
with gr.Row():
|
| 125 |
user_input = gr.Textbox(label="Your Question", lines=5, scale=2, value="What are the key considerations for implementing an expansion plan that would affect a large number of employees of a global biomedical company, My position is logistics global Manager professional in inventory management and supply chain within a biotech industry, particularly in cell therapy. The key responsibilities include managing end-to-end logistics and lab implementation over a dispersed geographical area. generate new programs, develop MRP processes, collaborate with various departments, and ensure compliance with GMP standards. I have several years of practical experience, strong analytical skills, and the ability to work collaboratively in a dynamic environment. Bonus qualifications include experience with cold chain logistics and autologous cell therapy.")
|
| 126 |
-
output_audio = gr.Audio(label="Sonia", type="filepath", interactive=False, autoplay=True, elem_classes="audio")
|
| 127 |
with gr.Row():
|
| 128 |
-
translate_btn = gr.Button("
|
| 129 |
translate_btn.click(fn=generate1, inputs=user_input, outputs=output_audio, api_name="translate")
|
| 130 |
|
| 131 |
-
|
| 132 |
if __name__ == "__main__":
|
| 133 |
demo.queue(max_size=400, api_open=False).launch()
|
|
|
|
| 27 |
'English (Ireland)-Emily- (Female)': 'en-IE-EmilyNeural',
|
| 28 |
}
|
| 29 |
|
| 30 |
+
default_lang = "en"
|
| 31 |
+
engines = { default_lang: Model(default_lang) }
|
| 32 |
+
client1 = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 33 |
+
# system_instructions1 = "<s>[SYSTEM] Your name is Sonia an Executive Assistant, answer with a female voice with a London slang and accent. Keep conversation professional. You are the Best Executive Assistant working for RJP Development Studio. You are a Harvard graduate PHD very knowledgeable, professional but friendly female Executive Assistant. You are sexy, femenine with a sharp and interesting personality. You will refer to the USER alternatively as: 'Darling' or 'dear.' or 'sweetheart' or 'honey'. Your role is to help users by answering their questions, providing information, and offering guidance to the best of your abilities. When responding, use a warm and professional tone, and break down complex topics into easy to understand explanations. If you are unsure about an answer, it is okay to say you do not know or you need to research more rather than guess. Generate a comprehensive and informative answer for a given question solely based on your knowledge and any necessary Web Search Results. when answering please use an unbiased and Diplomatic tone. Be concise and action oriented in your responses. Ensure all content is grammatically correct and free of spelling errors."
|
| 34 |
+
system_instructions1 = "<s>[SYSTEM] "Hello, I'm Sonia, your professional and knowledgeable Executive Assistant at RJP Development Studio. I hold a PhD from Oxford University, which equips me with the expertise to assist you effectively. I bring a touch of London charm with a hint of slang to our conversations, ensuring they remain engaging and approachable.
|
| 35 |
|
| 36 |
+
I am here to provide you with accurate information, answer your questions, and offer guidance with a warm and professional tone. I will break down complex topics into easy-to-understand explanations. If I'm unsure about something, I will let you know and seek the necessary information rather than guessing.
|
| 37 |
|
| 38 |
+
I use unbiased and diplomatic language to ensure clarity and respect. Our conversations will be concise, action-oriented, and free of grammatical errors. I look forward to assisting you, darling!"
|
| 39 |
|
|
|
|
| 40 |
|
| 41 |
def transcribe(audio):
|
| 42 |
lang = "en"
|
|
|
|
| 44 |
text = model.stt_file(audio)[0]
|
| 45 |
return text
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def model(text):
|
| 48 |
generate_kwargs = dict(
|
| 49 |
temperature=0.5,
|
|
|
|
| 61 |
for response in stream:
|
| 62 |
if not response.token.text == "</s>":
|
| 63 |
output += response.token.text
|
|
|
|
| 64 |
return output
|
| 65 |
|
|
|
|
|
|
|
| 66 |
async def respond(audio):
|
| 67 |
user = transcribe(audio)
|
| 68 |
reply = model(user)
|
|
|
|
| 75 |
await communicate.save(tmp_path)
|
| 76 |
yield tmp_path
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
async def generate1(prompt):
|
| 79 |
generate_kwargs = dict(
|
| 80 |
temperature=0.5,
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
with gr.Blocks(gr.themes.Glass()) as demo:
|
| 105 |
+
|
| 106 |
gr.HTML(""" <img src='https://huggingface.co/spaces/Isidorophp/Executive-Assistant/resolve/main/logo.png' alt='RJP DEV STUDIO logo' style='height:60px'> """
|
| 107 |
+
""" <center> <h1> I am Sonia π±πΎββοΈ your Unique Executive Assistant. </h1></center> """
|
| 108 |
+
""" <center> <h3> Always ready to help you, talk to me. π </h3></center> """)
|
| 109 |
+
|
|
|
|
| 110 |
with gr.Tab("Talk to Sonia"):
|
| 111 |
with gr.Row():
|
| 112 |
us_input = gr.Audio(label="Your Voice Chat", type="filepath", interactive=True, sources="microphone", waveform_options=None, scale=2,)
|
| 113 |
+
us_output = gr.Audio(label="Sonia's Response", type="filepath", interactive=False, autoplay=True, elem_classes="audio", scale=2,)
|
| 114 |
gr.Interface(fn=respond, inputs=us_input, outputs=us_output, live=False)
|
| 115 |
|
| 116 |
with gr.Tab("Write to Sonia"):
|
| 117 |
with gr.Row():
|
| 118 |
user_input = gr.Textbox(label="Your Question", lines=5, scale=2, value="What are the key considerations for implementing an expansion plan that would affect a large number of employees of a global biomedical company, My position is logistics global Manager professional in inventory management and supply chain within a biotech industry, particularly in cell therapy. The key responsibilities include managing end-to-end logistics and lab implementation over a dispersed geographical area. generate new programs, develop MRP processes, collaborate with various departments, and ensure compliance with GMP standards. I have several years of practical experience, strong analytical skills, and the ability to work collaboratively in a dynamic environment. Bonus qualifications include experience with cold chain logistics and autologous cell therapy.")
|
| 119 |
+
output_audio = gr.Audio(label="Sonia's Response", type="filepath", interactive=False, autoplay=True, elem_classes="audio", scale=2,)
|
| 120 |
with gr.Row():
|
| 121 |
+
translate_btn = gr.Button("Submit", scale=2)
|
| 122 |
translate_btn.click(fn=generate1, inputs=user_input, outputs=output_audio, api_name="translate")
|
| 123 |
|
|
|
|
| 124 |
if __name__ == "__main__":
|
| 125 |
demo.queue(max_size=400, api_open=False).launch()
|