Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,20 +65,6 @@ def combine_audio_files(audio_files):
|
|
65 |
os.remove(audio_file) # Remove temporary files
|
66 |
return combined
|
67 |
|
68 |
-
def postprocess(prediction_value):
|
69 |
-
if isinstance(prediction_value, pydub.AudioSegment):
|
70 |
-
# Convert AudioSegment to numpy array
|
71 |
-
samples = np.array(prediction_value.get_array_of_samples())
|
72 |
-
# If stereo, take the mean of both channels
|
73 |
-
if prediction_value.channels == 2:
|
74 |
-
samples = np.mean(samples.reshape(-1, 2), axis=1)
|
75 |
-
# Return as tuple (sample_rate, samples)
|
76 |
-
return (prediction_value.frame_rate, samples.astype(np.float32))
|
77 |
-
else:
|
78 |
-
raise ValueError(f"Cannot process {type(prediction_value)} as Audio")
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
#guardrail model
|
83 |
guard_llm = "llama-3.1-8b-instant"
|
84 |
|
@@ -138,7 +124,7 @@ async def greet(product,description):
|
|
138 |
audio_file = text_to_speech(a_list[0])
|
139 |
audio_files.append(audio_file)
|
140 |
final_audio = combine_audio_files(audio_files)
|
141 |
-
yield (final_audio.frame_rate,
|
142 |
else:
|
143 |
audio_files = []
|
144 |
output = llm.create_chat_completion(
|
@@ -160,7 +146,7 @@ async def greet(product,description):
|
|
160 |
audio_file = text_to_speech(delta.get('content', ''))
|
161 |
audio_files.append(audio_file)
|
162 |
final_audio = combine_audio_files(audio_files)
|
163 |
-
yield (final_audio.frame_rate,
|
164 |
|
165 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs=gr.Audio(), concurrency_limit=10)
|
166 |
demo.launch()
|
|
|
65 |
os.remove(audio_file) # Remove temporary files
|
66 |
return combined
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
#guardrail model
|
69 |
guard_llm = "llama-3.1-8b-instant"
|
70 |
|
|
|
124 |
audio_file = text_to_speech(a_list[0])
|
125 |
audio_files.append(audio_file)
|
126 |
final_audio = combine_audio_files(audio_files)
|
127 |
+
yield (final_audio.frame_rate, final_audio)
|
128 |
else:
|
129 |
audio_files = []
|
130 |
output = llm.create_chat_completion(
|
|
|
146 |
audio_file = text_to_speech(delta.get('content', ''))
|
147 |
audio_files.append(audio_file)
|
148 |
final_audio = combine_audio_files(audio_files)
|
149 |
+
yield (final_audio.frame_rate, final_audio)
|
150 |
|
151 |
demo = gr.Interface(fn=greet, inputs=["text","text"], outputs=gr.Audio(), concurrency_limit=10)
|
152 |
demo.launch()
|