Spaces:
Sleeping
Sleeping
File size: 3,270 Bytes
aa9892b | 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | -- ์นดํ BGM ๊ธ๋ก๋ฒ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ
์ด๋ธ (2026-05-20, BGM ์๋น์ค Phase 1).
--
-- ์ฐ๋ฆฌ๊ฐ ์ฌ์ ์์ฑํ PRO-free ์นดํ ๋ฐฐ๊ฒฝ์์
์นดํ๋ก๊ทธ. Lyria 2 (Vertex AI) ๋ก ์์ฑ โ
-- auto-loop (src/bgm/autoloop.py: seamless loop + -16 LUFS) ํ์ฒ๋ฆฌ โ Supabase
-- Storage('music' ๋ฒํท) ์ ์ฅ โ ์ด ํ
์ด๋ธ์ ๋ฉํ๋ฐ์ดํฐ 1ํ.
--
-- ์ฌ์ ๊ฒฝ๋ก๋ GPU/API 0 โ ํญ์ Storage ํ์ผ ์๋น (signed URL). ์ด ํ
์ด๋ธ์ ์นดํ๋ก๊ทธ
-- (๋ชฉ๋ก/๋ฌด๋ ํํฐ/๊ฒ์) ์ฉ. ์ฌ์ฉ์ ๊ฐ์ธ ์์ฑ๊ณก์ ๋ณ๋ user_music ํ
์ด๋ธ(Phase 4).
--
-- ํ๊ท 0 ๊ฐ๋:
-- - ์ ๊ท ํ
์ด๋ธ โ ๊ธฐ์กด TTS/voice/playlist/care ์คํค๋ง ์ํฅ 0.
-- - RLS: ๊ธ๋ก๋ฒ ์นดํ๋ก๊ทธ๋ผ ์ธ์ฆ ์ฌ์ฉ์ + anon ์ฝ๊ธฐ ํ์ฉ(public read). ์ฐ๊ธฐ๋
-- service_role ๋ง (๋ฐฐ์น ๋น๋๊ฐ service_role ํค ์ฌ์ฉ) โ ๊ธฐ๋ณธ deny ๋ก ์ฌ์ฉ์ ์ฐ๊ธฐ ์ฐจ๋จ.
-- - storage_path ๋ 'music' ๋ฒํท ๋ด ์๋ ๊ฒฝ๋ก๋ง ์ ์ฅ (๋ฒํท๋ช
๋นํฌํจ) โ ๋ฒํท ์ด์ ๋๋น.
--
-- ์ดํ ๋จ๊ณ:
-- 1) ์ด SQL ์ ์ฉ (Supabase SQL editor ๋๋ ๋ง์ด๊ทธ๋ ์ด์
๋ฌ๋)
-- 2) Storage 'music' ๋ฒํท ์์ฑ (๋ฐฐ์น ๋น๋๊ฐ ์์ผ๋ฉด ์๋ ์์ฑ ์๋)
-- 3) scripts/bgm_library/build_library.py ๋ก ๋ฐฐ์น ์์ฑ โ ํ insert
-- 4) (Phase 2+) backend ๋ผ์ฐํฐ๊ฐ ์นดํ๋ก๊ทธ ์กฐํ + signed URL ๋ฐ๊ธ
--
-- ์ฐธ์กฐ: project_bgm_service (memory), src/bgm/autoloop.py
CREATE TABLE IF NOT EXISTS public.music_themes (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
title text NOT NULL,
genre text NOT NULL DEFAULT '',
mood_tags text[] NOT NULL DEFAULT '{}',
-- ์ฌํ/๊ฐ์ฌ์ฉ: ์์ฑ ํ๋ผ๋ฏธํฐ ๋ฐ์ (Lyria 2)
prompt text NOT NULL DEFAULT '',
negative_prompt text NOT NULL DEFAULT '',
seed bigint,
-- ์ค๋์ค ์์ฐ
storage_path text NOT NULL, -- 'music' ๋ฒํท ๋ด ์๋ ๊ฒฝ๋ก (์: themes/lofi/xxx.mp3)
duration_sec real,
bpm real,
-- auto-loop QC ์งํ (๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ง ์ถ์ )
lufs real,
qc_pop_ratio real,
qc_rms_ratio real,
qc_passed boolean NOT NULL DEFAULT true,
-- ์ด์
is_active boolean NOT NULL DEFAULT true,
created_at timestamptz NOT NULL DEFAULT now()
);
-- ๋ฌด๋ ํํฐ ์กฐํ (์: mood_tags @> '{lofi}')
CREATE INDEX IF NOT EXISTS music_themes_mood_tags_idx
ON public.music_themes USING gin (mood_tags);
CREATE INDEX IF NOT EXISTS music_themes_active_idx
ON public.music_themes (is_active, created_at DESC);
-- ๋์ผ (path) ์ค๋ณต ๋ฐฉ์ง (๋ฐฐ์น ์ฌ์คํ idempotency)
CREATE UNIQUE INDEX IF NOT EXISTS music_themes_storage_path_key
ON public.music_themes (storage_path);
ALTER TABLE public.music_themes ENABLE ROW LEVEL SECURITY;
-- ๊ธ๋ก๋ฒ ์นดํ๋ก๊ทธ: ํ์ฑ ํ์ ๋๊ตฌ๋ ์ฝ๊ธฐ (์ฌ์ ๊ฒฝ๋ก). ์ฐ๊ธฐ ์ ์ฑ
์์ = service_role ๋ง.
DROP POLICY IF EXISTS music_themes_public_read ON public.music_themes;
CREATE POLICY music_themes_public_read ON public.music_themes
FOR SELECT
USING (is_active = true);
COMMENT ON TABLE public.music_themes IS
'์นดํ BGM ๊ธ๋ก๋ฒ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (Lyria 2 ์์ฑ + auto-loop). ์ฌ์=Storage signed URL.';
|