Spaces:
Sleeping
Sleeping
added audio
Browse files
app.py
CHANGED
@@ -82,6 +82,7 @@ async def greet(product,description):
|
|
82 |
description, # description
|
83 |
"", # output - leave this blank for generation!
|
84 |
)
|
|
|
85 |
chat_completion = client.chat.completions.create(
|
86 |
messages=[
|
87 |
{
|
@@ -94,7 +95,8 @@ async def greet(product,description):
|
|
94 |
warning_message = chat_completion.choices[0].message.content
|
95 |
if warning_message != 'safe':
|
96 |
chat = [chat_completion.choices[0].message.content]
|
97 |
-
|
|
|
98 |
else:
|
99 |
output = llm.create_chat_completion(
|
100 |
messages=[
|
@@ -113,11 +115,11 @@ async def greet(product,description):
|
|
113 |
for chunk in output:
|
114 |
delta = chunk['choices'][0]['delta']
|
115 |
if 'content' in delta:
|
116 |
-
|
117 |
-
|
118 |
partial_message = partial_message + delta.get('content', '')
|
119 |
-
yield partial_message
|
120 |
|
121 |
audio = gr.Audio()
|
122 |
-
demo = gr.Interface(fn=greet, inputs=["text","text"], concurrency_limit=10, outputs=["text"])
|
123 |
demo.launch()
|
|
|
82 |
description, # description
|
83 |
"", # output - leave this blank for generation!
|
84 |
)
|
85 |
+
#llama guard
|
86 |
chat_completion = client.chat.completions.create(
|
87 |
messages=[
|
88 |
{
|
|
|
95 |
warning_message = chat_completion.choices[0].message.content
|
96 |
if warning_message != 'safe':
|
97 |
chat = [chat_completion.choices[0].message.content]
|
98 |
+
processed_audio = combine_audio_files(text_to_speech([chat_completion.choices[0].message.content]))
|
99 |
+
yield processed_audio, chat[0]
|
100 |
else:
|
101 |
output = llm.create_chat_completion(
|
102 |
messages=[
|
|
|
115 |
for chunk in output:
|
116 |
delta = chunk['choices'][0]['delta']
|
117 |
if 'content' in delta:
|
118 |
+
audio_list.append([text_to_speech(delta.get('content', ''))])
|
119 |
+
processed_audio = combine_audio_files(audio_list)
|
120 |
partial_message = partial_message + delta.get('content', '')
|
121 |
+
yield processed_audio, partial_message
|
122 |
|
123 |
audio = gr.Audio()
|
124 |
+
demo = gr.Interface(fn=greet, inputs=["text","text"], concurrency_limit=10, outputs=[audio, "text"])
|
125 |
demo.launch()
|