File size: 1,280 Bytes
45d92cc
 
 
d360571
45d92cc
d360571
 
 
 
 
 
c600f78
 
 
45d92cc
34e3f13
 
 
 
 
 
 
 
 
 
 
 
4d426ef
34e3f13
4d426ef
 
45d92cc
 
 
 
d360571
45d92cc
 
 
 
 
d360571
45d92cc
d360571
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from __future__ import annotations

import os
from pathlib import Path

import gradio as gr

from studio.ui import CSS, HEAD, THEME, build_app

APP_DIR = Path(__file__).resolve().parent
# Schriften und Hintergründe selbst gehostet (keine Google-Fonts-Requests)
from studio.daw.api import DAW_DIR  # noqa: E402

gr.set_static_paths(paths=[APP_DIR / "static", DAW_DIR])


def _is_hf_space() -> bool:
    """Erkennt die HF-Space-Laufzeitumgebung über alle gängigen Variablen."""
    return bool(
        os.environ.get("HF_SPACE_ID")
        or os.environ.get("SPACE_ID")
        or os.environ.get("SPACE_HOST")
        or os.environ.get("SPACE_REPO_NAME")
    )


# Im HF-Space ONUS-Mastering deaktivieren (nur lokal verfügbar).
# Lokal bleibt der volle Funktionsumfang aktiv.
if _is_hf_space() and os.environ.get("STUDIO_SPACE_MODE") is None:
    os.environ["STUDIO_SPACE_MODE"] = "1"

demo = build_app()


if __name__ == "__main__":
    os.chdir(APP_DIR)  # relative /gradio_api/file=static/… URLs
    demo.launch(
        server_name=os.environ.get("STUDIO_HOST", "0.0.0.0"),
        server_port=int(os.environ.get("STUDIO_PORT", os.environ.get("PORT", "7860"))),
        share=False,
        show_error=True,
        theme=THEME,
        css=CSS,
        head=HEAD,
    )