Spaces:
Running
Running
gpt-omni
commited on
Commit
·
b7df447
1
Parent(s):
0d7b9d9
update
Browse files
app.py
CHANGED
|
@@ -312,6 +312,12 @@ def process_audio(audio):
|
|
| 312 |
if filepath is None:
|
| 313 |
return OUT_RATE, np.zeros((100, OUT_CHANNELS), dtype=np.int16)
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
cnt = 0
|
| 316 |
tik = time.time()
|
| 317 |
for chunk in run_AT_batch_stream(filepath):
|
|
@@ -327,15 +333,13 @@ def process_audio(audio):
|
|
| 327 |
return OUT_RATE, audio_data.astype(np.int16)
|
| 328 |
|
| 329 |
|
| 330 |
-
|
|
|
|
| 331 |
process_audio,
|
| 332 |
inputs=gr.Audio(type="filepath", label="Microphone"),
|
| 333 |
outputs=[gr.Audio(label="Response", streaming=streaming_output, autoplay=True)],
|
| 334 |
title="Chat Mini-Omni Demo",
|
| 335 |
live=True,
|
| 336 |
)
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
if __name__ == '__main__':
|
| 340 |
demo.queue()
|
| 341 |
demo.launch()
|
|
|
|
| 312 |
if filepath is None:
|
| 313 |
return OUT_RATE, np.zeros((100, OUT_CHANNELS), dtype=np.int16)
|
| 314 |
|
| 315 |
+
if not streaming_output:
|
| 316 |
+
chunk = run_AT_batch_stream(filepath)
|
| 317 |
+
audio_data = np.frombuffer(chunk, dtype=np.int16)
|
| 318 |
+
audio_data = audio_data.reshape(-1, OUT_CHANNELS)
|
| 319 |
+
return OUT_RATE, audio_data.astype(np.int16)
|
| 320 |
+
|
| 321 |
cnt = 0
|
| 322 |
tik = time.time()
|
| 323 |
for chunk in run_AT_batch_stream(filepath):
|
|
|
|
| 333 |
return OUT_RATE, audio_data.astype(np.int16)
|
| 334 |
|
| 335 |
|
| 336 |
+
if __name__ == '__main__':
|
| 337 |
+
demo = gr.Interface(
|
| 338 |
process_audio,
|
| 339 |
inputs=gr.Audio(type="filepath", label="Microphone"),
|
| 340 |
outputs=[gr.Audio(label="Response", streaming=streaming_output, autoplay=True)],
|
| 341 |
title="Chat Mini-Omni Demo",
|
| 342 |
live=True,
|
| 343 |
)
|
|
|
|
|
|
|
|
|
|
| 344 |
demo.queue()
|
| 345 |
demo.launch()
|