Upload folder using huggingface_hub
Browse files- handler.py +5 -1
handler.py
CHANGED
|
@@ -6,6 +6,7 @@ from s2s_pipeline import main, prepare_all_args, get_default_arguments, setup_lo
|
|
| 6 |
import numpy as np
|
| 7 |
from queue import Queue, Empty
|
| 8 |
import threading
|
|
|
|
| 9 |
|
| 10 |
class EndpointHandler:
|
| 11 |
def __init__(self, path=""):
|
|
@@ -111,7 +112,10 @@ class EndpointHandler:
|
|
| 111 |
# Combine all audio chunks into a single byte string
|
| 112 |
combined_audio = b''.join(output_chunks)
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
def cleanup(self):
|
| 117 |
# Stop the pipeline
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
from queue import Queue, Empty
|
| 8 |
import threading
|
| 9 |
+
import base64
|
| 10 |
|
| 11 |
class EndpointHandler:
|
| 12 |
def __init__(self, path=""):
|
|
|
|
| 112 |
# Combine all audio chunks into a single byte string
|
| 113 |
combined_audio = b''.join(output_chunks)
|
| 114 |
|
| 115 |
+
# Encode the combined audio as Base64
|
| 116 |
+
base64_audio = base64.b64encode(combined_audio).decode('utf-8')
|
| 117 |
+
|
| 118 |
+
return {"output": base64_audio}
|
| 119 |
|
| 120 |
def cleanup(self):
|
| 121 |
# Stop the pipeline
|