Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -95,20 +95,7 @@ def model(text):
|
|
95 |
output += response.token.text
|
96 |
return output
|
97 |
|
98 |
-
|
99 |
-
user = transcribe(audio)
|
100 |
-
reply = model(user)
|
101 |
-
|
102 |
-
voice = Female_language_dict.get("English (UK)-Sonia- (Female)", "default_voice")
|
103 |
-
reply = clean_text(reply)
|
104 |
-
communicate = edge_tts.Communicate(reply, voice)
|
105 |
-
|
106 |
-
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
107 |
-
tmp_path = tmp_file.name
|
108 |
-
await communicate.save(tmp_path)
|
109 |
-
yield tmp_path
|
110 |
-
|
111 |
-
async def generate1(prompt):
|
112 |
generate_kwargs = dict(
|
113 |
temperature=0.6,
|
114 |
max_new_tokens=512,
|
@@ -124,17 +111,31 @@ async def generate1(prompt):
|
|
124 |
for response in stream:
|
125 |
if not response.token.text == "</s>":
|
126 |
output += response.token.text
|
127 |
-
|
128 |
-
voice = Female_language_dict.get("English (UK)-Sonia- (Female)", "default_voice")
|
129 |
output_text = clean_text(output)
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
133 |
tmp_path = tmp_file.name
|
134 |
await communicate.save(tmp_path)
|
135 |
yield tmp_path
|
136 |
-
return output_text
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
|
140 |
with gr.Blocks(theme=gr.themes.Glass(font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "Arial"])) as demo:
|
@@ -153,6 +154,7 @@ with gr.Blocks(theme=gr.themes.Glass(font=[gr.themes.GoogleFont("Inconsolata"),
|
|
153 |
with gr.Group():
|
154 |
user_input = gr.TextArea(label="Your Question", scale=1, show_copy_button=True, 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.")
|
155 |
output_audio = gr.Audio(label="Sonia's Response", scale=3, type="filepath", interactive=False, autoplay=True, elem_classes="audio", waveform_options=gr.WaveformOptions(show_recording_waveform=False), container=True )
|
|
|
156 |
gr.Interface(fn=generate1, inputs=user_input, outputs=[output_audio, output_text], live=False)
|
157 |
#gr.Interface(fn=generate1, inputs=user_input, outputs=output_audio, live=False)
|
158 |
|
|
|
95 |
output += response.token.text
|
96 |
return output
|
97 |
|
98 |
+
def respondtxt(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
generate_kwargs = dict(
|
100 |
temperature=0.6,
|
101 |
max_new_tokens=512,
|
|
|
111 |
for response in stream:
|
112 |
if not response.token.text == "</s>":
|
113 |
output += response.token.text
|
|
|
|
|
114 |
output_text = clean_text(output)
|
115 |
+
return (output_text)
|
116 |
+
|
117 |
+
|
118 |
+
async def respond(audio):
|
119 |
+
user = transcribe(audio)
|
120 |
+
reply = model(user)
|
121 |
+
|
122 |
+
voice = Female_language_dict.get("English (UK)-Sonia- (Female)", "default_voice")
|
123 |
+
reply = clean_text(reply)
|
124 |
+
communicate = edge_tts.Communicate(reply, voice)
|
125 |
+
|
126 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
127 |
tmp_path = tmp_file.name
|
128 |
await communicate.save(tmp_path)
|
129 |
yield tmp_path
|
|
|
130 |
|
131 |
+
async def generate1(prompt):
|
132 |
+
voice = Female_language_dict.get("English (UK)-Sonia- (Female)", "default_voice")
|
133 |
+
communicate = edge_tts.Communicate(output_text, voice)
|
134 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
135 |
+
tmp_path = tmp_file.name
|
136 |
+
await communicate.save(tmp_path)
|
137 |
+
yield tmp_path
|
138 |
+
|
139 |
|
140 |
|
141 |
with gr.Blocks(theme=gr.themes.Glass(font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "Arial"])) as demo:
|
|
|
154 |
with gr.Group():
|
155 |
user_input = gr.TextArea(label="Your Question", scale=1, show_copy_button=True, 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.")
|
156 |
output_audio = gr.Audio(label="Sonia's Response", scale=3, type="filepath", interactive=False, autoplay=True, elem_classes="audio", waveform_options=gr.WaveformOptions(show_recording_waveform=False), container=True )
|
157 |
+
output_text = respondtxt(user_input)
|
158 |
gr.Interface(fn=generate1, inputs=user_input, outputs=[output_audio, output_text], live=False)
|
159 |
#gr.Interface(fn=generate1, inputs=user_input, outputs=output_audio, live=False)
|
160 |
|