Update backend/open_webui/apps/audio/main.py
Browse files
backend/open_webui/apps/audio/main.py
CHANGED
|
@@ -219,25 +219,28 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|
| 219 |
body = body.decode("utf-8")
|
| 220 |
body = json.loads(body)
|
| 221 |
body["model"] = app.state.config.TTS_MODEL
|
|
|
|
|
|
|
| 222 |
body = json.dumps(body).encode("utf-8")
|
| 223 |
except Exception:
|
| 224 |
pass
|
| 225 |
|
| 226 |
r = None
|
| 227 |
try:
|
| 228 |
-
r
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
| 234 |
|
| 235 |
-
r.raise_for_status()
|
| 236 |
|
| 237 |
# Save the streaming content to a file
|
| 238 |
with open(file_path, "wb") as f:
|
| 239 |
-
|
| 240 |
-
f.write(
|
| 241 |
|
| 242 |
with open(file_body_path, "w") as f:
|
| 243 |
json.dump(json.loads(body.decode("utf-8")), f)
|
|
@@ -368,7 +371,7 @@ def transcribe(file_path):
|
|
| 368 |
|
| 369 |
if app.state.config.STT_ENGINE == "":
|
| 370 |
from faster_whisper import WhisperModel
|
| 371 |
-
|
| 372 |
whisper_kwargs = {
|
| 373 |
"model_size_or_path": WHISPER_MODEL,
|
| 374 |
"device": whisper_device_type,
|
|
|
|
| 219 |
body = body.decode("utf-8")
|
| 220 |
body = json.loads(body)
|
| 221 |
body["model"] = app.state.config.TTS_MODEL
|
| 222 |
+
query=body["input"]
|
| 223 |
+
print(query)
|
| 224 |
body = json.dumps(body).encode("utf-8")
|
| 225 |
except Exception:
|
| 226 |
pass
|
| 227 |
|
| 228 |
r = None
|
| 229 |
try:
|
| 230 |
+
r=requests.get("https://cuio-e.hf.space",params={"query":query})
|
| 231 |
+
#r = requests.post(
|
| 232 |
+
# url=f"{app.state.config.TTS_OPENAI_API_BASE_URL}/audio/speech",
|
| 233 |
+
#data=body,
|
| 234 |
+
# headers=headers,
|
| 235 |
+
# stream=True,
|
| 236 |
+
#)
|
| 237 |
|
| 238 |
+
#r.raise_for_status()
|
| 239 |
|
| 240 |
# Save the streaming content to a file
|
| 241 |
with open(file_path, "wb") as f:
|
| 242 |
+
# for chunk in r.iter_content(chunk_size=8192):
|
| 243 |
+
f.write(r.content)
|
| 244 |
|
| 245 |
with open(file_body_path, "w") as f:
|
| 246 |
json.dump(json.loads(body.decode("utf-8")), f)
|
|
|
|
| 371 |
|
| 372 |
if app.state.config.STT_ENGINE == "":
|
| 373 |
from faster_whisper import WhisperModel
|
| 374 |
+
WHISPER_MODEL="base"
|
| 375 |
whisper_kwargs = {
|
| 376 |
"model_size_or_path": WHISPER_MODEL,
|
| 377 |
"device": whisper_device_type,
|