Spaces:
Running
Running
Upload 2 files
Browse files- streamlit_app.py +31 -4
streamlit_app.py
CHANGED
|
@@ -1,14 +1,41 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from songgen import (
|
| 4 |
VoiceBpeTokenizer,
|
| 5 |
SongGenMixedForConditionalGeneration,
|
| 6 |
SongGenProcessor
|
| 7 |
)
|
| 8 |
-
import soundfile as sf
|
| 9 |
-
import os
|
| 10 |
-
from datetime import datetime
|
| 11 |
-
import tempfile
|
| 12 |
|
| 13 |
# Page config
|
| 14 |
st.set_page_config(
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
+
import soundfile as sf
|
| 4 |
+
import os
|
| 5 |
+
import subprocess
|
| 6 |
+
import sys
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
import tempfile
|
| 9 |
+
|
| 10 |
+
# Install descript-audiotools if not available (bypass protobuf conflict)
|
| 11 |
+
@st.cache_resource
|
| 12 |
+
def ensure_descript_audiotools():
|
| 13 |
+
try:
|
| 14 |
+
import audiotools
|
| 15 |
+
return True
|
| 16 |
+
except ImportError:
|
| 17 |
+
st.info("🔧 กำลังติดตั้ง descript-audiotools... กรุณารอสักครู่")
|
| 18 |
+
try:
|
| 19 |
+
# Install without checking dependencies to bypass protobuf conflict
|
| 20 |
+
subprocess.check_call([
|
| 21 |
+
sys.executable, "-m", "pip", "install",
|
| 22 |
+
"--no-deps", "descript-audiotools>=0.7.2"
|
| 23 |
+
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 24 |
+
st.success("✅ ติดตั้ง descript-audiotools สำเร็จ!")
|
| 25 |
+
return True
|
| 26 |
+
except Exception as e:
|
| 27 |
+
st.warning(f"⚠️ ไม่สามารถติดตั้ง descript-audiotools อัตโนมัติ: {e}")
|
| 28 |
+
st.info("💡 กรุณาติดตั้ง manual: pip install --no-deps descript-audiotools>=0.7.2")
|
| 29 |
+
return False
|
| 30 |
+
|
| 31 |
+
# Ensure descript-audiotools is installed
|
| 32 |
+
ensure_descript_audiotools()
|
| 33 |
+
|
| 34 |
from songgen import (
|
| 35 |
VoiceBpeTokenizer,
|
| 36 |
SongGenMixedForConditionalGeneration,
|
| 37 |
SongGenProcessor
|
| 38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# Page config
|
| 41 |
st.set_page_config(
|